Class: Io::Flow::V0::Clients::SyncPendingRecords

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ SyncPendingRecords

Returns a new instance of SyncPendingRecords.



8677
8678
8679
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8677

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

Instance Method Details

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



8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8681

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) }),
    :stream_key => (x = opts.delete(:stream_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('stream_key', x, String)),
    :value => (x = opts.delete(:value); x.nil? ? nil : HttpClient::Preconditions.assert_class('value', x, String)),
    :system => (x = opts.delete(:system); x.nil? ? nil : HttpClient::Preconditions.assert_class('system', 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)}/sync/pending/records").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::SyncPendingRecord.new(x) }
end