google pay for passes OfferObject()

import os

from google.auth.transport.requests import AuthorizedSession
from google.oauth2 import service_account

# Path to service account key file obtained from Google CLoud Console
import service

service_account_file = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", "***")

# Issuer ID obtained from Google Pay Business Console.
# Developer defined ID for the wallet class.
issuer_id = "***"
class_id = "test"
resourceId = issuer_id + '.' + class_id

# [START auth]
credentials = service_account.Credentials.from_service_account_file(service_account_file, scopes=[
    "https://www.googleapis.com/auth/wallet_object.issuer"])
http_client = AuthorizedSession(credentials)
# [END auth]

# Get the specific Offer Object
offer_object = service.offerobject().get(resourceId=resourceId)
# Update the version, validTimeInterval.end, and add a message
offer_object['version'] = str(int(offer_object['version']) + 1)
offer_object['validTimeInterval'] = {
    'start': {'date': ''},
    'end': {'date': ''}
}

# Get the current messages
messages = offer_object['messages']

# Define new message
message = {
    'header': 'Test notification',
    'body': 'Your offer has been extended!',
    'kind': 'walletobjects#walletObjectMessage'
}

# Add the new message about updates to the Offer Object
messages.append(message)
offer_object['messages'] = messages

# Update the Offer Object
api_request = service.offerobject().update(resourceId=resourceId, body=offer_object)
api_response = api_request.execute()

Я создал карту лояльности с помощью passes-rest-simple. В Google Wallet API она отображается, но я не могу ее обновить, service надо импортировать, я не понимаю откуда?

offer_object = service.offerobject().get(resourceId=resourceId)
NameError: name 'service' is not defined

Ответы (0 шт):