Class: Io::Flow::V0::Clients::Webhooks
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Webhooks
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_id(organization, id) ⇒ Object
Delete a webhook with the specified id.
-
#get(organization, incoming = {}) ⇒ Object
Returns webhooks for an organization.
-
#get_by_id(organization, id) ⇒ Object
Returns information about a specific webhook.
-
#get_settings(organization) ⇒ Object
Returns the webhook settings for an organization.
-
#initialize(client) ⇒ Webhooks
constructor
A new instance of Webhooks.
-
#post(organization, webhook_form) ⇒ Object
Create a new webhook.
-
#put_by_id(organization, id, webhook_form) ⇒ Object
Update an existing webhook.
-
#put_settings(organization, webhook_settings) ⇒ Object
Updates the webhook settings for an organization.
Constructor Details
#initialize(client) ⇒ Webhooks
Returns a new instance of Webhooks.
3728 3729 3730 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3728 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
Delete a webhook with the specified id
3772 3773 3774 3775 3776 3777 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3772 def delete_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/webhooks/#{CGI.escape(id)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
Returns webhooks for an organization
3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3733 def get(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/webhooks").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Webhook.new(x) } end |
#get_by_id(organization, id) ⇒ Object
Returns information about a specific webhook
3755 3756 3757 3758 3759 3760 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3755 def get_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/webhooks/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Webhook.new(r) end |
#get_settings(organization) ⇒ Object
Returns the webhook settings for an organization
3780 3781 3782 3783 3784 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3780 def get_settings(organization) HttpClient::Preconditions.assert_class('organization', organization, String) r = @client.request("/#{CGI.escape(organization)}/webhooks/settings").get ::Io::Flow::V0::Models::WebhookSettings.new(r) end |
#post(organization, webhook_form) ⇒ Object
Create a new webhook
3747 3748 3749 3750 3751 3752 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3747 def post(organization, webhook_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = webhook_form; x.is_a?(::Io::Flow::V0::Models::WebhookForm) ? x : ::Io::Flow::V0::Models::WebhookForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/webhooks").with_json(webhook_form.to_json).post ::Io::Flow::V0::Models::Webhook.new(r) end |
#put_by_id(organization, id, webhook_form) ⇒ Object
Update an existing webhook
3763 3764 3765 3766 3767 3768 3769 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3763 def put_by_id(organization, id, webhook_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) (x = webhook_form; x.is_a?(::Io::Flow::V0::Models::WebhookForm) ? x : ::Io::Flow::V0::Models::WebhookForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/webhooks/#{CGI.escape(id)}").with_json(webhook_form.to_json).put ::Io::Flow::V0::Models::Webhook.new(r) end |
#put_settings(organization, webhook_settings) ⇒ Object
Updates the webhook settings for an organization
3787 3788 3789 3790 3791 3792 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3787 def put_settings(organization, webhook_settings) HttpClient::Preconditions.assert_class('organization', organization, String) (x = webhook_settings; x.is_a?(::Io::Flow::V0::Models::WebhookSettings) ? x : ::Io::Flow::V0::Models::WebhookSettings.new(x)) r = @client.request("/#{CGI.escape(organization)}/webhooks/settings").with_json(webhook_settings.to_json).put ::Io::Flow::V0::Models::WebhookSettings.new(r) end |