Beispiel #1
0
        /// <summary>
        /// Get a class with Google Pay API for Passes REST API
        /// See https://developers.google.com/pay/passes/reference/v1/loyaltyclass/get
        /// </summary>
        /// <param name="id">id of the class</param>
        /// <returns>class</returns>
        public LoyaltyClass getLoyaltyClass(string id)
        {
            LoyaltyClass response = null;
            // Uses the Google Pay API for Passes C# client lib to get a Loyalty class
            // check the devsite for newest client lib: https://developers.google.com/pay/passes/support/libraries#libraries
            // check reference API to see the underlying REST call:
            // https://developers.google.com/pay/passes/reference/v1/loyaltyclass/get
            WalletobjectsService service = new WalletobjectsService(new Google.Apis.Services.BaseClientService.Initializer()
            {
                HttpClientInitializer = this.credential
            });

            try
            {
                response = service.Loyaltyclass.Get(id).Execute();
            }
            catch (Google.GoogleApiException ge)
            {
                System.Console.WriteLine(">>>> [START] Google Server Error response:");
                System.Console.WriteLine(ge.Message);
                System.Console.WriteLine(">>>> [END] Google Server Error response\n");
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e.StackTrace);
            }
            return(response);
        }
Beispiel #2
0
 public void addLoyaltyClass(LoyaltyClass loyaltyClass)
 {
     if (this.payload.loyaltyClasses == null)
     {
         this.payload.loyaltyClasses = new List <LoyaltyClass>();
     }
     this.payload.loyaltyClasses.Add(loyaltyClass);
 }
        public virtual void ProcessRequest(HttpContext context)
        {
            try
            {
                HttpRequest request = context.Request;

                // get settings
                WobCredentials credentials = new WobCredentials(
                    WebConfigurationManager.AppSettings["ServiceAccountId"],
                    WebConfigurationManager.AppSettings["ServiceAccountPrivateKey"],
                    WebConfigurationManager.AppSettings["ApplicationName"],
                    WebConfigurationManager.AppSettings["IssuerId"]);

                string loyaltyClassId = WebConfigurationManager.AppSettings["LoyaltyClassId"];
                string offerClassId   = WebConfigurationManager.AppSettings["OfferClassId"];

                // OAuth - setup certificate based on private key file
                X509Certificate2 certificate = new X509Certificate2(
                    AppDomain.CurrentDomain.BaseDirectory + credentials.serviceAccountPrivateKey,
                    "notasecret",
                    X509KeyStorageFlags.Exportable);

                // create service account credential
                ServiceAccountCredential credential = new ServiceAccountCredential(
                    new ServiceAccountCredential.Initializer(credentials.serviceAccountId)
                {
                    Scopes = new[] { "https://www.googleapis.com/auth/wallet_object.issuer" }
                }.FromCertificate(certificate));

                // create the service
                var woService = new WalletobjectsService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName       = "Wallet Objects API Sample",
                });

                // get the class type
                string type = request.Params["type"];

                // insert the class
                if (type.Equals("loyalty"))
                {
                    LoyaltyClass loyaltyClass = Loyalty.generateLoyaltyClass(credentials.IssuerId, loyaltyClassId);
                    woService.Loyaltyclass.Insert(loyaltyClass).Execute();
                }
                else if (type.Equals("offer"))
                {
                    OfferClass offerClass = Offer.generateOfferClass(credentials.IssuerId, offerClassId);
                    woService.Offerclass.Insert(offerClass).Execute();
                }
            }
            catch (Exception e)
            {
                Console.Write(e.StackTrace);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Generates a signed "object" JWT.
        /// 1 REST call is made to pre-insert class.
        /// If this JWT only contains 1 object, usually isn't too long; can be used in Android intents/redirects.
        /// </summary>
        /// <param name="verticalType"> pass type to created</param>
        /// <param name="classId">the unique identifier for the class</param>
        /// <param name="objectId">the unique identifier for the object</param>
        /// <returns></returns>
        public string makeObjectJwt(VerticalType verticalType, string classId, string objectId)
        {
            ResourceDefinitions resourceDefinitions = ResourceDefinitions.getInstance();
            RestMethods         restMethods         = RestMethods.getInstance();
            // create JWT to put objects and class into JSON Web Token (JWT) format for Google Pay API for Passes
            Jwt googlePassJwt = new Jwt();

            // get class, object definitions, insert class (check in Merchant center GUI: https://pay.google.com/gp/m/issuer/list)
            try
            {
                switch (verticalType)
                {
                case VerticalType.OFFER:
                    OfferClass  offerClass  = resourceDefinitions.makeOfferClassResource(classId);
                    OfferObject offerObject = resourceDefinitions.makeOfferObjectResource(objectId, classId);
                    System.Console.WriteLine("\nMaking REST call to insert class");
                    OfferClass classResponse = restMethods.insertOfferClass(offerClass);
                    System.Console.WriteLine("\nMaking REST call to get object to see if it exists.");
                    OfferObject objectResponse = restMethods.getOfferObject(objectId);
                    // check responses
                    if (!(classResponse is null))
                    {
                        System.Console.WriteLine($"classId: {classId} inserted.");
                    }
                    else
                    {
                        System.Console.WriteLine($"classId: {classId} insertion failed. See above Server Response for more information.");
                    }
                    if (!(objectResponse is null))
                    {
                        System.Console.WriteLine($"objectId: {objectId} already exists.");
                    }
                    if (!(objectResponse is null) && objectResponse.ClassId != offerObject.ClassId)
                    {
                        System.Console.WriteLine($"the classId of inserted object is ({objectResponse.ClassId}). " +
                                                 $"It does not match the target classId ({offerObject.ClassId}). The saved object will not " +
                                                 "have the class properties you expect.");
                    }
                    // need to add only object because class was pre-inserted
                    googlePassJwt.addOfferObject(offerObject);
                    break;

                case VerticalType.LOYALTY:
                    LoyaltyClass  loyaltyClass  = resourceDefinitions.makeLoyaltyClassResource(classId);
                    LoyaltyObject loyaltyObject = resourceDefinitions.makeLoyaltyObjectResource(objectId, classId);
                    System.Console.WriteLine("\nMaking REST call to insert class");
                    LoyaltyClass loyaltyClassResponse = restMethods.insertLoyaltyClass(loyaltyClass);
                    System.Console.WriteLine("\nMaking REST call to get object to see if it exists.");
                    LoyaltyObject loyaltyObjectResponse = restMethods.getLoyaltyObject(objectId);
                    // check responses
                    if (!(loyaltyClassResponse is null))
                    {
                        System.Console.WriteLine($"classId: {classId} inserted.");
                    }
        public void TestInsertLoyaltyClassAndObject()
        {
            RestMethods         restMethods         = RestMethods.getInstance();
            ResourceDefinitions resourceDefinitions = ResourceDefinitions.getInstance();
            VerticalType        verticalType        = Services.VerticalType.LOYALTY;
            Config        config         = Config.getInstance();
            string        UUID           = Guid.NewGuid().ToString();
            string        classUid       = $"{verticalType.ToString()}_CLASS_{UUID}";
            string        classId        = $"{config.getIssuerId()}.{classUid}";
            string        UUIDobj        = Guid.NewGuid().ToString();
            string        objectUid      = $"{verticalType.ToString()}_OBJECT_{UUIDobj}";
            string        objectId       = $"{config.getIssuerId()}.{objectUid}";
            LoyaltyClass  classResponse  = restMethods.insertLoyaltyClass(resourceDefinitions.makeLoyaltyClassResource(classId));
            LoyaltyObject objectResponse = restMethods.insertLoyaltyObject(resourceDefinitions.makeLoyaltyObjectResource(objectId, classId));

            Assert.NotNull(classResponse);
            Assert.NotNull(objectResponse);
        }
Beispiel #6
0
 /// <summary>Updates the loyalty class referenced by the given class ID.</summary>
 /// <param name="body">The body of the request.</param>
 /// <param name="resourceId">The unique identifier for a class. This ID must be unique across all classes from an
 /// issuer. This value should follow the format issuer ID.identifier where the former is issued by Google and latter is
 /// chosen by you. Your unique identifier should only include alphanumeric characters, '.', '_', or '-'.</param>
 public virtual UpdateRequest Update(LoyaltyClass body, string resourceId)
 {
     return(new UpdateRequest(service, body, resourceId));
 }
Beispiel #7
0
 /// <summary>Updates the loyalty class referenced by the given class ID. This method supports patch
 /// semantics.</summary>
 /// <param name="body">The body of the request.</param>
 /// <param name="resourceId">The unique identifier for a class. This ID must be unique across all classes from an
 /// issuer. This value should follow the format issuer ID.identifier where the former is issued by Google and latter is
 /// chosen by you. Your unique identifier should only include alphanumeric characters, '.', '_', or '-'.</param>
 public virtual PatchRequest Patch(LoyaltyClass body, string resourceId)
 {
     return(new PatchRequest(service, body, resourceId));
 }
Beispiel #8
0
 /// <summary>Inserts an loyalty class with the given ID and properties.</summary>
 /// <param name="body">The body of the request.</param>
 public virtual InsertRequest Insert(LoyaltyClass body)
 {
     return(new InsertRequest(service, body));
 }
        /// <summary>
        /// Generate a loyalty class
        /// See https://developers.google.com/pay/passes/reference/v1/loyaltyclass
        /// </summary>
        /// <param name="classId"> the unique identifier for a class</param>
        /// <returns>the inserted loyalty class</returns>
        public LoyaltyClass makeLoyaltyClassResource(string classId)
        {
            // Define the resource representation of the Class
            // values should be from your DB/services; here we hardcode information
            // below defines an loyalty class. For more properties, check:
            //// https://developers.google.com/pay/passes/reference/v1/loyaltyclass/insert
            //// https://developers.google.com/pay/passes/guides/pass-verticals/loyalty/design

            // There is a client lib to help make the data structure. Newest client is on
            // devsite:
            //// https://developers.google.com/pay/passes/support/libraries#libraries
            LoyaltyClass payload = new LoyaltyClass();

            //required fields
            payload.Id          = classId;
            payload.IssuerName  = "Baconrista Coffee";
            payload.ProgramName = "Baconrista Rewards";
            payload.ProgramLogo = new Image()
            {
                SourceUri = new ImageUri()
                {
                    Uri = "http://farm8.staticflickr.com/7340/11177041185_a61a7f2139_o.jpg"
                }
            };
            payload.ReviewStatus = "underReview";
            //optional fields. See design and reference api for more
            payload.TextModulesData = new List <TextModuleData>()
            {
                new TextModuleData()
                {
                    Header = "Rewards details",
                    Body   = "Welcome to Baconrista rewards.  Enjoy your rewards for being a loyal customer. "
                             + "10 points for ever dollar spent.  Redeem your points for free coffee, bacon and more! "
                }
            };
            payload.LinksModuleData = new LinksModuleData()
            {
                Uris = new List <Uri>()
                {
                    new Uri()
                    {
                        UriValue    = "http://maps.google.com/",
                        Description = "Nearby Locations"
                    },
                    new Uri()
                    {
                        UriValue    = "tel:6505555555",
                        Description = "Call Customer Service"
                    }
                }
            };
            payload.ImageModulesData = new List <ImageModuleData>()
            {
                new ImageModuleData()
                {
                    MainImage = new Image()
                    {
                        SourceUri = new ImageUri()
                        {
                            Uri         = "http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg",
                            Description = "Coffee beans"
                        }
                    }
                }
            };
            payload.Messages = new List <Message>()
            {
                new Message()
                {
                    Header = "Welcome to Banconrista Rewards!",
                    Body   = "Featuring our new bacon donuts."
                }
            };
            payload.RewardsTier      = "Gold";
            payload.RewardsTierLabel = "Tier";
            payload.Locations        = new List <LatLongPoint>()
            {
                new LatLongPoint()
                {
                    Latitude  = 37.424015499999996,
                    Longitude = -122.09259560000001
                },
                new LatLongPoint()
                {
                    Latitude  = 37.7901435,
                    Longitude = -122.09508869999999
                },
                new LatLongPoint()
                {
                    Latitude  = 37.424354,
                    Longitude = -122.39026709999997
                },
                new LatLongPoint()
                {
                    Latitude  = 40.7406578,
                    Longitude = -74.00208940000002
                }
            };
            return(payload);
        }
    /// <summary>
    /// Generates a Loyalty Class
    /// </summary>
    /// <param name="issuerId"> </param>
    /// <param name="classId"> </param>
    /// <returns> loyaltyClass </returns>
    public static LoyaltyClass generateLoyaltyClass(string issuerId, string classId)
    {
        // Define rendering templates per view
        IList<RenderSpec> renderSpec = new List<RenderSpec>();

        RenderSpec listRenderSpec = new RenderSpec() {
          ViewName = "g_list",
          TemplateFamily = "1.loyalty_list"
        };

        RenderSpec expandedRenderSpec = new RenderSpec() {
          ViewName = "g_expanded",
          TemplateFamily = "1.loyalty_expanded"
        };

        renderSpec.Add(listRenderSpec);
        renderSpec.Add(expandedRenderSpec);

        // Define the Image Module Data
        IList<ImageModuleData> imageModulesData = new List<ImageModuleData>();
        ImageModuleData image = new ImageModuleData() {
          MainImage = new Image() {
            SourceUri = new Uri() {
              UriValue = "http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg",
              Description = "Coffee beans"
            }
          }
        };
        imageModulesData.Add(image);

        // Define Text Module Data
        IList<TextModuleData> textModulesData = new List<TextModuleData>();
        TextModuleData textModuleData = new TextModuleData() {
          Header = "Rewards details",
          Body = "Welcome to Baconrista rewards.  Enjoy your rewards for being a loyal customer.  " +
          "10 points for ever dollar spent.  Redeem your points for free coffee, bacon and more!"
        };
        textModulesData.Add(textModuleData);

        // Define Links Module Data
        IList<Uri> uris = new List<Uri>();
        Uri uri1 = new Uri() {
          Description = "Nearby Locations",
          UriValue = "http://maps.google.com/maps?q=google"
        };
        Uri uri2 = new Uri() {
          Description = "Call Customer Service",
          UriValue = "tel:6505555555"
        };
        uris.Add(uri1);
        uris.Add(uri2);

        LinksModuleData linksModuleData = new LinksModuleData() {
          Uris = uris
        };

        // Define Info Module
        InfoModuleData infoModuleData = new InfoModuleData() {
          HexFontColor = "#F8EDC1",
          HexBackgroundColor = "#442905",
          ShowLastUpdateTime = true
        };

        // Define general messages
        IList<WalletObjectMessage> messages = new List<WalletObjectMessage>();
        WalletObjectMessage message = new WalletObjectMessage() {
          Header = "Welcome to Banconrista Rewards!",
          Body = "Featuring our new bacon donuts.",
          Image = new Image() {
            SourceUri = new Uri() {
              UriValue = "http://farm8.staticflickr.com/7302/11177240353_115daa5729_o.jpg"
            }
          },
          ActionUri = new Uri() { UriValue = "http://baconrista.com" }
        };
        messages.Add(message);

        // Define Geofence locations
        IList<LatLongPoint> locations = new List<LatLongPoint>();
        locations.Add(new LatLongPoint() { Latitude = 37.422601, Longitude = -122.085286 });
        locations.Add(new LatLongPoint() { Latitude = 37.424354, Longitude = -122.09508869999999 });
        locations.Add(new LatLongPoint() { Latitude = 40.7406578, Longitude = -74.00208940000002 });

        // Create Loyalty class
        LoyaltyClass wobClass = new LoyaltyClass() {
          Id = issuerId + "." + classId,
          IssuerName = "Baconrista",
          ProgramName = "Baconrista Rewards",
          ProgramLogo = new Image() {
            SourceUri = new Uri() {
              UriValue = "http://farm8.staticflickr.com/7340/11177041185_a61a7f2139_o.jpg"
            }
          },
          RewardsTierLabel = "Tier",
          RewardsTier = "Gold",
          AccountNameLabel = "Member Name",
          AccountIdLabel = "Member Id",
          RenderSpecs = renderSpec,
          Messages = messages,
          ReviewStatus = "underReview",
          AllowMultipleUsersPerObject = true,
          Locations = locations,
          ImageModulesData = imageModulesData,
          InfoModuleData = infoModuleData,
          TextModulesData = textModulesData,
          LinksModuleData = linksModuleData
        };

        return wobClass;
    }
Beispiel #11
0
        /// <summary>
        /// Generates a Loyalty Class
        /// </summary>
        /// <param name="issuerId"> </param>
        /// <param name="classId"> </param>
        /// <returns> loyaltyClass </returns>
        public static LoyaltyClass generateLoyaltyClass(string issuerId, string classId)
        {
            // Define the Image Module Data
            IList <ImageModuleData> imageModulesData = new List <ImageModuleData>();
            ImageModuleData         image            = new ImageModuleData()
            {
                MainImage = new Image()
                {
                    SourceUri = new Uri()
                    {
                        UriValue    = "http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg",
                        Description = "Coffee beans"
                    }
                }
            };

            imageModulesData.Add(image);

            // Define Text Module Data
            IList <TextModuleData> textModulesData = new List <TextModuleData>();
            TextModuleData         textModuleData  = new TextModuleData()
            {
                Header = "Rewards details",
                Body   = "Welcome to Baconrista rewards.  Enjoy your rewards for being a loyal customer.  " +
                         "10 points for ever dollar spent.  Redeem your points for free coffee, bacon and more!"
            };

            textModulesData.Add(textModuleData);

            // Define Links Module Data
            IList <Uri> uris = new List <Uri>();
            Uri         uri1 = new Uri()
            {
                Description = "Nearby Locations",
                UriValue    = "http://maps.google.com/maps?q=google"
            };
            Uri uri2 = new Uri()
            {
                Description = "Call Customer Service",
                UriValue    = "tel:6505555555"
            };

            uris.Add(uri1);
            uris.Add(uri2);

            LinksModuleData linksModuleData = new LinksModuleData()
            {
                Uris = uris
            };

            // Define Info Module
            InfoModuleData infoModuleData = new InfoModuleData()
            {
                HexFontColor       = "#F8EDC1",
                HexBackgroundColor = "#442905",
                ShowLastUpdateTime = true
            };

            // Define general messages
            IList <WalletObjectMessage> messages = new List <WalletObjectMessage>();
            WalletObjectMessage         message  = new WalletObjectMessage()
            {
                Header = "Welcome to Banconrista Rewards!",
                Body   = "Featuring our new bacon donuts.",
                Image  = new Image()
                {
                    SourceUri = new Uri()
                    {
                        UriValue = "http://farm8.staticflickr.com/7302/11177240353_115daa5729_o.jpg"
                    }
                },
                ActionUri = new Uri()
                {
                    UriValue = "http://baconrista.com"
                }
            };

            messages.Add(message);

            // Define Geofence locations
            IList <LatLongPoint> locations = new List <LatLongPoint>();

            locations.Add(new LatLongPoint()
            {
                Latitude = 37.422601, Longitude = -122.085286
            });
            locations.Add(new LatLongPoint()
            {
                Latitude = 37.424354, Longitude = -122.09508869999999
            });
            locations.Add(new LatLongPoint()
            {
                Latitude = 40.7406578, Longitude = -74.00208940000002
            });

            // Create Loyalty class
            LoyaltyClass wobClass = new LoyaltyClass()
            {
                Id          = issuerId + "." + classId,
                IssuerName  = "Baconrista",
                ProgramName = "Baconrista Rewards",
                ProgramLogo = new Image()
                {
                    SourceUri = new Uri()
                    {
                        UriValue = "http://farm8.staticflickr.com/7340/11177041185_a61a7f2139_o.jpg"
                    }
                },
                RewardsTierLabel            = "Tier",
                RewardsTier                 = "Gold",
                AccountNameLabel            = "Member Name",
                AccountIdLabel              = "Member Id",
                Messages                    = messages,
                ReviewStatus                = "underReview",
                AllowMultipleUsersPerObject = true,
                Locations                   = locations,
                ImageModulesData            = imageModulesData,
                InfoModuleData              = infoModuleData,
                TextModulesData             = textModulesData,
                LinksModuleData             = linksModuleData
            };

            return(wobClass);
        }
Beispiel #12
0
        /// <summary>
        /// Generates a signed "fat" JWT.
        /// No REST calls made.
        /// Use fat JWT in JS web button.
        /// Fat JWT is too long to be used in Android intents.
        /// Possibly might break in redirects.
        /// </summary>
        /// <param name="verticalType"> pass type to created</param>
        /// <param name="classId">the unique identifier for the class</param>
        /// <param name="objectId">the unique identifier for the object</param>
        /// <returns></returns>
        public string makeFatJwt(VerticalType verticalType, string classId, string objectId)
        {
            ResourceDefinitions resourceDefinitions = ResourceDefinitions.getInstance();
            RestMethods         restMethods         = RestMethods.getInstance();
            // create JWT to put objects and class into JSON Web Token (JWT) format for Google Pay API for Passes
            Jwt googlePassJwt = new Jwt();

            // get class definition, object definition and see if Ids exist. for a fat JWT, first time a user hits the save button, the class and object are inserted
            try
            {
                switch (verticalType)
                {
                case VerticalType.OFFER:
                    OfferClass  offerClass  = resourceDefinitions.makeOfferClassResource(classId);
                    OfferObject offerObject = resourceDefinitions.makeOfferObjectResource(objectId, classId);
                    System.Console.WriteLine("\nMaking REST call to get class and object to see if they exist.");
                    OfferClass  classResponse  = restMethods.getOfferClass(classId);
                    OfferObject objectResponse = restMethods.getOfferObject(objectId);
                    // check responses
                    if (!(classResponse is null))
                    {
                        System.Console.WriteLine($"classId: {classId} already exists.");
                    }
                    if (!(objectResponse is null))
                    {
                        System.Console.WriteLine($"objectId: {objectId} already exists.");
                    }
                    if (!(classResponse is null) && objectResponse.ClassId != offerObject.ClassId)
                    {
                        System.Console.WriteLine($"the classId of inserted object is ({objectResponse.ClassId}). " +
                                                 $"It does not match the target classId ({offerObject.ClassId}). The saved object will not " +
                                                 "have the class properties you expect.");
                    }
                    // need to add both class and object resource definitions into JWT because no REST calls made to pre-insert
                    googlePassJwt.addOfferClass(offerClass);
                    googlePassJwt.addOfferObject(offerObject);
                    break;

                case VerticalType.LOYALTY:
                    LoyaltyClass  loyaltyClass  = resourceDefinitions.makeLoyaltyClassResource(classId);
                    LoyaltyObject loyaltyObject = resourceDefinitions.makeLoyaltyObjectResource(objectId, classId);
                    System.Console.WriteLine("\nMaking REST call to get class and object to see if they exist.");
                    LoyaltyClass  loyaltyClassResponse  = restMethods.getLoyaltyClass(classId);
                    LoyaltyObject loyaltyObjectResponse = restMethods.getLoyaltyObject(objectId);
                    // check responses
                    if (!(loyaltyClassResponse is null))
                    {
                        System.Console.WriteLine($"classId: {classId} already exists.");
                    }
                    if (!(loyaltyObjectResponse is null))
                    {
                        System.Console.WriteLine($"objectId: {objectId} already exists.");
                    }
                    if (!(loyaltyClassResponse is null) && loyaltyObjectResponse.ClassId != loyaltyObject.ClassId)
                    {
                        System.Console.WriteLine($"the classId of inserted object is ({loyaltyObjectResponse.ClassId}). " +
                                                 $"It does not match the target classId ({loyaltyObject.ClassId}). The saved object will not " +
                                                 "have the class properties you expect.");
                    }
                    // need to add both class and object resource definitions into JWT because no REST calls made to pre-insert
                    googlePassJwt.addLoyaltyClass(loyaltyClass);
                    googlePassJwt.addLoyaltyObject(loyaltyObject);
                    break;

                case VerticalType.GIFTCARD:
                    GiftCardClass  giftCardClass  = resourceDefinitions.makeGiftCardClassResource(classId);
                    GiftCardObject giftCardObject = resourceDefinitions.makeGiftCardObjectResource(objectId, classId);
                    System.Console.WriteLine("\nMaking REST call to get class and object to see if they exist.");
                    GiftCardClass  giftCardClassResponse  = restMethods.getGiftCardClass(classId);
                    GiftCardObject giftCardObjectResponse = restMethods.getGiftCardObject(objectId);
                    // check responses
                    if (!(giftCardClassResponse is null))
                    {
                        System.Console.WriteLine($"classId: {classId} already exists.");
                    }
                    if (!(giftCardObjectResponse is null))
                    {
                        System.Console.WriteLine($"objectId: {objectId} already exists.");
                    }
                    if (!(giftCardClassResponse is null) && giftCardObjectResponse.ClassId != giftCardObject.ClassId)
                    {
                        System.Console.WriteLine($"the classId of inserted object is ({giftCardObjectResponse.ClassId}). " +
                                                 $"It does not match the target classId ({giftCardObject.ClassId}). The saved object will not " +
                                                 "have the class properties you expect.");
                    }
                    // need to add both class and object resource definitions into JWT because no REST calls made to pre-insert
                    googlePassJwt.addGiftCardClass(giftCardClass);
                    googlePassJwt.addGiftCardObject(giftCardObject);
                    break;
                }
                // return "fat" JWT. Try putting it into JS web button
                // note button needs to be rendered in local web server who's domain matches the ORIGINS
                // defined in the JWT. See https://developers.google.com/pay/passes/reference/s2w-reference
                return(googlePassJwt.generateSignedJwt());
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e.Message);
                return(null);
            }
        }
        /// <summary>
        /// Generates a Loyalty Class
        /// </summary>
        /// <param name="issuerId"> </param>
        /// <param name="classId"> </param>
        /// <returns> loyaltyClass </returns>
        public static LoyaltyClass generateLoyaltyClass(string issuerId, string classId)
        {
            // Define general messages
            IList<WalletObjectMessage> messages = new List<WalletObjectMessage>();
            WalletObjectMessage message = new WalletObjectMessage();
            message.Header = "Welcome";
            message.Body = "Welcome to Banconrista Rewards!";

            Uri imageUri = new Uri();
            imageUri.UriValue = "https://ssl.gstatic.com/codesite/ph/images/search-48.gif";
            Image messageImage = new Image();
            messageImage.SourceUri = imageUri;
            message.Image = messageImage;

            Uri actionUri = new Uri();
            actionUri.UriValue = "http://baconrista.com";
            message.ActionUri = actionUri;

            messages.Add(message);

            // Define rendering templates per view
            IList<RenderSpec> renderSpec = new List<RenderSpec>();

            RenderSpec listRenderSpec = new RenderSpec();
            listRenderSpec.ViewName = "g_list";
            listRenderSpec.TemplateFamily = "1.loyaltyCard1_list";

            RenderSpec expandedRenderSpec = new RenderSpec();
            expandedRenderSpec.ViewName = "g_expanded";
            expandedRenderSpec.TemplateFamily = "1.loyaltyCard1_expanded";

            renderSpec.Add(listRenderSpec);
            renderSpec.Add(expandedRenderSpec);

            // Define Geofence locations
            IList<LatLongPoint> locations = new List<LatLongPoint>();

            LatLongPoint llp1 = new LatLongPoint();
            llp1.Latitude = 37.422601;
            llp1.Longitude = -122.085286;

            LatLongPoint llp2 = new LatLongPoint();
            llp2.Latitude = 37.429379;
            llp2.Longitude = -122.122730;

            locations.Add(llp1);
            locations.Add(llp2);

            // Create class
            LoyaltyClass wobClass = new LoyaltyClass();
            wobClass.Id = issuerId + "." + classId;
            wobClass.Version = "1";
            wobClass.IssuerName = "Baconrista";
            wobClass.ProgramName = "Baconrista Rewards";

            Uri homepageUri = new Uri();
            homepageUri.UriValue = "https://www.example.com";
            homepageUri.Description = "Website";
            wobClass.HomepageUri = homepageUri;

            Uri logoImageUri = new Uri();
            logoImageUri.UriValue = "http://www.google.com/landing/chrome/ugc/chrome-icon.jpg";
            Image logoImage = new Image();
            logoImage.SourceUri = logoImageUri;
            wobClass.ProgramLogo = logoImage;

            wobClass.RewardsTierLabel= "Tier";
            wobClass.RewardsTier = "Gold";
            wobClass.AccountNameLabel = "Member Name";
            wobClass.AccountIdLabel = "Member Id";
            wobClass.RenderSpecs = renderSpec;
            wobClass.Messages = messages;
            wobClass.ReviewStatus = "underReview";
            wobClass.AllowMultipleUsersPerObject = true;
            wobClass.Locations = locations;

            return wobClass;
        }