Class: SpreeCmCommissioner::GoogleWallets::EventTicketObjectBuilder

Inherits:
BaseObjectBuilder
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/google_wallets/event_ticket_object_builder.rb

Instance Attribute Summary

Attributes inherited from BaseObjectBuilder

#line_item

Instance Method Summary collapse

Methods inherited from BaseObjectBuilder

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

Constructor Details

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

Instance Method Details

#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
# File 'app/services/spree_cm_commissioner/google_wallets/event_ticket_object_builder.rb', line 5

def object
  {
    iss: iss,
    aud: 'google',
    typ: 'savetowallet',
    payload: {
      eventTicketObjects: [
        {
          id: ticket_id,
          classId: ticket_class_id,
          ticketHolderName: ticket_holder_name,
          ticketNumber: ticket_number,
          ticketType: {
            defaultValue: {
              language: 'en-US',
              value: ticket_name
            }
          },
          state: 'ACTIVE',
          barcode: {
            type: 'QR_CODE',
            value: line_item.qr_data,
            alternateText: 'QR Code'
          },
          linksModuleData: {
            uris: [
              {
                uri: ticket_detail_url,
                description: 'Visit Ticket Detail'
              }
            ]
          },
          textModulesData: [
            {
              header: 'Ticket Quantities',
              body: line_item.quantity
            },
            {
              header: 'Option Texts',
              body: line_item.options_text
            }
          ]
        }
      ]
    }
  }
end

#ticket_class_idObject



65
66
67
# File 'app/services/spree_cm_commissioner/google_wallets/event_ticket_object_builder.rb', line 65

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

#ticket_detail_urlObject



73
74
75
# File 'app/services/spree_cm_commissioner/google_wallets/event_ticket_object_builder.rb', line 73

def ticket_detail_url
  "https://#{Spree::Store.default.url}/bookings/#{line_item.order.number}/tickets/#{line_item.id}"
end

#ticket_holder_nameObject



69
70
71
# File 'app/services/spree_cm_commissioner/google_wallets/event_ticket_object_builder.rb', line 69

def ticket_holder_name
  line_item.order.customer_address.full_name
end

#ticket_idObject



61
62
63
# File 'app/services/spree_cm_commissioner/google_wallets/event_ticket_object_builder.rb', line 61

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

#ticket_nameObject



53
54
55
# File 'app/services/spree_cm_commissioner/google_wallets/event_ticket_object_builder.rb', line 53

def ticket_name
  line_item.name
end

#ticket_numberObject



57
58
59
# File 'app/services/spree_cm_commissioner/google_wallets/event_ticket_object_builder.rb', line 57

def ticket_number
  line_item.number
end