Class: Layer::Webhook

Overview

Note:

This is only available via the Platform API.

Examples:

webhook = Layer::Webhook.create({
  version: '1.0',
  target_url: 'https://example.com/layer/webhook',
  events: ['message.sent'],
  secret: 'my-secret',
  config: { foo: :bar }
})

See Also:

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #client

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Operations::Find::ClassMethods

find

Methods included from Operations::List::ClassMethods

all

Methods included from Operations::Create::ClassMethods

create

Methods included from Operations::Delete::ClassMethods

delete

Methods included from Operations::Delete

#delete

Methods included from Operations::Find

#reload

Methods inherited from Resource

class_name, from_response, #id, #initialize, #respond_to_missing?, url, #url

Constructor Details

This class inherits a constructor from Layer::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Layer::Resource

Class Method Details

.clientObject



24
25
26
# File 'lib/layer/webhook.rb', line 24

def self.client
  @client ||= Client::Webhook.new
end

Instance Method Details

#activate!Object

Activate this webhook



29
30
31
# File 'lib/layer/webhook.rb', line 29

def activate!
  client.post("#{url}/activate")
end

#active?Boolean

Check if this webhook is active

Returns:

  • (Boolean)

    whether the webhook is active



46
47
48
# File 'lib/layer/webhook.rb', line 46

def active?
  status == 'active'
end

#created_atTime

Returns the time the webhook was created at

Returns:

  • (Time)

    the time the webhook was created at



58
59
60
# File 'lib/layer/webhook.rb', line 58

def created_at
  Time.parse(attributes['created_at'])
end

#deactivate!Object

Deactivate this webhook



34
35
36
# File 'lib/layer/webhook.rb', line 34

def deactivate!
  client.post("#{url}/deactivate")
end

#inactive?Boolean

Check if this webhook is inactive

Returns:

  • (Boolean)

    whether the webhook is inactive



52
53
54
# File 'lib/layer/webhook.rb', line 52

def inactive?
  status == 'inactive'
end

#unverified?Boolean

Check if this webhook is unverified

Returns:

  • (Boolean)

    whether the webhook is unverified



40
41
42
# File 'lib/layer/webhook.rb', line 40

def unverified?
  status == 'unverified'
end