Class: Io::Flow::V0::Clients::OrderBuilders

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ OrderBuilders

Returns a new instance of OrderBuilders.



2077
2078
2079
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2077

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#delete_lines_by_number_and_id(organization, number, id) ⇒ Object

Deletes line item in the order specifed by the line item id.



2244
2245
2246
2247
2248
2249
2250
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2244

def delete_lines_by_number_and_id(organization, number, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/lines/#{CGI.escape(id)}").delete
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#get_by_number(organization, number, incoming = {}) ⇒ Object

Returns information about a specific order and any errors associated with the order.



2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2118

def get_by_number(organization, number, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, 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) }),
    :romanize => (x = opts.delete(:romanize); x.nil? ? nil : HttpClient::Preconditions.assert_class('romanize', x, Array).map { |v| HttpClient::Preconditions.assert_class('romanize', v, String) }),
    :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)}/order/builders/#{CGI.escape(number)}").with_query(query).get
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#post(organization, order_put_form, incoming = {}) ⇒ Object



2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2081

def post(organization, order_put_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', x, String)),
    :country => (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String)),
    :ip => (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String)),
    :currency => (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, String)),
    :language => (x = opts.delete(:language); x.nil? ? nil : HttpClient::Preconditions.assert_class('language', 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) }),
    :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String))
  }.delete_if { |k, v| v.nil? }
  (x = order_put_form; x.is_a?(::Io::Flow::V0::Models::OrderPutForm) ? x : ::Io::Flow::V0::Models::OrderPutForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders").with_query(query).with_json(order_put_form.to_json).post
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#post_lines_by_number(organization, number, line_item_form) ⇒ Object

Adds a line item to the order.



2216
2217
2218
2219
2220
2221
2222
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2216

def post_lines_by_number(organization, number, line_item_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  (x = line_item_form; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/lines").with_json(line_item_form.to_json).post
  ::Io::Flow::V0::Models::Order.new(r)
end

#put_attributes_by_number(organization, number, order_builder_attributes_form, incoming = {}) ⇒ Object



2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2149

def put_attributes_by_number(organization, number, order_builder_attributes_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, 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 = order_builder_attributes_form; x.is_a?(::Io::Flow::V0::Models::OrderBuilderAttributesForm) ? x : ::Io::Flow::V0::Models::OrderBuilderAttributesForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/attributes").with_query(query).with_json(order_builder_attributes_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#put_by_number(organization, number, order_put_form, incoming = {}) ⇒ Object



2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2131

def put_by_number(organization, number, order_put_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', x, String)),
    :country => (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String)),
    :ip => (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String)),
    :currency => (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, String)),
    :language => (x = opts.delete(:language); x.nil? ? nil : HttpClient::Preconditions.assert_class('language', 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) }),
    :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String))
  }.delete_if { |k, v| v.nil? }
  (x = order_put_form; x.is_a?(::Io::Flow::V0::Models::OrderPutForm) ? x : ::Io::Flow::V0::Models::OrderPutForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}").with_query(query).with_json(order_put_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#put_carts_by_number(organization, number, order_put_form, incoming = {}) ⇒ Object



2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2098

