Class: SquareEvent::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/square_event/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, merchant_id, event_id, data, payload, environment, timestamp) ⇒ Event

Returns a new instance of Event.



14
15
16
17
18
19
20
21
# File 'lib/square_event/event.rb', line 14

def initialize(type, merchant_id, event_id, data, payload, environment, timestamp)
  @type = type
  @merchant_id = merchant_id
  @event_id = event_id
  @data = data
  @environment = environment
  @initial_delivery_timestamp = timestamp
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/square_event/event.rb', line 3

def data
  @data
end

#environmentObject (readonly)

Returns the value of attribute environment.



3
4
5
# File 'lib/square_event/event.rb', line 3

def environment
  @environment
end

#event_idObject (readonly)

Returns the value of attribute event_id.



3
4
5
# File 'lib/square_event/event.rb', line 3

def event_id
  @event_id
end

#initial_delivery_timestampObject (readonly)

Returns the value of attribute initial_delivery_timestamp.



3
4
5
# File 'lib/square_event/event.rb', line 3

def initial_delivery_timestamp
  @initial_delivery_timestamp
end

#merchant_idObject (readonly)

Returns the value of attribute merchant_id.



3
4
5
# File 'lib/square_event/event.rb', line 3

def merchant_id
  @merchant_id
end

#payloadObject (readonly)

Returns the value of attribute payload.



3
4
5
# File 'lib/square_event/event.rb', line 3

def payload
  @payload
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/square_event/event.rb', line 3

def type
  @type
end

Class Method Details

.construct_from(payload, environment, timestamp) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/square_event/event.rb', line 5

def self.construct_from(payload, environment, timestamp)
  type        = payload[:type]
  merchant_id = payload[:merchant_id]
  event_id    = payload[:event_id]
  data        = payload[:data]

  new(type, merchant_id, event_id, data, payload, environment, timestamp)
end

Instance Method Details

#livemodeObject Also known as: livemode?



23
24
25
# File 'lib/square_event/event.rb', line 23

def livemode
  environment != 'Sandbox'
end

#sandboxObject Also known as: sandbox?



28
29
30
# File 'lib/square_event/event.rb', line 28

def sandbox
  environment == 'Sandbox'
end