Exemple #1
0
 private void DestroyBasic()
 {
     try
     {
         MAdapter          = null !;
         TxtSave           = null !;
         IconDiscountType  = null !;
         TxtDiscountType   = null !;
         MRecycler         = null !;
         IconDiscountItems = null !;
         TxtDiscountItems  = null !;
         IconCurrency      = null !;
         TxtCurrency       = null !;
         IconDescription   = null !;
         TxtDescription    = null !;
         IconDate          = null !;
         TxtDate           = null !;
         IconTime          = null !;
         TxtTime           = null !;
         OfferClass        = null !;
         TypeDialog        = null !;
         CurrencyId        = null !;
         OfferId           = null !;
         AddDiscountId     = null !;
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
        /// <summary>
        /// Generate an offer object
        /// See https://developers.google.com/pay/passes/reference/v1/offerobject
        /// </summary>
        /// <param name="objectId"> the unique identifier for a object</param>
        /// <returns>the inserted offer object</returns>
        public OfferObject makeOfferObjectResource(string objectId, string classId)
        {
            // Define the resource representation of the Object
            // values should be from your DB/services; here we hardcode information
            // below defines an offer object. For more properties, check:
            //// https://developers.google.com/pay/passes/reference/v1/offerobject/insert
            //// https://developers.google.com/pay/passes/guides/pass-verticals/offers/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
            OfferObject payload = new OfferObject();

            //required fields
            payload.Id      = objectId;
            payload.ClassId = classId;
            payload.State   = "active";
            //optional fields. See design and reference api for more
            payload.Barcode = new Barcode()
            {
                Type          = "qrCode",
                Value         = "1234abc",
                AlternateText = "1234abc"
            };
            return(payload);
        }
Exemple #3
0
        /// <summary>
        /// Get with Google Pay API for Passes REST API
        /// See https://developers.google.com/pay/passes/reference/v1/offerobject/get
        /// </summary>
        /// <param name="id">id of the object</param>
        /// <returns>object</returns>
        public OfferObject getOfferObject(string id)
        {
            OfferObject response = null;
            // Uses the Google Pay API for Passes C# client lib to get a Offer object
            // 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/offerobject/get
            WalletobjectsService service = new WalletobjectsService(new Google.Apis.Services.BaseClientService.Initializer()
            {
                HttpClientInitializer = this.credential
            });

            try
            {
                response = service.Offerobject.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);
        }
Exemple #4
0
 private void DestroyBasic()
 {
     try
     {
         MAdapter          = null;
         TxtSave           = null;
         IconDiscountType  = null;
         TxtDiscountType   = null;
         MRecycler         = null;
         IconDiscountItems = null;
         TxtDiscountItems  = null;
         IconCurrency      = null;
         TxtCurrency       = null;
         IconDescription   = null;
         TxtDescription    = null;
         IconDate          = null;
         TxtDate           = null;
         IconTime          = null;
         TxtTime           = null;
         OfferClass        = null;
         TypeDialog        = null;
         CurrencyId        = null;
         OfferId           = null;
         AddDiscountId     = null;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemple #5
0
 public void addOfferObject(OfferObject offerObject)
 {
     if (this.payload.offerObjects == null)
     {
         this.payload.offerObjects = new List <OfferObject>();
     }
     this.payload.offerObjects.Add(offerObject);
 }
        public virtual void ProcessRequest(HttpContext context)
        {
            try {
                HttpRequest request = context.Request;

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

                string loyaltyClassId   = WebConfigurationManager.AppSettings["LoyaltyClassId"];
                string loyaltyObjectId  = WebConfigurationManager.AppSettings["LoyaltyObjectId"];
                string offerClassId     = WebConfigurationManager.AppSettings["OfferClassId"];
                string offerObjectId    = WebConfigurationManager.AppSettings["OfferObjectId"];
                string giftCardClassId  = WebConfigurationManager.AppSettings["GiftCardClassId"];
                string giftCardObjectId = WebConfigurationManager.AppSettings["GiftCardObjectId"];

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

                WobUtils utils = new WobUtils(credentials.serviceAccountId, certificate);

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

                if (type.Equals("loyalty"))
                {
                    LoyaltyObject loyaltyObject = Loyalty.generateLoyaltyObject(credentials.IssuerId, loyaltyClassId, loyaltyObjectId);
                    utils.addObject(loyaltyObject);
                }
                else if (type.Equals("offer"))
                {
                    OfferObject offerObject = Offer.generateOfferObject(credentials.IssuerId, offerClassId, offerObjectId);
                    utils.addObject(offerObject);
                }
                else if (type.Equals("giftcard"))
                {
                    GiftCardObject giftCardObject = GiftCard.generateGiftCardObject(credentials.IssuerId, giftCardClassId, giftCardObjectId);
                    utils.addObject(giftCardObject);
                }

                // generate the JWT
                string jwt = utils.GenerateJwt();

                HttpResponse response = context.Response;
                response.Write(jwt);
                //response.ContentType = "text/xml";
            }
            catch (Exception e) {
                Console.Write(e.StackTrace);
            }
        }
Exemple #7
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 TestInsertOfferClassAndObject()
        {
            RestMethods         restMethods         = RestMethods.getInstance();
            ResourceDefinitions resourceDefinitions = ResourceDefinitions.getInstance();
            VerticalType        verticalType        = Services.VerticalType.OFFER;
            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}";
            OfferClass  classResponse  = restMethods.insertOfferClass(resourceDefinitions.makeOfferClassResource(classId));
            OfferObject objectResponse = restMethods.insertOfferObject(resourceDefinitions.makeOfferObjectResource(objectId, classId));

            Assert.NotNull(classResponse);
            Assert.NotNull(objectResponse);
        }
    public static OfferObject generateOfferObject(string issuerId, string classId, string objectId)
    {
      Barcode barcode = new Barcode() {
        Type = "upcA",
        Value = "123456789012",
        AlternateText = "12345",
        Label = "Offer Code"
      };

      // Define Wallet Object
      OfferObject offerObj = new OfferObject() {
        ClassId = issuerId + "." + classId,
        Id = issuerId + "." + objectId,
        Version = 1,
        Barcode = barcode,
        State = "active"
      };

      return offerObj;
    }
Exemple #10
0
        public static OfferObject generateOfferObject(string issuerId, string classId, string objectId)
        {
            Barcode barcode = new Barcode()
            {
                Type          = "upcA",
                Value         = "123456789012",
                AlternateText = "12345",
                Label         = "Offer Code"
            };

            // Define Wallet Object
            OfferObject offerObj = new OfferObject()
            {
                ClassId = issuerId + "." + classId,
                Id      = issuerId + "." + objectId,
                Version = 1,
                Barcode = barcode,
                State   = "active"
            };

            return(offerObj);
        }
Exemple #11
0
        private async void TxtSaveOnClick(object sender, EventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    if (string.IsNullOrEmpty(TxtDiscountType.Text) || string.IsNullOrEmpty(TxtDiscountItems.Text) || string.IsNullOrEmpty(TxtCurrency.Text) ||
                        string.IsNullOrEmpty(TxtDescription.Text))
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_your_data), ToastLength.Short).Show();
                        return;
                    }

                    //Show a progress
                    AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading));

                    OfferObject newInfoObject = new OfferObject()
                    {
                        Id              = OfferId,
                        DiscountType    = AddDiscountId,
                        Currency        = CurrencyId,
                        ExpireDate      = TxtDate.Text,
                        Time            = TxtTime.Text,
                        Description     = TxtDescription.Text,
                        DiscountedItems = TxtDiscountItems.Text,
                    };

                    var dictionary = new Dictionary <string, string>
                    {
                        { "discount_type", AddDiscountId },
                        { "currency", CurrencyId },
                        { "offer_id", OfferId },
                        { "expire_date", TxtDate.Text },
                        { "expire_time", TxtTime.Text },
                        { "description", TxtDescription.Text },
                        { "discounted_items", TxtDiscountItems.Text },
                    };

                    if (MAdapter.DiscountList.Count > 0)
                    {
                        foreach (var discount in MAdapter.DiscountList)
                        {
                            if (discount == null)
                            {
                                continue;
                            }
                            switch (discount.DiscountType)
                            {
                            case "discount_percent":
                                dictionary.Add("discount_percent", discount.DiscountFirst);

                                newInfoObject.DiscountPercent = discount.DiscountFirst;
                                break;

                            case "discount_amount":
                                dictionary.Add("discount_amount", discount.DiscountFirst);

                                newInfoObject.DiscountAmount = discount.DiscountFirst;
                                break;

                            case "buy_get_discount":
                                dictionary.Add("discount_percent", discount.DiscountFirst);
                                dictionary.Add("buy", discount.DiscountSec);
                                dictionary.Add("get", discount.DiscountThr);

                                newInfoObject.DiscountPercent = discount.DiscountFirst;
                                newInfoObject.Buy             = discount.DiscountSec;
                                newInfoObject.GetPrice        = discount.DiscountThr;
                                break;

                            case "spend_get_off":
                                dictionary.Add("spend", discount.DiscountSec);
                                dictionary.Add("amount_off", discount.DiscountThr);

                                newInfoObject.Spend     = discount.DiscountSec;
                                newInfoObject.AmountOff = discount.DiscountThr;
                                break;

                            case "free_shipping":     //Not have tag
                                break;
                            }
                        }
                    }

                    var(apiStatus, respond) = await RequestsAsync.Offers.EditOffer(dictionary);

                    if (apiStatus == 200)
                    {
                        if (respond is MessageOfferObject result)
                        {
                            Console.WriteLine(result.MessageData);
                            Toast.MakeText(this, GetString(Resource.String.Lbl_OfferSuccessfullyAdded), ToastLength.Short).Show();

                            AndHUD.Shared.Dismiss(this);

                            var data = OffersActivity.GetInstance()?.MAdapter?.OffersList?.FirstOrDefault(a => a.Id == newInfoObject.Id);
                            if (data != null)
                            {
                                data.DiscountType    = AddDiscountId;
                                data.Currency        = CurrencyId;
                                data.ExpireDate      = TxtDate.Text;
                                data.Time            = TxtTime.Text;
                                data.Description     = TxtDescription.Text;
                                data.DiscountedItems = TxtDiscountItems.Text;
                                data.Description     = TxtDescription.Text;
                                data.DiscountPercent = newInfoObject.DiscountPercent;
                                data.DiscountAmount  = newInfoObject.DiscountAmount;
                                data.DiscountPercent = newInfoObject.DiscountPercent;
                                data.Buy             = newInfoObject.Buy;
                                data.GetPrice        = newInfoObject.GetPrice;
                                data.Spend           = newInfoObject.Spend;
                                data.AmountOff       = newInfoObject.AmountOff;

                                OffersActivity.GetInstance().MAdapter.NotifyItemChanged(OffersActivity.GetInstance().MAdapter.OffersList.IndexOf(data));
                            }

                            Intent intent = new Intent();
                            intent.PutExtra("OffersItem", JsonConvert.SerializeObject(newInfoObject));
                            SetResult(Result.Ok, intent);
                            Finish();
                        }
                    }
                    else
                    {
                        Methods.DisplayAndHUDErrorResult(this, respond);
                    }
                }
                else
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                AndHUD.Shared.Dismiss(this);
            }
        }
 public void addObject(OfferObject obj)
 {
     offerObjects.Add(obj);
 }
