Class: SpreeCmCommissioner::GoogleWallets::BaseHotelClass

Inherits:
BaseGenericClass show all
Defined in:
app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb

Direct Known Subclasses

HotelClassCreator, HotelClassUpdater

Constant Summary

Constants inherited from BaseGenericClass

SpreeCmCommissioner::GoogleWallets::BaseGenericClass::GOOGLE_API_ENDPOINT, SpreeCmCommissioner::GoogleWallets::BaseGenericClass::GOOGLE_OAUTH_SCOPE

Instance Method Summary collapse

Methods inherited from BaseGenericClass

#access_token, #credentials, #initialize

Constructor Details

This class inherits a constructor from SpreeCmCommissioner::GoogleWallets::BaseGenericClass

Instance Method Details

#background_color ⇒ Object



34
35
36
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 34

def background_color
  @google_wallet_class.preferred_background_color
end

#build_request_body ⇒ Object

override



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 47

def build_request_body
  {
    id: class_id,
    issuerId: issuer_id,
    imageModulesData: [
      {
        mainImage: {
          sourceUri: {
            id: 'logo',
            uri: 
          }
        }
      }
    ],
    textModulesData: [
      {
        header: 'Hotel Name',
        body: hotel_name
      },
      {
        header: 'Hotel Address',
        body: hotel_address
      },
      {
        header: 'Background Color',
        body: background_color
      }
    ]
  }.to_json
end

#call ⇒ Object



4
5
6
7
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 4

def call
  response = send_request
  { status: response.code }
end

#class_id ⇒ Object



18
19
20
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 18

def class_id
  "#{issuer_id}.#{@google_wallet_class.class_id}"
end

#hero_image ⇒ Object



42
43
44
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 42

def hero_image
  rails_blob_url(@google_wallet_class.hero_image)
end

#hotel_address ⇒ Object



30
31
32
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 30

def hotel_address
  @google_wallet_class.preferred_hotel_address
end

#hotel_name ⇒ Object



26
27
28
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 26

def hotel_name
  @google_wallet_class.preferred_hotel_name
end

#issuer_id ⇒ Object



14
15
16
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 14

def issuer_id
  ENV.fetch('ISSUER_ID', nil)
end

#issuer_name ⇒ Object



22
23
24
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 22

def issuer_name
  @google_wallet_class.preferred_issuer_name
end

#logo ⇒ Object



38
39
40
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 38

def 
  rails_blob_url(@google_wallet_class.)
end

#send_request ⇒ Object

This method is to be overrided in subclasses

Raises:



10
11
12
# File 'app/services/spree_cm_commissioner/google_wallets/base_hotel_class.rb', line 10

def send_request
  raise NotImplementedError, 'send_request must be implemented in subclasses'
end