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) ⇒ 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) ⇒ 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.
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, tls: nil, auth_username: nil, auth_password: nil, secret: nil) ⇒ Webhook
Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur.
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 92 93 94 95 |
# File 'lib/appwrite/services/webhooks.rb', line 52 def create(webhook_id:, url:, name:, events:, enabled: nil, tls: nil, auth_username: nil, auth_password: nil, secret: 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, tls: tls, authUsername: auth_username, authPassword: auth_password, secret: secret, } 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.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/appwrite/services/webhooks.rb', line 190 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.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/appwrite/services/webhooks.rb', line 103 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.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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, tls: nil, auth_username: nil, auth_password: nil) ⇒ Webhook
Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook.
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 177 178 179 180 181 182 |
# File 'lib/appwrite/services/webhooks.rb', line 140 def update(webhook_id:, name:, url:, events:, enabled: nil, tls: nil, auth_username: nil, auth_password: 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, tls: tls, authUsername: auth_username, authPassword: auth_password, } 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_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.
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 update_secret(webhook_id:, secret: nil) api_path = '/webhooks/{webhookId}/secret' .gsub('{webhookId}', webhook_id) if webhook_id.nil? raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end api_params = { secret: secret, } api_headers = { "content-type": 'application/json', } @client.call( method: 'PATCH', path: api_path, headers: api_headers, params: api_params, response_type: Models::Webhook ) end |