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.
1070 1071 1072 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1070 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_number(organization, number) ⇒ Object
1111 1112 1113 1114 1115 1116 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1111 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
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1074 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
1096 1097 1098 1099 1100 1101 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1096 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
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1118 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
1089 1090 1091 1092 1093 1094 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1089 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
1103 1104 1105 1106 1107 1108 1109 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1103 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 |