I would like to update the data of the Google Pay for passes.
Before updating, I've uploaded the sample pass with using sample code provided by Google.
And now, I am trying this https://developers.google.com/pay/passes/rest.
However, I don't have idea how to update the edited-code with command PUT https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resourceId}
on Mac Terminal.
I tried to send following commands.
curl https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resorceID} -XPOST
curl -X PUT 'https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resorceID}'
But it returns
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
Please let me teach.
If you look at the rest methods you will see how to make the calls using python:
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=UTF-8'
}
credentials = makeOauthCredential()
response = None
# Define insert() REST call of target vertical
uri = 'https://walletobjects.googleapis.com/walletobjects/v1'
postfix = 'Class'
path = createPath(verticalType, postfix)
# There is no Google API for Passes Client Library for Python.
# Authorize a http client with credential generated from Google API client library.
## see https://google-auth.readthedocs.io/en/latest/user-guide.html#making-authenticated-requests
authed_session = AuthorizedSession(credentials)
# make the POST request to make an insert(); this returns a response object
# other methods require different http methods; for example, get() requires authed_Session.get(...)
# check the reference API to make the right REST call
## https://developers.google.com/pay/passes/reference/v1/
## https://google-auth.readthedocs.io/en/latest/user-guide.html#making-authenticated-requests
response = authed_session.post(
uri+path # REST API endpoint
,headers=headers # Header; optional
,json=payload # non-form-encoded Payload for POST. Check rest API for format based on method.
)
return response
Note there are special authorization headers for the call so just using curl may not be best but there is a [tool] (https://developers.google.com/pay/passes/support/testing) to generate authorization token for curl to work.
If you are inserting a class this url will be POST https://walletobjects.googleapis.com/walletobjects/v1/offerClass
If you are updating a class. it would be PUT https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resourceId}