Class: PostForMe::Resources::Webhooks
- Inherits:
-
Object
- Object
- PostForMe::Resources::Webhooks
- Defined in:
- lib/post_for_me/resources/webhooks.rb,
sig/post_for_me/resources/webhooks.rbs
Overview
Webhooks enable you to subscribe to certain events. This involves Post for Me making a POST request to the URL of any webhooks you create. Only the events you subscribe to will be sent to your webhook URL.
Payload
When an event happens that your webhook is subscribed to, we will make a POST request with the following JSON body
{
"event_type": "",
"data": {}
}
The event_type will be the event that triggered the webhook POST, data will be the resulting entity from the event
Security
To verify the POST to your webhook URL is from us we will include a secret in the header "Post-For-Me-Webhook-Secret". When you create a webhook you will receive the secret in the response.
Retries
If your server fails to respond with a 2XX code, requests to it will be retried with exponential backoff around 8 times over the course of just over a day.
Instance Method Summary collapse
-
#create(event_types:, url:, request_options: {}) ⇒ PostForMe::Models::Webhook
Create Webhook.
-
#delete(id, request_options: {}) ⇒ PostForMe::Models::DeleteEntityResponse
Delete Webhook.
-
#initialize(client:) ⇒ Webhooks
constructor
private
A new instance of Webhooks.
-
#list(id: nil, event_type: nil, limit: nil, offset: nil, url: nil, request_options: {}) ⇒ PostForMe::Models::WebhookListResponse
Some parameter documentations has been truncated, see Models::WebhookListParams for more details.
-
#retrieve(id, request_options: {}) ⇒ PostForMe::Models::Webhook
Get webhook by ID.
-
#update(id, event_types: nil, url: nil, request_options: {}) ⇒ PostForMe::Models::Webhook
Update Webhook.
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.
162 163 164 |
# File 'lib/post_for_me/resources/webhooks.rb', line 162 def initialize(client:) @client = client end |
Instance Method Details
#create(event_types:, url:, request_options: {}) ⇒ PostForMe::Models::Webhook
Create Webhook
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/post_for_me/resources/webhooks.rb', line 48 def create(params) parsed, = PostForMe::WebhookCreateParams.dump_request(params) @client.request( method: :post, path: "v1/webhooks", body: parsed, model: PostForMe::Webhook, options: ) end |
#delete(id, request_options: {}) ⇒ PostForMe::Models::DeleteEntityResponse
Delete Webhook
150 151 152 153 154 155 156 157 |
# File 'lib/post_for_me/resources/webhooks.rb', line 150 def delete(id, params = {}) @client.request( method: :delete, path: ["v1/webhooks/%1$s", id], model: PostForMe::DeleteEntityResponse, options: params[:request_options] ) end |
#list(id: nil, event_type: nil, limit: nil, offset: nil, url: nil, request_options: {}) ⇒ PostForMe::Models::WebhookListResponse
Some parameter documentations has been truncated, see Models::WebhookListParams for more details.
Get a paginated result for webhooks based on the applied filters
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/post_for_me/resources/webhooks.rb', line 127 def list(params = {}) parsed, = PostForMe::WebhookListParams.dump_request(params) query = PostForMe::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v1/webhooks", query: query, model: PostForMe::Models::WebhookListResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ PostForMe::Models::Webhook
Get webhook by ID
70 71 72 73 74 75 76 77 |
# File 'lib/post_for_me/resources/webhooks.rb', line 70 def retrieve(id, params = {}) @client.request( method: :get, path: ["v1/webhooks/%1$s", id], model: PostForMe::Webhook, options: params[:request_options] ) end |
#update(id, event_types: nil, url: nil, request_options: {}) ⇒ PostForMe::Models::Webhook
Update Webhook
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/post_for_me/resources/webhooks.rb', line 94 def update(id, params = {}) parsed, = PostForMe::WebhookUpdateParams.dump_request(params) @client.request( method: :patch, path: ["v1/webhooks/%1$s", id], body: parsed, model: PostForMe::Webhook, options: ) end |