Exemple #13
0
 /// <summary>Updates the offer object referenced by the given object ID.</summary>
 /// <param name="body">The body of the request.</param>
 /// <param name="resourceId">The unique identifier for an object. This ID must be unique across all objects 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(OfferObject body, string resourceId)
 {
     return(new UpdateRequest(service, body, resourceId));
 }
Exemple #14
0
 /// <summary>Updates the offer object referenced by the given object ID. This method supports patch
 /// semantics.</summary>
 /// <param name="body">The body of the request.</param>
 /// <param name="resourceId">The unique identifier for an object. This ID must be unique across all objects 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(OfferObject body, string resourceId)
 {
     return(new PatchRequest(service, body, resourceId));
 }
Exemple #15
0
 /// <summary>Inserts an offer object with the given ID and properties.</summary>
 /// <param name="body">The body of the request.</param>
 public virtual InsertRequest Insert(OfferObject body)
 {
     return(new InsertRequest(service, body));
 }
        public static OfferObject generateOfferObject(string issuerId, string classId, string objectId)
        {
            Barcode barcode = new Barcode();
              barcode.Type = "upcA";
              barcode.Value ="123456789012";
              barcode.AlternateText = "12345";
              barcode.Label = "User Id";

              // Define Wallet Object
              OfferObject offobj = new OfferObject();
              offobj.ClassId = issuerId + "." + classId;
              offobj.Id = issuerId + "." + objectId;
              offobj.Version = "1";
              offobj.Barcode = barcode;
              offobj.State = "active";

              return offobj;
        }
