def makeSkinnyJwt(verticalType, classId, objectId, Globalname, Globalmrn, Globaldate, Globaldoctor, Globalhospital, Globalhospitalphone, Globalhospitaladdress, Globallocation, Globalservice): signedJwt = None classResourcePayload = None objectResourcePayload = None classResponse = None objectResponse = None try: # get class definition and object definition classResourcePayload, objectResourcePayload = getClassAndObjectDefinitions( verticalType, classId, objectId, classResourcePayload, objectResourcePayload, Globalname, Globalmrn, Globaldate, Globaldoctor, Globalhospital, Globalhospitalphone, Globalhospitaladdress, Globallocation, Globalservice) print('\nMaking REST call to insert class: (%s)' % (classId)) # make authorized REST call to explicitly insert class into Google server. # if this is successful, you can check/update class definitions in Merchant Center GUI: https://pay.google.com/gp/m/issuer/list classResponse = restMethods.insertClass(verticalType, classResourcePayload) print('\nMaking REST call to insert object') # make authorized REST call to explicitly insert object into Google server. objectResponse = restMethods.insertObject(verticalType, objectResourcePayload) # continue based on insert response status. Check https://developers.google.com/pay/passes/reference/v1/statuscodes # check class insert response. Will print out if class insert succeeds or not. Throws error if class resource is malformed. handleInsertCallStatusCode(classResponse, "class", classId, None, None) # check object insert response. Will print out if object insert succeeds or not. Throws error if object resource is malformed, or if existing objectId's classId does not match the expected classId handleInsertCallStatusCode(objectResponse, "object", objectId, classId, verticalType) # put into JSON Web Token (JWT) format for Google Pay API for Passes googlePassJwt = jwt.googlePassJwt() # only need to add objectId in JWT because class and object definitions were pre-inserted via REST call loadObjectIntoJWT(verticalType, googlePassJwt, {"id": objectId}) # sign JSON to make signed JWT signedJwt = googlePassJwt.generateSignedJwt() except ValueError as err: print(err.args) # return "skinny" JWT. Try putting it into save link. # See https://developers.google.com/pay/passes/guides/get-started/implementing-the-api/save-to-google-pay#add-link-to-email return signedJwt
def test_insertEventTicketObjectAndClass(self): classResourcePayload = None objectResourcePayload = None classResponse = None objectResponse = None classUid = str( services.VerticalType.EVENTTICKET).split('.')[1] + '_CLASS_' + str( uuid.uuid4()) classId = '%s.%s' % (config.ISSUER_ID, classUid) objectUid = str(services.VerticalType.EVENTTICKET).split( '.')[1] + '_OBJECT_' + str(uuid.uuid4()) objectId = '%s.%s' % (config.ISSUER_ID, objectUid) classResourcePayload, objectResourcePayload = services.getClassAndObjectDefinitions( services.VerticalType.EVENTTICKET, classId, objectId, classResourcePayload, objectResourcePayload) classResponse = restMethods.insertClass( services.VerticalType.EVENTTICKET, classResourcePayload) objectResponse = restMethods.insertObject( services.VerticalType.EVENTTICKET, objectResourcePayload) self.assertEqual(objectResponse.status_code, 200) self.assertEqual(classResponse.status_code, 200)