def put_carts_by_number(organization, number, order_put_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', x, String)),
    :country => (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String)),
    :ip => (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String)),
    :currency => (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, String)),
    :language => (x = opts.delete(:language); x.nil? ? nil : HttpClient::Preconditions.assert_class('language', 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) }),
    :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String))
  }.delete_if { |k, v| v.nil? }
  (x = order_put_form; x.is_a?(::Io::Flow::V0::Models::OrderPutForm) ? x : ::Io::Flow::V0::Models::OrderPutForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/carts/#{CGI.escape(number)}").with_query(query).with_json(order_put_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#put_country_by_number(organization, number, order_builder_destination_country_form, incoming = {}) ⇒ Object



2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2162

def put_country_by_number(organization, number, order_builder_destination_country_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, 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 = order_builder_destination_country_form; x.is_a?(::Io::Flow::V0::Models::OrderBuilderDestinationCountryForm) ? x : ::Io::Flow::V0::Models::OrderBuilderDestinationCountryForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/country").with_query(query).with_json(order_builder_destination_country_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#put_destination_by_number(organization, number, order_builder_destination_form, incoming = {}) ⇒ Object



2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2175

def put_destination_by_number(organization, number, order_builder_destination_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, 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 = order_builder_destination_form; x.is_a?(::Io::Flow::V0::Models::OrderBuilderDestinationForm) ? x : ::Io::Flow::V0::Models::OrderBuilderDestinationForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/destination").with_query(query).with_json(order_builder_destination_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#put_duty_by_number(organization, number, order_builder_delivered_duty_form, incoming = {}) ⇒ Object



2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2188

def put_duty_by_number(organization, number, order_builder_delivered_duty_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, 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 = order_builder_delivered_duty_form; x.is_a?(::Io::Flow::V0::Models::OrderBuilderDeliveredDutyForm) ? x : ::Io::Flow::V0::Models::OrderBuilderDeliveredDutyForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/duty").with_query(query).with_json(order_builder_delivered_duty_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#put_invoice_and_address_by_number(organization, number, order_builder_customer_invoice_address_form, incoming = {}) ⇒ Object

Update the customer invoice address



2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2202

def put_invoice_and_address_by_number(organization, number, order_builder_customer_invoice_address_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, 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 = order_builder_customer_invoice_address_form; x.is_a?(::Io::Flow::V0::Models::OrderBuilderCustomerInvoiceAddressForm) ? x : ::Io::Flow::V0::Models::OrderBuilderCustomerInvoiceAddressForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/invoice/address").with_query(query).with_json(order_builder_customer_invoice_address_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

#put_lines_and_attributes_by_number_and_id(organization, number, id, line_item_attributes_form) ⇒ Object

Updates line item attributes in the order specifed by the line item id.



2253
2254
2255
2256
2257
2258
2259
2260
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2253

def put_lines_and_attributes_by_number_and_id(organization, number, id, line_item_attributes_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = line_item_attributes_form; x.is_a?(::Io::Flow::V0::Models::LineItemAttributesForm) ? x : ::Io::Flow::V0::Models::LineItemAttributesForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/lines/#{CGI.escape(id)}/attributes").with_json(line_item_attributes_form.to_json).put
  ::Io::Flow::V0::Models::Order.new(r)
end

#put_lines_and_quantity_by_number_and_id(organization, number, id, line_item_quantity_form) ⇒ Object

Updates line item quantity in the order specifed by the line item id.



2263
2264
2265
2266
2267
2268
2269
2270
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2263

def put_lines_and_quantity_by_number_and_id(organization, number, id, line_item_quantity_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = line_item_quantity_form; x.is_a?(::Io::Flow::V0::Models::LineItemQuantityForm) ? x : ::Io::Flow::V0::Models::LineItemQuantityForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/lines/#{CGI.escape(id)}/quantity").with_json(line_item_quantity_form.to_json).put
  ::Io::Flow::V0::Models::Order.new(r)
end

#put_lines_by_number(organization, number, line_item_forms) ⇒ Object

Replaces all line items in the order.



2225
2226
2227
2228
2229
2230
2231
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2225

def put_lines_by_number(organization, number, line_item_forms)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  HttpClient::Preconditions.assert_class('line_item_forms', line_item_forms, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) }
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/lines").with_json(line_item_forms.map { |o| o.to_hash }.to_json).put
  ::Io::Flow::V0::Models::Order.new(r)
end

#put_lines_by_number_and_id(organization, number, id, line_item_form) ⇒ Object

Replaces line item in the order specifed by the line item id.



2234
2235
2236
2237
2238
2239
2240
2241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2234

def put_lines_by_number_and_id(organization, number, id, line_item_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = line_item_form; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/lines/#{CGI.escape(id)}").with_json(line_item_form.to_json).put
  ::Io::Flow::V0::Models::Order.new(r)
end

#put_tax_and_registration_by_number(organization, number, tax_registration_form, incoming = {}) ⇒ Object

Validates a tax registration number, proxying to underlying services and recording the result on the order.



2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2274

def put_tax_and_registration_by_number(organization, number, tax_registration_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, 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 = tax_registration_form; x.is_a?(::Io::Flow::V0::Models::TaxRegistrationForm) ? x : ::Io::Flow::V0::Models::TaxRegistrationForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/tax/registration").with_query(query).with_json(tax_registration_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end