Exemple #17
0
 public void addObject(OfferObject obj)
 {
     offerObjects.Add(obj);
 }
Exemple #18
0
        private void Get_DataOffer()
        {
            try
            {
                OfferClass = JsonConvert.DeserializeObject <OfferObject>(Intent.GetStringExtra("OfferItem"));
                if (OfferClass != null)
                {
                    AddDiscountId = OfferClass.DiscountType;
                    switch (OfferClass.DiscountType)
                    {
                    case "discount_percent":
                    {
                        TxtDiscountType.Text = GetString(Resource.String.Lbl_DiscountPercent);
                        MRecycler.Visibility = ViewStates.Visible;
                        MAdapter.DiscountList.Clear();

                        MAdapter.DiscountList.Add(new DiscountOffers()
                            {
                                DiscountType  = OfferClass.DiscountType,
                                DiscountFirst = OfferClass.DiscountPercent,
                                DiscountSec   = "",
                                DiscountThr   = "",
                            });
                        MAdapter.NotifyDataSetChanged();
                    } break;

                    case "discount_amount":
                    {
                        TxtDiscountType.Text = GetString(Resource.String.Lbl_DiscountAmount);

                        MRecycler.Visibility = ViewStates.Visible;
                        MAdapter.DiscountList.Clear();

                        MAdapter.DiscountList.Add(new DiscountOffers()
                            {
                                DiscountType  = OfferClass.DiscountType,
                                DiscountFirst = OfferClass.DiscountAmount,
                                DiscountSec   = "",
                                DiscountThr   = "",
                            });
                        MAdapter.NotifyDataSetChanged();
                    } break;

                    case "buy_get_discount":
                    {
                        TxtDiscountType.Text = GetString(Resource.String.Lbl_BuyGetDiscount);

                        MRecycler.Visibility = ViewStates.Visible;
                        MAdapter.DiscountList.Clear();

                        MAdapter.DiscountList.Add(new DiscountOffers()
                            {
                                DiscountType  = OfferClass.DiscountType,
                                DiscountFirst = OfferClass.DiscountPercent,
                                DiscountSec   = OfferClass.Buy,
                                DiscountThr   = OfferClass.GetPrice,
                            });
                        MAdapter.NotifyDataSetChanged();
                    } break;

                    case "spend_get_off":
                    {
                        TxtDiscountType.Text = GetString(Resource.String.Lbl_SpendGetOff);

                        MRecycler.Visibility = ViewStates.Visible;
                        MAdapter.DiscountList.Clear();

                        MAdapter.DiscountList.Add(new DiscountOffers()
                            {
                                DiscountType  = OfferClass.DiscountType,
                                DiscountFirst = "",
                                DiscountSec   = OfferClass.Spend,
                                DiscountThr   = OfferClass.AmountOff,
                            });
                        MAdapter.NotifyDataSetChanged();
                    } break;

                    case "free_shipping":     //Not have tag
                    {
                        TxtDiscountType.Text = GetString(Resource.String.Lbl_FreeShipping);

                        MRecycler.Visibility = ViewStates.Gone;
                        MAdapter.DiscountList.Clear();
                        MAdapter.NotifyDataSetChanged();
                    } break;
                    }

                    TxtDiscountItems.Text = Methods.FunString.DecodeString(OfferClass.DiscountedItems);
                    TxtCurrency.Text      = OfferClass.Currency;
                    TxtDate.Text          = OfferClass.ExpireDate;
                    TxtTime.Text          = OfferClass.ExpireTime;
                    TxtDescription.Text   = Methods.FunString.DecodeString(OfferClass.Description);

                    CurrencyId = OfferClass.Currency;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #19
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);
            }
        }