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.
-
#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.
Constructor Details
#initialize(client) ⇒ Webhooks
Returns a new instance of Webhooks.
5070 5071 5072 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5070 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
5114 5115 5116 5117 5118 5119 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5114 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
5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5075 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
5097 5098 5099 5100 5101 5102 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5097 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 |
#post(organization, webhook_form) ⇒ Object
Create a new webhook
5089 5090 5091 5092 5093 5094 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5089 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
5105 5106 5107 5108 5109 5110 5111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5105 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 |