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.



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

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.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def event
  @event
end

#idObject (readonly)

Returns the value of attribute id.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def id
  @id
end

#kindObject (readonly)

Returns the value of attribute kind.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def name
  @name
end

#originObject (readonly)

Returns the value of attribute origin.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def origin
  @origin
end

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def raw_body
  @raw_body
end

#raw_headersObject (readonly)

Returns the value of attribute raw_headers.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def raw_headers
  @raw_headers
end

#raw_topicObject (readonly)

Returns the value of attribute raw_topic.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def raw_topic
  @raw_topic
end

#space_idObject (readonly)

Returns the value of attribute space_id.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def space_id
  @space_id
end

#sysObject (readonly)

Returns the value of attribute sys.



37
38
39
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37

def sys
  @sys
end

Instance Method Details

#asset?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/contentful/webhook/listener/webhooks.rb', line 54

def asset?
  kind == 'Asset'
end

#content_type?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/contentful/webhook/listener/webhooks.rb', line 58

def content_type?
  kind == 'ContentType'
end

#entry?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/contentful/webhook/listener/webhooks.rb', line 50

def entry?
  kind == 'Entry'
end