Class: GoogleWallet::Resources::EventTicket::Object

Inherits:
Base
  • Object
show all
Defined in:
lib/google_wallet/resources/event_ticket/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes

Constructor Details

#initialize(attributes: {}, options: {}) ⇒ Object

attributes =

object_identifier: 'fd9b637f-0381-42ad-9161-b4d887d79d9f',
class_identifier: 'Event-1234',
grouping_id: 'order-12345',
ticket_type: 'Vip Pass + Priority24',
section: 'The Sponsor Felt-F Overpower',
seat: '65',
row: '17',
gate: 'G3, G4',
ticket_holder_name: 'Yaro Developer',
qr_code_value: '12345678',
ref_number: 'cdeqw',
valid_time_start: '2023-09-27T22:30',
valid_time_end: '2023-09-28T02:00',
micros: 82_000_000,
currency_code: 'NOK',
hex_background_color: '#45ffaa'



33
34
35
36
37
38
39
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 33

def initialize(attributes: {}, options: {})
  super

  validate_fields( %w[object_identifier class_identifier])
  @id = "#{GoogleWallet.configuration.issuer_id}.#{@object_identifier}"
  @class_id = "#{GoogleWallet.configuration.issuer_id}.#{@class_identifier}"
end

Instance Attribute Details

#class_idObject (readonly)

Returns the value of attribute class_id.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def class_id
  @class_id
end

#class_identifierObject (readonly)

Returns the value of attribute class_identifier.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def class_identifier
  @class_identifier
end

#currency_codeObject (readonly)

Returns the value of attribute currency_code.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def currency_code
  @currency_code
end

#gateObject (readonly)

Returns the value of attribute gate.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def gate
  @gate
end

#grouping_idObject (readonly)

Returns the value of attribute grouping_id.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def grouping_id
  @grouping_id
end

#hex_background_colorObject (readonly)

Returns the value of attribute hex_background_color.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def hex_background_color
  @hex_background_color
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def id
  @id
end

#microsObject (readonly)

Returns the value of attribute micros.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def micros
  @micros
end

#object_identifierObject (readonly)

Returns the value of attribute object_identifier.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def object_identifier
  @object_identifier
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def options
  @options
end

#qr_code_valueObject (readonly)

Returns the value of attribute qr_code_value.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def qr_code_value
  @qr_code_value
end

#rowObject (readonly)

Returns the value of attribute row.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def row
  @row
end

#seatObject (readonly)

Returns the value of attribute seat.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def seat
  @seat
end

#sectionObject (readonly)

Returns the value of attribute section.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def section
  @section
end

#ticket_holder_nameObject (readonly)

Returns the value of attribute ticket_holder_name.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def ticket_holder_name
  @ticket_holder_name
end

#ticket_numberObject (readonly)

Returns the value of attribute ticket_number.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def ticket_number
  @ticket_number
end

#ticket_typeObject (readonly)

Returns the value of attribute ticket_type.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def ticket_type
  @ticket_type
end

#valid_time_endObject (readonly)

Returns the value of attribute valid_time_end.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def valid_time_end
  @valid_time_end
end

#valid_time_startObject (readonly)

Returns the value of attribute valid_time_start.



8
9
10
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 8

def valid_time_start
  @valid_time_start
end

Instance Method Details

#payload_keyObject



59
60
61
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 59

def payload_key
  "#{payload_key_logic}Objects"
end

#pushObject



41
42
43
44
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 41

def push
  access_token = GoogleWallet::Authentication.new.access_token
  GoogleWallet::Operations::EventTicket::PushObject.new(resource: self, access_token: access_token).call
end

#sign(push_resource: true) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/google_wallet/resources/event_ticket/object.rb', line 46

def sign(push_resource: true)
  sign_operation =
    if push_resource
      push
      GoogleWallet::Operations::SignObjects.new(resource_ids: [id], objects_type: self.payload_key)
    else
      GoogleWallet::Operations::SignObjects.new(resources: [itself])
    end

  sign_operation.call
  sign_operation.jwt
end