Class: SpreeCmCommissioner::GoogleWallets::HotelObjectBuilder

Inherits:
BaseGenericObjectBuilder show all
Defined in:
app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb

Instance Attribute Summary

Attributes inherited from BaseGenericObjectBuilder

#line_item

Instance Method Summary collapse

Methods inherited from BaseGenericObjectBuilder

#credentials, #initialize, #iss, #issuer_id, #object_token, #signing_key

Constructor Details

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

Instance Method Details

#check_in_dateObject



91
92
93
# File 'app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb', line 91

def check_in_date
  line_item.from_date
end

#check_out_dateObject



95
96
97
# File 'app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb', line 95

def check_out_date
  line_item.to_date
end

#hotel_addressObject



87
88
89
# File 'app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb', line 87

def hotel_address
  line_item.address
end

#hotel_class_idObject



71
72
73
# File 'app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb', line 71

def hotel_class_id
  "#{issuer_id}.#{line_item.google_wallet.class_id}"
end

#hotel_holder_nameObject



75
76
77
# File 'app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb', line 75

def hotel_holder_name
  line_item.order.customer_address.full_name
end

#hotel_idObject



67
68
69
# File 'app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb', line 67

def hotel_id
  "#{issuer_id}.#{line_item.id}"
end

#hotel_line_item_numberObject



83
84
85
# File 'app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb', line 83

def hotel_line_item_number
  line_item.number
end

#hotel_nameObject



79
80
81
# File 'app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb', line 79

def hotel_name
  line_item.name
end

#objectObject

override



5
6
7
8
9
10
11
12
13
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
57
58
59
60
61
62
63
64
65
# File 'app/services/spree_cm_commissioner/google_wallets/hotel_object_builder.rb', line 5

def object
  {
    iss: iss,
    aud: 'google',
    typ: 'savetowallet',
    payload: {
      genericObjects: [
        {
          id: hotel_id,
          classId: hotel_class_id,
          cardTitle: {
            defaultValue: {
              language: 'en-US',
              value: hotel_name
            }
          },
          subheader: {
            defaultValue: {
              language: 'en-US',
              value: hotel_line_item_number
            }
          },
          header: {
            defaultValue: {
              language: 'en-US',
              value: hotel_holder_name
            }
          },
          textModulesData: [
            {
              id: 'from_date',
              header: 'From Date',
              body: check_in_date
            },
            {
              id: 'to_date',
              header: 'To Date',
              body: check_out_date
            }
          ],
          barcode: {
            type: 'QR_CODE',
            value: line_item.qr_data,
            alternateText: 'QR Code'
          },
          logo: {
            sourceUri: {
              uri: line_item.vendor..original_url
            }
          },
          heroImage: {
            sourceUri: {
              uri: line_item.variant.images.first.original_url
            }
          },
          hexBackgroundColor: '#FFFFFF'
        }
      ]
    }
  }
end