Class: Io::Flow::V0::Clients::Returns
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Returns
- 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) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ Returns
constructor
A new instance of Returns.
- #post(organization, return_form) ⇒ Object
- #put_by_key(organization, key, return_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ Returns
Returns a new instance of Returns.
4093 4094 4095 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4093 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
4151 4152 4153 4154 4155 4156 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4151 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)}/returns/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4097 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, Array).map { |v| HttpClient::Preconditions.assert_class('order_number', v, String) }), :flow_tracking_number => (x = opts.delete(:flow_tracking_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('flow_tracking_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('flow_tracking_number', v, String) }), :carrier_tracking_number => (x = opts.delete(:carrier_tracking_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('carrier_tracking_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('carrier_tracking_number', v, String) }), :service => (x = opts.delete(:service); x.nil? ? nil : HttpClient::Preconditions.assert_class('service', x, Array).map { |v| HttpClient::Preconditions.assert_class('service', 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? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/returns").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Return.new(x) } end |
#get_by_key(organization, key) ⇒ Object
4136 4137 4138 4139 4140 4141 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4136 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)}/returns/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::Return.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4122 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)}/returns/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ReturnVersion.new(x) } end |
#post(organization, return_form) ⇒ Object
4115 4116 4117 4118 4119 4120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4115 def post(organization, return_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = return_form; x.is_a?(::Io::Flow::V0::Models::ReturnForm) ? x : ::Io::Flow::V0::Models::ReturnForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/returns").with_json(return_form.to_json).post ::Io::Flow::V0::Models::Return.new(r) end |
#put_by_key(organization, key, return_form) ⇒ Object
4143 4144 4145 4146 4147 4148 4149 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4143 def put_by_key(organization, key, return_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = return_form; x.is_a?(::Io::Flow::V0::Models::ReturnForm) ? x : ::Io::Flow::V0::Models::ReturnForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/returns/#{CGI.escape(key)}").with_json(return_form.to_json).put ::Io::Flow::V0::Models::Return.new(r) end |