Class: Io::Flow::V0::Clients::WebhookDeliveries

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WebhookDeliveries

Returns a new instance of WebhookDeliveries.



5290
5291
5292
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5290

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#get(organization, incoming = {}) ⇒ Object

Returns deliveries for an organization’s webhook



5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5295

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) }),
    :webhook_id => (x = opts.delete(:webhook_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('webhook_id', x, String)),
    :since => (x = opts.delete(:since); x.nil? ? nil : HttpClient::Preconditions.assert_class('since', HttpClient::Helper.to_date_time_iso8601(x), DateTime)),
    :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)}/webhook/deliveries").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::WebhookDelivery.new(x) }
end

#get_by_id(organization, id) ⇒ Object

Returns information about a specific webhook delivery



5311
5312
5313
5314
5315
5316
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5311

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)}/webhook/deliveries/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::WebhookDelivery.new(r)
end

#post_requests_by_id(organization, id) ⇒ Object

Redeliver a webhook request. This created a new webhook request to requeue delivery



5320
5321
5322
5323
5324
5325
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5320

def post_requests_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/webhook/deliveries/#{CGI.escape(id)}/requests").post
  ::Io::Flow::V0::Models::WebhookRequest.new(r)
end