Class: BaseCradle::TimelineWebhookEndpoints

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/basecradle/webhooks.rb

Overview

One timeline’s webhook endpoints: create here, or iterate (newest first).

Instance Method Summary collapse

Constructor Details

#initialize(client, timeline_uuid) ⇒ TimelineWebhookEndpoints

Returns a new instance of TimelineWebhookEndpoints.



111
112
113
114
# File 'lib/basecradle/webhooks.rb', line 111

def initialize(client, timeline_uuid)
  @client = client
  @timeline_uuid = timeline_uuid
end

Instance Method Details

#create(description:) ⇒ Object

Create an inbound webhook endpoint on this timeline (viewer; the timeline unlocked).



117
118
119
120
121
# File 'lib/basecradle/webhooks.rb', line 117

def create(description:)
  response = @client.request("POST", "/timelines/#{@timeline_uuid}/webhook_endpoints",
                             json: { "webhook_endpoint" => { "description" => description } })
  WebhookEndpoint.new(response.fetch("webhook_endpoint"), client: @client)
end

#each(&block) ⇒ Object



123
124
125
# File 'lib/basecradle/webhooks.rb', line 123

def each(&block)
  WebhookEndpointsResource.new(@client).filter(timeline: @timeline_uuid).each(&block)
end