Class: Io::Flow::V0::Clients::Reversals
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Reversals
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(organization, incoming = {}) ⇒ Object
- #get_by_key(organization, key) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ Reversals
constructor
A new instance of Reversals.
- #post(organization, reversal_form) ⇒ Object
-
#put_by_key(organization, key, reversal_put_form) ⇒ Object
Try inserting or updating a new reversal.
Constructor Details
#initialize(client) ⇒ Reversals
Returns a new instance of Reversals.
2751 2752 2753 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2751 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2755 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)), :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)}/reversals").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Reversal.new(x) } end |
#get_by_key(organization, key) ⇒ Object
2778 2779 2780 2781 2782 2783 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2778 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)}/reversals/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::Reversal.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2795 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) }), :reversal_id => (x = opts.delete(:reversal_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('reversal_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('reversal_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)}/reversals/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ReversalVersion.new(x) } end |
#post(organization, reversal_form) ⇒ Object
2771 2772 2773 2774 2775 2776 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2771 def post(organization, reversal_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = reversal_form; x.is_a?(::Io::Flow::V0::Models::ReversalForm) ? x : ::Io::Flow::V0::Models::ReversalForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/reversals").with_json(reversal_form.to_json).post ::Io::Flow::V0::Models::Reversal.new(r) end |
#put_by_key(organization, key, reversal_put_form) ⇒ Object
Try inserting or updating a new reversal. Useful for retrying pending reversals
2787 2788 2789 2790 2791 2792 2793 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2787 def put_by_key(organization, key, reversal_put_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = reversal_put_form; x.is_a?(::Io::Flow::V0::Models::ReversalPutForm) ? x : ::Io::Flow::V0::Models::ReversalPutForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/reversals/#{CGI.escape(key)}").with_json(reversal_put_form.to_json).put ::Io::Flow::V0::Models::Reversal.new(r) end |