Class: Contentful::Webhook::Listener::BaseWebhook

Inherits:
Object
  • Object
show all
Defined in:
lib/contentful/webhook/listener/webhooks.rb

Direct Known Subclasses

DeleteWebhook, FieldWebhook, UnpublishWebhook

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers, body) ⇒ BaseWebhook

Returns a new instance of BaseWebhook.



37
38
39
40
41
42
43
44
45
46
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def initialize(headers, body)
  @raw_topic = headers[::Contentful::Webhook::Listener::WebhookConstants::WEBHOOK_TOPIC]
  @name = headers[::Contentful::Webhook::Listener::WebhookConstants::WEBHOOK_NAME]
  @origin, @kind, @event = @raw_topic.split('.')
  @raw_body = body
  @raw_headers = headers
  @sys = body['sys']
  @id = sys['id']
  @space_id = sys['space']['sys']['id']
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def event
  @event
end

#idObject (readonly)

Returns the value of attribute id.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def id
  @id
end

#kindObject (readonly)

Returns the value of attribute kind.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def name
  @name
end

#originObject (readonly)

Returns the value of attribute origin.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def origin
  @origin
end

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def raw_body
  @raw_body
end

#raw_headersObject (readonly)

Returns the value of attribute raw_headers.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def raw_headers
  @raw_headers
end

#raw_topicObject (readonly)

Returns the value of attribute raw_topic.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def raw_topic
  @raw_topic
end

#space_idObject (readonly)

Returns the value of attribute space_id.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def space_id
  @space_id
end

#sysObject (readonly)

Returns the value of attribute sys.



35
36
37
# File 'lib/contentful/webhook/listener/webhooks.rb', line 35

def sys
  @sys
end

Instance Method Details

#asset?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/contentful/webhook/listener/webhooks.rb', line 52

def asset?
  kind == 'Asset'
end

#content_type?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/contentful/webhook/listener/webhooks.rb', line 56

def content_type?
  kind == 'ContentType'
end

#entry?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/contentful/webhook/listener/webhooks.rb', line 48

def entry?
  kind == 'Entry'
end