Class: Io::Flow::V0::Clients::ChannelTransactions

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ChannelTransactions

Returns a new instance of ChannelTransactions.



6123
6124
6125
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6123

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

Instance Method Details

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



6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6127

def get(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) }),
    :statement_id => (x = opts.delete(:statement_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('statement_id', x, String)),
    :since => (x = opts.delete(:since); x.nil? ? nil : HttpClient::Preconditions.assert_class('since', HttpClient::Helper.to_date_time_iso8601(x), DateTime)),
    :updated_since => (x = opts.delete(:updated_since); x.nil? ? nil : HttpClient::Preconditions.assert_class('updated_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("/channel/#{CGI.escape(channel)}/billing/transactions").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::ChannelTransaction.new(x) }
end

#get_by_id(channel, id) ⇒ Object



6143
6144
6145
6146
6147
6148
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6143

def get_by_id(channel, id)
  HttpClient::Preconditions.assert_class('channel', channel, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/channel/#{CGI.escape(channel)}/billing/transactions/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::ChannelTransaction.new(r)
end