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, incoming = {}) ⇒ 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.
1055 1056 1057 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1055 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key, incoming = {}) ⇒ Object
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1125 def delete_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 = { :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String)) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/credit/payments/#{CGI.escape(key)}").with_query(query).delete nil end |
#get(organization, incoming = {}) ⇒ Object
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1059 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
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1101 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
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1087 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
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1075 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) }), :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, 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
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1112 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) }), :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, 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 |