Class: Onlyfans::Resources::Webhooks

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Webhooks

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Webhooks.

Parameters:



155
156
157
# File 'lib/onlyfans/resources/webhooks.rb', line 155

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account_scope:, endpoint_url:, events:, account_ids: nil, signing_secret: nil, request_options: {}) ⇒ Onlyfans::Models::WebhookCreateResponse

Some parameter documentations has been truncated, see Models::WebhookCreateParams for more details.

Create a new webhook for your Team

**List

Parameters:

  • account_scope (String)

    The account scope for the webhook. Use “global” for all accounts, “inclusive” fo

  • endpoint_url (String)

    The URL of your webhook endpoint.

  • events (Array<String>)

    An array of webhook events to subscribe to. For all options, refer to our

  • account_ids (Array<String>)

    An array of account IDs to apply the scope to. Required unless account_scope is

  • signing_secret (String, nil)

    Optionally, add a signing secret to protect your webhook.

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



29
30
31
32
33
34
35
36
37
38
# File 'lib/onlyfans/resources/webhooks.rb', line 29

def create(params)
  parsed, options = Onlyfans::WebhookCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/webhooks",
    body: parsed,
    model: Onlyfans::Models::WebhookCreateResponse,
    options: options
  )
end

#delete(webhook_id, request_options: {}) ⇒ Hash{Symbol=>Object}?

Delete an existing webhook

Parameters:

Returns:

  • (Hash{Symbol=>Object}, nil)

See Also:



125
126
127
128
129
130
131
132
# File 'lib/onlyfans/resources/webhooks.rb', line 125

def delete(webhook_id, params = {})
  @client.request(
    method: :delete,
    path: ["api/webhooks/%1$s", webhook_id],
    model: Onlyfans::Internal::Type::HashOf[Onlyfans::Internal::Type::Unknown],
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ Onlyfans::Models::WebhookListResponse

Retrieve a list of webhooks for your Team

Parameters:

Returns:

See Also:



105
106
107
108
109
110
111
112
# File 'lib/onlyfans/resources/webhooks.rb', line 105

def list(params = {})
  @client.request(
    method: :get,
    path: "api/webhooks",
    model: Onlyfans::Models::WebhookListResponse,
    options: params[:request_options]
  )
end

#list_events(request_options: {}) ⇒ Onlyfans::Models::WebhookListEventsResponse

Retrieve a list of all available webhook event types

Parameters:

Returns:

See Also:



143
144
145
146
147
148
149
150
# File 'lib/onlyfans/resources/webhooks.rb', line 143

def list_events(params = {})
  @client.request(
    method: :get,
    path: "api/webhooks/events",
    model: Onlyfans::Models::WebhookListEventsResponse,
    options: params[:request_options]
  )
end

#retrieve(webhook_id, request_options: {}) ⇒ Onlyfans::Models::WebhookRetrieveResponse

Retrieve details about a specific webhook

Parameters:

Returns:

See Also:



51
52
53
54
55
56
57
58
# File 'lib/onlyfans/resources/webhooks.rb', line 51

def retrieve(webhook_id, params = {})
  @client.request(
    method: :get,
    path: ["api/webhooks/%1$s", webhook_id],
    model: Onlyfans::Models::WebhookRetrieveResponse,
    options: params[:request_options]
  )
end

#update(webhook_id, account_scope:, endpoint_url:, events:, account_ids: nil, enabled: nil, request_options: {}) ⇒ Onlyfans::Models::WebhookUpdateResponse

Some parameter documentations has been truncated, see Models::WebhookUpdateParams for more details.

Update an existing webhook

**List

Parameters:

  • webhook_id (String)

    The ID of the webhook

  • account_scope (String)

    The account scope for the webhook. Use “global” for all accounts, “inclusive” fo

  • endpoint_url (String)

    The URL of your webhook endpoint.

  • events (Array<String>)

    An array of webhook events to subscribe to. For all options, refer to our

  • account_ids (Array<String>)

    An array of account IDs to apply the scope to. Required unless account_scope is

  • enabled (Boolean, nil)

    Optionally, enabled/disable the webhook. This will stop/resume the sending of ev

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



85
86
87
88
89
90
91
92
93
94
# File 'lib/onlyfans/resources/webhooks.rb', line 85

def update(webhook_id, params)
  parsed, options = Onlyfans::WebhookUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["api/webhooks/%1$s", webhook_id],
    body: parsed,
    model: Onlyfans::Models::WebhookUpdateResponse,
    options: options
  )
end