Class: Contentful::Webhook::Listener::BaseWebhook
- Inherits:
-
Object
- Object
- Contentful::Webhook::Listener::BaseWebhook
- Defined in:
- lib/contentful/webhook/listener/webhooks.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#raw_body ⇒ Object
readonly
Returns the value of attribute raw_body.
-
#raw_headers ⇒ Object
readonly
Returns the value of attribute raw_headers.
-
#raw_topic ⇒ Object
readonly
Returns the value of attribute raw_topic.
-
#space_id ⇒ Object
readonly
Returns the value of attribute space_id.
-
#sys ⇒ Object
readonly
Returns the value of attribute sys.
Instance Method Summary collapse
- #asset? ⇒ Boolean
- #content_type? ⇒ Boolean
- #entry? ⇒ Boolean
-
#initialize(headers, body) ⇒ BaseWebhook
constructor
A new instance of BaseWebhook.
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
#event ⇒ Object (readonly)
Returns the value of attribute event.
37 38 39 |
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37 def event @event end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
37 38 39 |
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
37 38 39 |
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
37 38 39 |
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37 def name @name end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
37 38 39 |
# File 'lib/contentful/webhook/listener/webhooks.rb', line 37 def origin @origin end |
#raw_body ⇒ Object (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_headers ⇒ Object (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_topic ⇒ Object (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_id ⇒ Object (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 |
#sys ⇒ Object (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
54 55 56 |
# File 'lib/contentful/webhook/listener/webhooks.rb', line 54 def asset? kind == 'Asset' end |
#content_type? ⇒ Boolean
58 59 60 |
# File 'lib/contentful/webhook/listener/webhooks.rb', line 58 def content_type? kind == 'ContentType' end |
#entry? ⇒ Boolean
50 51 52 |
# File 'lib/contentful/webhook/listener/webhooks.rb', line 50 def entry? kind == 'Entry' end |