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.
1223 1224 1225 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1223 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_number(organization, number) ⇒ Object
1264 1265 1266 1267 1268 1269 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1264 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
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1227 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
1249 1250 1251 1252 1253 1254 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1249 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
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1271 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
1242 1243 1244 1245 1246 1247 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1242 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
1256 1257 1258 1259 1260 1261 1262 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1256 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 |