Class: Io::Flow::V0::Clients::Payments
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Payments
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_id(organization, id) ⇒ Object
Deletes the specified payment.
- #get(organization, incoming = {}) ⇒ Object
-
#get_by_id(organization, id) ⇒ Object
Returns information about a specific payment.
-
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion.
-
#initialize(client) ⇒ Payments
constructor
A new instance of Payments.
-
#post(organization, payment_form) ⇒ Object
Create a new payment.
Constructor Details
#initialize(client) ⇒ Payments
Returns a new instance of Payments.
2293 2294 2295 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2293 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
Deletes the specified payment
2329 2330 2331 2332 2333 2334 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2329 def delete_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/payments/#{CGI.escape(id)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2297 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) }), :payment_method => (x = opts.delete(:payment_method); x.nil? ? nil : HttpClient::Preconditions.assert_class('payment_method', 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)}/payments").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Payment.from_json(x) } end |
#get_by_id(organization, id) ⇒ Object
Returns information about a specific payment.
2321 2322 2323 2324 2325 2326 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2321 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)}/payments/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Payment.from_json(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2337 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) }), :payment_id => (x = opts.delete(:payment_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('payment_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('payment_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)}/payments/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::PaymentVersion.new(x) } end |
#post(organization, payment_form) ⇒ Object
Create a new payment. Note that when using JSONP to submit a payment, you do not need to authenticate.
2313 2314 2315 2316 2317 2318 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2313 def post(organization, payment_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('payment_form', payment_form, ::Io::Flow::V0::Models::PaymentForm) r = @client.request("/#{CGI.escape(organization)}/payments").with_json(payment_form.to_json).post ::Io::Flow::V0::Models::Payment.from_json(r) end |