Class: Io::Flow::V0::Clients::Statements
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Statements
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
-
#initialize(client) ⇒ Statements
constructor
A new instance of Statements.
Constructor Details
#initialize(client) ⇒ Statements
Returns a new instance of Statements.
8626 8627 8628 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8626 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8630 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) }), :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)}/billing/statements").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Statement.new(x) } end |
#get_by_id(organization, id) ⇒ Object
8644 8645 8646 8647 8648 8649 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8644 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)}/billing/statements/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Statement.new(r) end |