Class: Appwrite::Webhooks

Inherits:
Service
  • Object
show all
Defined in:
lib/appwrite/services/webhooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Webhooks

Returns a new instance of Webhooks.



6
7
8
# File 'lib/appwrite/services/webhooks.rb', line 6

def initialize(client)
    @client = client
end

Instance Method Details

#create(webhook_id:, url:, name:, events:, enabled: nil, security: nil, http_user: nil, http_pass: nil) ⇒ Webhook

Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur.

Parameters:

  • webhook_id (String)

    Webhook ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • url (String)

    Webhook URL.

  • name (String)

    Webhook name. Max length: 128 chars.

  • events (Array)

    Events list. Maximum of 100 events are allowed.

  • []

    enabled Enable or disable a webhook.

  • []

    security Certificate verification, false for disabled or true for enabled.

  • http_user (String) (defaults to: nil)

    Webhook HTTP user. Max length: 256 chars.

  • http_pass (String) (defaults to: nil)

    Webhook HTTP password. Max length: 256 chars.

Returns:

  • (Webhook)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/appwrite/services/webhooks.rb', line 50

def create(webhook_id:, url:, name:, events:, enabled: nil, security: nil, http_user: nil, http_pass: nil)
    api_path = '/webhooks'

    if webhook_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "webhookId"')
    end

    if url.nil?
      raise Appwrite::Exception.new('Missing required parameter: "url"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    if events.nil?
      raise Appwrite::Exception.new('Missing required parameter: "events"')
    end

    api_params = {
        webhookId: webhook_id,
        url: url,
        name: name,
        events: events,
        enabled: enabled,
        security: security,
        httpUser: http_user,
        httpPass: http_pass,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Webhook
    )
end

#delete(webhook_id:) ⇒ Object

Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events.

Parameters:

  • webhook_id (String)

    Webhook ID.

Returns:



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/appwrite/services/webhooks.rb', line 184

def delete(webhook_id:)
    api_path = '/webhooks/{webhookId}'
        .gsub('{webhookId}', webhook_id)

    if webhook_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "webhookId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )
end

#get(webhook_id:) ⇒ Webhook

Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project.

Parameters:

  • webhook_id (String)

    Webhook ID.

Returns:

  • (Webhook)


99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/appwrite/services/webhooks.rb', line 99

def get(webhook_id:)
    api_path = '/webhooks/{webhookId}'
        .gsub('{webhookId}', webhook_id)

    if webhook_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "webhookId"')
    end

    api_params = {
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Webhook
    )
end

#list(queries: nil, total: nil) ⇒ WebhookList

Get a list of all webhooks belonging to the project. You can use the query params to filter your results.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, httpUser, security, events, enabled, logs, attempts

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (WebhookList)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/appwrite/services/webhooks.rb', line 17

def list(queries: nil, total: nil)
    api_path = '/webhooks'

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::WebhookList
    )
end

#update(webhook_id:, name:, url:, events:, enabled: nil, security: nil, http_user: nil, http_pass: nil) ⇒ Webhook

Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook.

Parameters:

  • webhook_id (String)

    Webhook ID.

  • name (String)

    Webhook name. Max length: 128 chars.

  • url (String)

    Webhook URL.

  • events (Array)

    Events list. Maximum of 100 events are allowed.

  • []

    enabled Enable or disable a webhook.

  • []

    security Certificate verification, false for disabled or true for enabled.

  • http_user (String) (defaults to: nil)

    Webhook HTTP user. Max length: 256 chars.

  • http_pass (String) (defaults to: nil)

    Webhook HTTP password. Max length: 256 chars.

Returns:

  • (Webhook)


135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/appwrite/services/webhooks.rb', line 135

def update(webhook_id:, name:, url:, events:, enabled: nil, security: nil, http_user: nil, http_pass: nil)
    api_path = '/webhooks/{webhookId}'
        .gsub('{webhookId}', webhook_id)

    if webhook_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "webhookId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    if url.nil?
      raise Appwrite::Exception.new('Missing required parameter: "url"')
    end

    if events.nil?
      raise Appwrite::Exception.new('Missing required parameter: "events"')
    end

    api_params = {
        name: name,
        url: url,
        events: events,
        enabled: enabled,
        security: security,
        httpUser: http_user,
        httpPass: http_pass,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Webhook
    )
end

#update_signature(webhook_id:) ⇒ Webhook

Update the webhook signature key. This endpoint can be used to regenerate the signature key used to sign and validate payload deliveries for a specific webhook.

Parameters:

  • webhook_id (String)

    Webhook ID.

Returns:

  • (Webhook)


214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/appwrite/services/webhooks.rb', line 214

def update_signature(webhook_id:)
    api_path = '/webhooks/{webhookId}/signature'
        .gsub('{webhookId}', webhook_id)

    if webhook_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "webhookId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Webhook
    )
end