Class: LemonSqueezy::Webhook
- Defined in:
- lib/lemon_squeezy/models/webhook.rb
Class Method Summary collapse
- .create(store_id:, url:, events:, secret:, **params) ⇒ Object
- .delete(id:) ⇒ Object
- .list(**params) ⇒ Object
- .retrieve(id:) ⇒ Object
- .update(id:, **params) ⇒ Object
Methods inherited from Object
Constructor Details
This class inherits a constructor from LemonSqueezy::Object
Class Method Details
.create(store_id:, url:, events:, secret:, **params) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lemon_squeezy/models/webhook.rb', line 16 def create(store_id:, url:, events:, secret:, **params) body = { data: { type: "webhooks", attributes: { url: url, events: events, secret: secret }.merge(params), relationships: { store: { data: { type: "stores", id: store_id.to_s } }, } } } response = Client.post_request("webhooks", body: body.to_json) Webhook.new(response.body["data"]) if response.success? end |
.delete(id:) ⇒ Object
51 52 53 |
# File 'lib/lemon_squeezy/models/webhook.rb', line 51 def delete(id:) Client.delete_request("webhooks/#{id}") end |
.list(**params) ⇒ Object
6 7 8 9 |
# File 'lib/lemon_squeezy/models/webhook.rb', line 6 def list(**params) response = Client.get_request("webhooks", params: {filter: params}) Collection.from_response(response, type: Webhook) end |
.retrieve(id:) ⇒ Object
11 12 13 14 |
# File 'lib/lemon_squeezy/models/webhook.rb', line 11 def retrieve(id:) response = Client.get_request("webhooks/#{id}") Webhook.new(response.body["data"]) if response.success? end |
.update(id:, **params) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lemon_squeezy/models/webhook.rb', line 39 def update(id:, **params) body = { data: { type: "webhooks", id: id.to_s, attributes: params } } response = Client.patch_request("webhooks/#{id}", body: body.to_json) Webhook.new(response.body["data"]) if response.success? end |