Class: TrueTrial::Resources::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/truetrial/resources/webhooks.rb

Overview

Provides access to webhook subscription management endpoints.

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Webhooks

Returns a new instance of Webhooks.



7
8
9
# File 'lib/truetrial/resources/webhooks.rb', line 7

def initialize(http_client)
  @http = http_client
end

Instance Method Details

#create(data) ⇒ Hash

Creates a new webhook subscription.

Parameters:

  • data (Hash)

    webhook attributes (url, events, secret)

Returns:

  • (Hash)

    the created webhook subscription



22
23
24
# File 'lib/truetrial/resources/webhooks.rb', line 22

def create(data)
  @http.post("/webhooks", body: data)
end

#delete(id) ⇒ Hash

Deletes a webhook subscription.

Parameters:

  • id (String)

    the webhook subscription ULID

Returns:

  • (Hash)

    deletion confirmation



30
31
32
# File 'lib/truetrial/resources/webhooks.rb', line 30

def delete(id)
  @http.delete("/webhooks/#{id}")
end

#listHash

Lists all webhook subscriptions.

Returns:

  • (Hash)

    list of webhook subscriptions



14
15
16
# File 'lib/truetrial/resources/webhooks.rb', line 14

def list
  @http.get("/webhooks")
end