google-wallet / rest-samples

Samples for the Google Wallet REST APIs
https://developers.google.com/wallet/
Apache License 2.0
277 stars 119 forks source link

Creating generic pass with template info using google client library #78

Open miguelRedit opened 1 year ago

miguelRedit commented 1 year ago

Hello

Could you please let us know how to create programmatically a generic card pass in .net using google client library? Would like to know to to define the filed path for my texmodules.

Something like this:

GenericObject newObject = new GenericObject
{
      TextModulesData = new List<TextModuleData>
                    {
                        new TextModuleData
                        {
                        Header = eventTicketDTO.NameLabel,
                        Body = eventTicketDTO.Name,
                        Id = "nome"

                        },
                        new TextModuleData
                        {
                        Header = eventTicketDTO.AssociatedLabel,
                        Body = eventTicketDTO.Associated,
                        Id = "socio"
                        },

                        new TextModuleData
                        {
                        Header = eventTicketDTO.BenchLabel,
                        Body = eventTicketDTO.Bench,
                        Id = "bancada",

                        }
            }
}

and class like

GenericClass newClass = new GenericClass
                {
                    Id = $"{issuerId}.{classSuffix}",
                    ClassTemplateInfo = new ClassTemplateInfo
                    {
                        CardTemplateOverride = new CardTemplateOverride
                        {
                            CardRowTemplateInfos = new List<CardRowTemplateInfo>
                            {
                                new CardRowTemplateInfo()
                                {
                                    OneItem = new CardRowOneItem
                                    {
                                       Item = new TemplateItem
                                       {
                                            FirstValue= new FieldSelector
                                            {
                                                Fields = new List<FieldReference>
                                                {
                                                    new FieldReference
                                                    {
                                                        FieldPath = "object.payload.genericObjects[0].textModulesData[0].id"

                                                    }
                                                }
                                            },
                                            SecondValue= new FieldSelector
                                            {
                                                Fields = new List<FieldReference>
                                                {
                                                    new FieldReference
                                                    {
                                                        FieldPath = "object.payload.genericObjects[0].textModulesData[0].id"
                                                    }
                                                }
                                            }

                                       }
                                    }
                                },
                    }
         }
    }

For some reason all of my attemps its not working, its not defining a template and referencing the values

Thanks a lot!

singhdilip1007 commented 1 year ago

@miguelRedit I'm also looking for a way to create a google generic pass using C#, but no results have been found. Have to got anything? Please let me know