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.
2964 2965 2966 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2964 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
3008 3009 3010 3011 3012 3013 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3008 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
2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2969 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
2991 2992 2993 2994 2995 2996 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2991 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
3016 3017 3018 3019 3020 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3016 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
2983 2984 2985 2986 2987 2988 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2983 def post(organization, webhook_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('webhook_form', webhook_form, ::Io::Flow::V0::Models::WebhookForm) 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
2999 3000 3001 3002 3003 3004 3005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2999 def put_by_id(organization, id, webhook_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) HttpClient::Preconditions.assert_class('webhook_form', webhook_form, ::Io::Flow::V0::Models::WebhookForm) 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
3023 3024 3025 3026 3027 3028 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3023 def put_settings(organization, webhook_settings) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('webhook_settings', webhook_settings, ::Io::Flow::V0::Models::WebhookSettings) r = @client.request("/#{CGI.escape(organization)}/webhooks/settings").with_json(webhook_settings.to_json).put ::Io::Flow::V0::Models::WebhookSettings.new(r) end |