Class: Io::Flow::V0::Clients::Refunds
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Refunds
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(organization, incoming = {}) ⇒ Object
-
#get_by_key(organization, key) ⇒ Object
Returns information about a specific refund.
-
#get_summary_by_order_number(organization, order_number) ⇒ Object
Returns a refund order summary for the specified order.
-
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion.
-
#initialize(client) ⇒ Refunds
constructor
A new instance of Refunds.
-
#post(organization, refund_form) ⇒ Object
Create a new refund.
Constructor Details
#initialize(client) ⇒ Refunds
Returns a new instance of Refunds.
2524 2525 2526 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2524 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2528 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) }), :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)), :capture_id => (x = opts.delete(:capture_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('capture_id', x, String)), :capture_key => (x = opts.delete(:capture_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('capture_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)}/refunds").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Refund.new(x) } end |
#get_by_key(organization, key) ⇒ Object
Returns information about a specific refund.
2555 2556 2557 2558 2559 2560 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2555 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)}/refunds/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::Refund.new(r) end |
#get_summary_by_order_number(organization, order_number) ⇒ Object
Returns a refund order summary for the specified order.
2563 2564 2565 2566 2567 2568 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2563 def get_summary_by_order_number(organization, order_number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('order_number', order_number, String) r = @client.request("/#{CGI.escape(organization)}/refunds/summary/#{CGI.escape(order_number)}").get ::Io::Flow::V0::Models::RefundOrderSummary.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2571 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) }), :refund_id => (x = opts.delete(:refund_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('refund_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('refund_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)}/refunds/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::RefundVersion.new(x) } end |
#post(organization, refund_form) ⇒ Object
Create a new refund.
2547 2548 2549 2550 2551 2552 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2547 def post(organization, refund_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = refund_form; x.is_a?(::Io::Flow::V0::Models::RefundForm) ? x : ::Io::Flow::V0::Models::RefundForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/refunds").with_json(refund_form.to_json).post ::Io::Flow::V0::Models::Refund.new(r) end |