Class: Pobo::DTO::WebhookPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/pobo/dto/webhook_payload.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event:, timestamp:, eshop_id:) ⇒ WebhookPayload

Returns a new instance of WebhookPayload.



8
9
10
11
12
# File 'lib/pobo/dto/webhook_payload.rb', line 8

def initialize(event:, timestamp:, eshop_id:)
  @event = event
  @timestamp = timestamp
  @eshop_id = eshop_id
end

Instance Attribute Details

#eshop_id ⇒ Object (readonly)

Returns the value of attribute eshop_id.



6
7
8
# File 'lib/pobo/dto/webhook_payload.rb', line 6

def eshop_id
  @eshop_id
end

#event ⇒ Object (readonly)

Returns the value of attribute event.



6
7
8
# File 'lib/pobo/dto/webhook_payload.rb', line 6

def event
  @event
end

#timestamp ⇒ Object (readonly)

Returns the value of attribute timestamp.



6
7
8
# File 'lib/pobo/dto/webhook_payload.rb', line 6

def timestamp
  @timestamp
end

Class Method Details

.from_hash(hash) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pobo/dto/webhook_payload.rb', line 14

def self.from_hash(hash)
  timestamp = hash["timestamp"] || hash[:timestamp]
  timestamp = Time.at(timestamp) if timestamp.is_a?(Integer)
  timestamp = Time.parse(timestamp) if timestamp.is_a?(String)

  new(
    event: hash["event"] || hash[:event],
    timestamp: timestamp,
    eshop_id: hash["eshop_id"] || hash[:eshop_id]
  )
end