/// <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."); }