Class: Io::Flow::V0::Clients::Captures

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Captures

Returns a new instance of Captures.



3363
3364
3365
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3363

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

Instance Method Details

#delete_identifiers_by_key_and_identifier(organization, key, identifier) ⇒ Object



3440
3441
3442
3443
3444
3445
3446
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3440

def delete_identifiers_by_key_and_identifier(organization, key, identifier)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  HttpClient::Preconditions.assert_class('identifier', identifier, String)
  r = @client.request("/#{CGI.escape(organization)}/captures/#{CGI.escape(key)}/identifiers/#{CGI.escape(identifier)}").delete
  nil
end

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



3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3367

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) }),
    :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, Array).map { |v| HttpClient::Preconditions.assert_class('key', v, String) }),
    :identifier => (x = opts.delete(:identifier); x.nil? ? nil : HttpClient::Preconditions.assert_class('identifier', x, String)),
    :authorization_id => (x = opts.delete(:authorization_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('authorization_id', x, String)),
    :authorization_key => (x = opts.delete(:authorization_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('authorization_key', x, 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)}/captures").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::Capture.new(x) }
end

#get_by_key(organization, key) ⇒ Object

Returns information about a specific capture.



3408
3409
3410
3411
3412
3413
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3408

def get_by_key(organization, key)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  r = @client.request("/#{CGI.escape(organization)}/captures/#{CGI.escape(key)}").get
  ::Io::Flow::V0::Models::Capture.new(r)
end

#get_identifiers_by_key(organization, key, incoming = {}) ⇒ Object



3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3415

def get_identifiers_by_key(organization, key, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, 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) }),
    :identifier => (x = opts.delete(:identifier); x.nil? ? nil : HttpClient::Preconditions.assert_class('identifier', x, 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? ? "name" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/captures/#{CGI.escape(key)}/identifiers").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::CaptureIdentifier.new(x) }
end

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

Provides visibility into recent changes of each object, including deletion



3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3393

def get_versions(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, Integer) }),
    :capture_id => (x = opts.delete(:capture_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('capture_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('capture_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? ? "journal_timestamp" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/captures/versions").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::CaptureVersion.new(x) }
end

#post(organization, capture_form) ⇒ Object

Create a new capture.



3385
3386
3387
3388
3389
3390
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3385

def post(organization, capture_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = capture_form; x.is_a?(::Io::Flow::V0::Models::CaptureForm) ? x : ::Io::Flow::V0::Models::CaptureForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/captures").with_json(capture_form.to_json).post
  ::Io::Flow::V0::Models::Capture.new(r)
end

#put_identifiers_by_key_and_identifier(organization, key, identifier, identifier_form) ⇒ Object

Create a new identifier for this capture



3431
3432
3433
3434
3435
3436
3437
3438
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3431

def put_identifiers_by_key_and_identifier(organization, key, identifier, identifier_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  HttpClient::Preconditions.assert_class('identifier', identifier, String)
  (x = identifier_form; x.is_a?(::Io::Flow::V0::Models::IdentifierForm) ? x : ::Io::Flow::V0::Models::IdentifierForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/captures/#{CGI.escape(key)}/identifiers/#{CGI.escape(identifier)}").with_json(identifier_form.to_json).put
  ::Io::Flow::V0::Models::CaptureIdentifier.new(r)
end