Class: Io::Flow::V0::Clients::OrderIdentifiers
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::OrderIdentifiers
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_number(organization, number) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_number(organization, number) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ OrderIdentifiers
constructor
A new instance of OrderIdentifiers.
- #post(organization, order_identifier_form) ⇒ Object
- #put_by_number(organization, number, order_identifier_put_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ OrderIdentifiers
Returns a new instance of OrderIdentifiers.
1157 1158 1159 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1157 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_number(organization, number) ⇒ Object
1198 1199 1200 1201 1202 1203 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1198 def delete_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/order-identifiers/#{CGI.escape(number)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1161 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) }), :number => (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, Array).map { |v| HttpClient::Preconditions.assert_class('number', 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) }), :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)}/order-identifiers").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::OrderIdentifier.new(x) } end |
#get_by_number(organization, number) ⇒ Object
1183 1184 1185 1186 1187 1188 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1183 def get_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/order-identifiers/#{CGI.escape(number)}").get ::Io::Flow::V0::Models::OrderIdentifier.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1205 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) }), :number => (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, Array).map { |v| HttpClient::Preconditions.assert_class('number', 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) }), :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)}/order-identifiers/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::OrderIdentifierVersion.new(x) } end |
#post(organization, order_identifier_form) ⇒ Object
1176 1177 1178 1179 1180 1181 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1176 def post(organization, order_identifier_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = order_identifier_form; x.is_a?(::Io::Flow::V0::Models::OrderIdentifierForm) ? x : ::Io::Flow::V0::Models::OrderIdentifierForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/order-identifiers").with_json(order_identifier_form.to_json).post ::Io::Flow::V0::Models::OrderIdentifier.new(r) end |
#put_by_number(organization, number, order_identifier_put_form) ⇒ Object
1190 1191 1192 1193 1194 1195 1196 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1190 def put_by_number(organization, number, order_identifier_put_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) (x = order_identifier_put_form; x.is_a?(::Io::Flow::V0::Models::OrderIdentifierPutForm) ? x : ::Io::Flow::V0::Models::OrderIdentifierPutForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/order-identifiers/#{CGI.escape(number)}").with_json(order_identifier_put_form.to_json).put ::Io::Flow::V0::Models::OrderIdentifier.new(r) end |