Class: Io::Flow::V0::Clients::CreditPayments
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::CreditPayments
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_key(organization, key) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_key(organization, key, incoming = {}) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ CreditPayments
constructor
A new instance of CreditPayments.
- #post(organization, credit_payment_form, incoming = {}) ⇒ Object
- #put_by_key(organization, key, credit_payment_form, incoming = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ CreditPayments
Returns a new instance of CreditPayments.
677 678 679 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 677 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
745 746 747 748 749 750 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 745 def delete_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/credit/payments/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 681 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) }), :order_number => (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', 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), :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/credit/payments").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::CreditPayment.new(x) } end |
#get_by_key(organization, key, incoming = {}) ⇒ Object
722 723 724 725 726 727 728 729 730 731 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 722 def get_by_key(organization, key, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/credit/payments/#{CGI.escape(key)}").with_query(query).get ::Io::Flow::V0::Models::CreditPayment.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
708 709 710 711 712 713 714 715 716 717 718 719 720 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 708 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, 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) }), :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)}/credit/payments/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::CreditPaymentVersion.new(x) } end |
#post(organization, credit_payment_form, incoming = {}) ⇒ Object
697 698 699 700 701 702 703 704 705 706 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 697 def post(organization, credit_payment_form, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } (x = credit_payment_form; x.is_a?(::Io::Flow::V0::Models::CreditPaymentForm) ? x : ::Io::Flow::V0::Models::CreditPaymentForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/credit/payments").with_query(query).with_json(credit_payment_form.to_json).post ::Io::Flow::V0::Models::CreditPayment.new(r) end |
#put_by_key(organization, key, credit_payment_form, incoming = {}) ⇒ Object
733 734 735 736 737 738 739 740 741 742 743 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 733 def put_by_key(organization, key, credit_payment_form, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } (x = credit_payment_form; x.is_a?(::Io::Flow::V0::Models::CreditPaymentForm) ? x : ::Io::Flow::V0::Models::CreditPaymentForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/credit/payments/#{CGI.escape(key)}").with_query(query).with_json(credit_payment_form.to_json).put ::Io::Flow::V0::Models::CreditPayment.new(r) end |