Как обновить Google Pay For Passes - PullRequest
0 голосов
/ 11 марта 2020

Я хотел бы обновить данные Google Pay для пропусков. Перед обновлением я загрузил пример с использованием образца кода, предоставленного Google. А сейчас я пытаюсь это https://developers.google.com/pay/passes/rest. Однако я не знаю, как обновить отредактированный код с помощью команды PUT https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resourceId} на терминале Ma c. Я пытался отправить следующие команды.

 curl https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resorceID} -XPOST

 curl -X PUT 'https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resorceID}'

Но он возвращает

<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}

Пожалуйста, дайте мне учить.

1 Ответ

0 голосов
/ 17 марта 2020

Если вы посмотрите на методы отдыха , вы увидите, как совершать вызовы, используя 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

Обратите внимание, что для вызова есть специальные заголовки авторизации, поэтому просто используйте curl может быть не лучшим, но есть [инструмент] (https://developers.google.com/pay/passes/support/testing) для генерации токена авторизации для работы curl.

Если вы вставляете класс, этот URL будет POST https://walletobjects.googleapis.com/walletobjects/v1/offerClass

Если вы обновляете класс. это было бы PUT https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resourceId}

...