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.



2246
2247
2248
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2246

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.



2426
2427
2428
2429
2430
2431
2432
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2426

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.



2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2287

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



2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2250

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.



2398
2399
2400
2401
2402
2403
2404
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2398

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



2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2318

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



2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2300

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



2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2267

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



2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2331

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_customer_by_number(organization, number, order_builder_customer_form, incoming = {}) ⇒ Object



2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2344

def put_customer_by_number(organization, number, order_builder_customer_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_form; x.is_a?(::Io::Flow::V0::Models::OrderBuilderCustomerForm) ? x : ::Io::Flow::V0::Models::OrderBuilderCustomerForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/customer").with_query(query).with_json(order_builder_customer_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.new(r)
end

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



2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2357

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



2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2370

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



2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2384

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.



2435
2436
2437
2438
2439
2440
2441
2442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2435

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.



2445
2446
2447
2448
2449
2450
2451
2452
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2445

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.



2407
2408
2409
2410
2411
2412
2413
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2407

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.



2416
2417
2418
2419
2420
2421
2422
2423
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2416

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_selections_by_number(organization, number, order_builder_selections_form, incoming = {}) ⇒ Object



2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2454

def put_selections_by_number(organization, number, order_builder_selections_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_selections_form; x.is_a?(::Io::Flow::V0::Models::OrderBuilderSelectionsForm) ? x : ::Io::Flow::V0::Models::OrderBuilderSelectionsForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/order/builders/#{CGI.escape(number)}/selections").with_query(query).with_json(order_builder_selections_form.to_json).put
  ::Io::Flow::V0::Models::OrderBuilder.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.



2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2469

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