Class: SquareEvent::Event
- Inherits:
-
Object
- Object
- SquareEvent::Event
- Defined in:
- lib/square_event/event.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#event_id ⇒ Object
readonly
Returns the value of attribute event_id.
-
#initial_delivery_timestamp ⇒ Object
readonly
Returns the value of attribute initial_delivery_timestamp.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(type, merchant_id, event_id, data, payload, environment, timestamp) ⇒ Event
constructor
A new instance of Event.
- #livemode ⇒ Object (also: #livemode?)
- #sandbox ⇒ Object (also: #sandbox?)
- #to_h ⇒ Object
Constructor Details
#initialize(type, merchant_id, event_id, data, payload, environment, timestamp) ⇒ Event
Returns a new instance of Event.
25 26 27 28 29 30 31 32 33 |
# File 'lib/square_event/event.rb', line 25 def initialize(type, merchant_id, event_id, data, payload, environment, ) @type = type @merchant_id = merchant_id @event_id = event_id @data = data @environment = environment = @internal_hash = {} end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/square_event/event.rb', line 3 def data @data end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
3 4 5 |
# File 'lib/square_event/event.rb', line 3 def environment @environment end |
#event_id ⇒ Object (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_timestamp ⇒ Object (readonly)
Returns the value of attribute initial_delivery_timestamp.
3 4 5 |
# File 'lib/square_event/event.rb', line 3 def end |
#merchant_id ⇒ Object (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 |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
3 4 5 |
# File 'lib/square_event/event.rb', line 3 def payload @payload end |
#type ⇒ Object (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
16 17 18 19 20 21 22 23 |
# File 'lib/square_event/event.rb', line 16 def self.construct_from(payload, environment, ) 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, ) end |
Instance Method Details
#[](key) ⇒ Object
35 36 37 |
# File 'lib/square_event/event.rb', line 35 def [](key) @internal_hash[key] end |
#[]=(key, value) ⇒ Object
39 40 41 |
# File 'lib/square_event/event.rb', line 39 def []=(key, value) @internal_hash[key] = value end |
#livemode ⇒ Object Also known as: livemode?
43 44 45 |
# File 'lib/square_event/event.rb', line 43 def livemode environment != 'Sandbox' end |
#sandbox ⇒ Object Also known as: sandbox?
48 49 50 |
# File 'lib/square_event/event.rb', line 48 def sandbox environment == 'Sandbox' end |
#to_h ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/square_event/event.rb', line 5 def to_h { type: type, merchant_id: merchant_id, event_id: event_id, data: data, environment: environment, initial_delivery_timestamp: } end |