class Io::Flow::V0::Clients::Webhooks

Public Class Methods

new(client) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 5188
def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Public Instance Methods

delete_channel_and_webhooks_by_channel_and_id(channel, id) click to toggle source

Delete a channel webhook with the specified id

# File lib/flow_commerce/flow_api_v0_client.rb, line 5232
def delete_channel_and_webhooks_by_channel_and_id(channel, id)
  HttpClient::Preconditions.assert_class('channel', channel, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/channel/#{CGI.escape(channel)}/webhooks/#{CGI.escape(id)}").delete
  nil
end
delete_webhooks_by_organization_and_id(organization, id) click to toggle source

Delete a webhook with the specified id

# File lib/flow_commerce/flow_api_v0_client.rb, line 5279
def delete_webhooks_by_organization_and_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_channel_and_webhooks_by_channel(channel, incoming={}) click to toggle source

Returns webhooks for a channel

# File lib/flow_commerce/flow_api_v0_client.rb, line 5193
def get_channel_and_webhooks_by_channel(channel, incoming={})
  HttpClient::Preconditions.assert_class('channel', channel, 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("/channel/#{CGI.escape(channel)}/webhooks").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::Webhook.new(x) }
end
get_channel_and_webhooks_by_channel_and_id(channel, id) click to toggle source

Returns information about a specific channel webhook

# File lib/flow_commerce/flow_api_v0_client.rb, line 5215
def get_channel_and_webhooks_by_channel_and_id(channel, id)
  HttpClient::Preconditions.assert_class('channel', channel, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/channel/#{CGI.escape(channel)}/webhooks/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::Webhook.new(r)
end
get_webhooks_by_organization(organization, incoming={}) click to toggle source

Returns webhooks for an organization

# File lib/flow_commerce/flow_api_v0_client.rb, line 5240
def get_webhooks_by_organization(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_webhooks_by_organization_and_id(organization, id) click to toggle source

Returns information about a specific webhook

# File lib/flow_commerce/flow_api_v0_client.rb, line 5262
def get_webhooks_by_organization_and_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_channel_and_webhooks_by_channel(channel, webhook_form) click to toggle source

Create a new webhook for a channel

# File lib/flow_commerce/flow_api_v0_client.rb, line 5207
def post_channel_and_webhooks_by_channel(channel, webhook_form)
  HttpClient::Preconditions.assert_class('channel', channel, String)
  (x = webhook_form; x.is_a?(::Io::Flow::V0::Models::WebhookForm) ? x : ::Io::Flow::V0::Models::WebhookForm.new(x))
  r = @client.request("/channel/#{CGI.escape(channel)}/webhooks").with_json(webhook_form.to_json).post
  ::Io::Flow::V0::Models::Webhook.new(r)
end
post_webhooks_by_organization(organization, webhook_form) click to toggle source

Create a new webhook

# File lib/flow_commerce/flow_api_v0_client.rb, line 5254
def post_webhooks_by_organization(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_channel_and_webhooks_by_channel_and_id(channel, id, webhook_form) click to toggle source

Update an existing channel webhook

# File lib/flow_commerce/flow_api_v0_client.rb, line 5223
def put_channel_and_webhooks_by_channel_and_id(channel, id, webhook_form)
  HttpClient::Preconditions.assert_class('channel', channel, 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("/channel/#{CGI.escape(channel)}/webhooks/#{CGI.escape(id)}").with_json(webhook_form.to_json).put
  ::Io::Flow::V0::Models::Webhook.new(r)
end
put_webhooks_by_organization_and_id(organization, id, webhook_form) click to toggle source

Update an existing webhook

# File lib/flow_commerce/flow_api_v0_client.rb, line 5270
def put_webhooks_by_organization_and_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