Class: Appwrite::Webhooks
- Defined in:
- lib/appwrite/services/webhooks.rb
Instance Method Summary collapse
-
#create(webhook_id:, url:, name:, events:, enabled: nil, tls: nil, auth_username: nil, auth_password: nil, secret: nil, description: nil) ⇒ Webhook
Create a new webhook.
-
#delete(webhook_id:) ⇒ Object
Delete a webhook by its unique ID.
-
#get(webhook_id:) ⇒ Webhook
Get a webhook by its unique ID.
-
#initialize(client) ⇒ Webhooks
constructor
A new instance of Webhooks.
-
#list(queries: nil, total: nil) ⇒ WebhookList
Get a list of all webhooks belonging to the project.
-
#update(webhook_id:, name:, url:, events:, enabled: nil, tls: nil, auth_username: nil, auth_password: nil, description: nil) ⇒ Webhook
Update a webhook by its unique ID.
-
#update_secret(webhook_id:, secret: nil) ⇒ Webhook
Update the webhook signing key.
Constructor Details
#initialize(client) ⇒ Webhooks
Returns a new instance of Webhooks.
5 6 7 |
# File 'lib/appwrite/services/webhooks.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#create(webhook_id:, url:, name:, events:, enabled: nil, tls: nil, auth_username: nil, auth_password: nil, secret: nil, description: nil) ⇒ Webhook
Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur.
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/appwrite/services/webhooks.rb', line 56 def create( webhook_id:, url:, name:, events:, enabled: nil, tls: nil, auth_username: nil, auth_password: nil, secret: nil, description: nil ) 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_path = '/webhooks' api_params = { webhookId: webhook_id, url: url, name: name, events: events, enabled: enabled, tls: tls, authUsername: auth_username, authPassword: auth_password, secret: secret, description: description, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": '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.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/appwrite/services/webhooks.rb', line 222 def delete( webhook_id: ) if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end api_path = '/webhooks/{webhookId}' .gsub('{webhookId}', @client.encode_path(webhook_id)) api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": '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.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/appwrite/services/webhooks.rb', line 120 def get( webhook_id: ) if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end api_path = '/webhooks/{webhookId}' .gsub('{webhookId}', @client.encode_path(webhook_id)) api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/appwrite/services/webhooks.rb', line 16 def list( queries: nil, total: nil ) api_path = '/webhooks' api_params = { queries: queries, total: total, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @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, tls: nil, auth_username: nil, auth_password: nil, description: nil) ⇒ Webhook
Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/appwrite/services/webhooks.rb', line 160 def update( webhook_id:, name:, url:, events:, enabled: nil, tls: nil, auth_username: nil, auth_password: nil, description: nil ) if webhook_id.nil? || webhook_id == '' 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_path = '/webhooks/{webhookId}' .gsub('{webhookId}', @client.encode_path(webhook_id)) api_params = { name: name, url: url, events: events, enabled: enabled, tls: tls, authUsername: auth_username, authPassword: auth_password, description: description, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PUT', path: api_path, headers: api_headers, params: api_params, response_type: Models::Webhook ) end |
#update_secret(webhook_id:, secret: nil) ⇒ Webhook
Update the webhook signing key. This endpoint can be used to regenerate the signing key used to sign and validate payload deliveries for a specific webhook.
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/appwrite/services/webhooks.rb', line 256 def update_secret( webhook_id:, secret: nil ) if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end api_path = '/webhooks/{webhookId}/secret' .gsub('{webhookId}', @client.encode_path(webhook_id)) api_params = { secret: secret, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PATCH', path: api_path, headers: api_headers, params: api_params, response_type: Models::Webhook ) end |