Class: Layer::Webhook

Overview

Note:

This feature is still in beta at Layer. Please contact Layer to enable webhooks for your account.

Note:

This is only available via the Platform API.

Examples:

webhook = Layer::Webhook.create({
  target_config: { foo: :bar },
  secret: 'my-secret',
  event_types: ['message.sent'],
  target_url: 'http://example.com/layer/webhook'
})

See Also:

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #client

Instance Method Summary collapse

Methods included from Operations::Delete::ClassMethods

delete

Methods included from Operations::Create::ClassMethods

create

Methods included from Operations::List::ClassMethods

all

Methods included from Operations::Find::ClassMethods

find

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

Instance Method Details

#activate!Object

Activate this webhook



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

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

#active?Boolean

Check if this webhook is active

Returns:

  • (Boolean)

    whether the webhook is active



42
43
44
# File 'lib/layer/webhook.rb', line 42

def active?
  status == 'active'
end

#created_atTime

Returns the time the webhook was created at

Returns:

  • (Time)

    the time the webhook was created at



54
55
56
# File 'lib/layer/webhook.rb', line 54

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

#deactivate!Object

Deactivate this webhook



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

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

#inactive?Boolean

Check if this webhook is inactive

Returns:

  • (Boolean)

    whether the webhook is inactive



48
49
50
# File 'lib/layer/webhook.rb', line 48

def inactive?
  status == 'inactive'
end

#unverified?Boolean

Check if this webhook is unverified

Returns:

  • (Boolean)

    whether the webhook is unverified



36
37
38
# File 'lib/layer/webhook.rb', line 36

def unverified?
  status == 'unverified'
end