Class: Webhook

Inherits:
Object
  • Object
show all
Defined in:
lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb

Direct Known Subclasses

CustomerCreated, K2CommonEvents

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Webhook

Returns a new instance of Webhook.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 11

def initialize(payload)
  @id = payload.dig('id')
  @topic = payload.dig('topic')
  @created_at = payload.dig('created_at')
  # Event
  @event_type = payload.dig('event', 'type')
  @resource_id = payload.dig('event', 'resource', 'id') unless @event_type.eql?('Customer Created')
  # Links
  @links_self = payload.dig('_links', 'self')
  @links_resource = payload.dig('_links', 'resource')
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 2

def created_at
  @created_at
end

#event_resourceObject (readonly)

Returns the value of attribute event_resource.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 2

def event_resource
  @event_resource
end

#event_typeObject (readonly)

Returns the value of attribute event_type.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 2

def event_type
  @event_type
end

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 2

def id
  @id
end

Returns the value of attribute links_resource.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 2

def links_resource
  @links_resource
end

Returns the value of attribute links_self.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 2

def links_self
  @links_self
end

#resource_idObject (readonly)

Returns the value of attribute resource_id.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 2

def resource_id
  @resource_id
end

#topicObject (readonly)

Returns the value of attribute topic.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 2

def topic
  @topic
end