Class: SpreeCmCommissioner::GoogleWallets::BaseGenericClass
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::GoogleWallets::BaseGenericClass
- Defined in:
- app/services/spree_cm_commissioner/google_wallets/base_generic_class.rb
Direct Known Subclasses
Constant Summary collapse
- GOOGLE_API_ENDPOINT =
'https://walletobjects.googleapis.com/walletobjects/v1/genericClass'.freeze
- GOOGLE_OAUTH_SCOPE =
'https://www.googleapis.com/auth/wallet_object.issuer'.freeze
Instance Method Summary collapse
- #access_token ⇒ Object
-
#build_request_body ⇒ Object
This method is to be overrided in subclasses.
- #credentials ⇒ Object
-
#initialize(google_wallet_class) ⇒ BaseGenericClass
constructor
A new instance of BaseGenericClass.
Constructor Details
#initialize(google_wallet_class) ⇒ BaseGenericClass
Returns a new instance of BaseGenericClass.
9 10 11 |
# File 'app/services/spree_cm_commissioner/google_wallets/base_generic_class.rb', line 9 def initialize(google_wallet_class) @google_wallet_class = google_wallet_class end |
Instance Method Details
#access_token ⇒ Object
62 63 64 65 66 67 68 |
# File 'app/services/spree_cm_commissioner/google_wallets/base_generic_class.rb', line 62 def access_token = Google::Auth::ServiceAccountCredentials.make_creds( json_key_io: StringIO.new(credentials.to_json), scope: GOOGLE_OAUTH_SCOPE ) .fetch_access_token!['access_token'] end |
#build_request_body ⇒ Object
This method is to be overrided in subclasses
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/services/spree_cm_commissioner/google_wallets/base_generic_class.rb', line 14 def build_request_body raise NotImplementedError, 'build_request_body must be implemented in subclasses' ## Reference: https://developers.google.com/wallet/reference/rest/v1/genericclass ## Example of what the body should look like # { # id: string, # imageModulesData: [ # { # mainImage: { # sourceUri: { # uri: 'https://storage.googleapis.com/wallet-lab-tools-codelab-artifacts-public/google-io-2021-card.png' # }, # contentDescription: { # defaultValue: { # language: 'en-US', # value: 'Google I/O 2022 Banner' # } # } # }, # id: 'event_banner' # } # ], # textModulesData: [ # { # header: 'Gather points meeting new people at Google I/O', # body: 'Join the game and accumulate points in this badge by meeting other attendees in the event.', # id: 'game_overview' # } # ], # linksModuleData: { # uris: [ # { # uri: 'https://io.google/2022/', # description: 'Official I/O \'22 Site', # id: 'official_site' # } # ] # } # } end |
#credentials ⇒ Object
58 59 60 |
# File 'app/services/spree_cm_commissioner/google_wallets/base_generic_class.rb', line 58 def credentials Rails.application.credentials.google_wallet_service_account end |