Class: Io::Flow::V0::Clients::Orders

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Orders

Returns a new instance of Orders.



6812
6813
6814
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6812

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

Instance Method Details

#delete_by_number(organization, number) ⇒ Object

Delete an order. Note that production orders that have already been submitted cannot be deleted (you will see a 422 response in these cases).



6954
6955
6956
6957
6958
6959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6954

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)}/orders/#{CGI.escape(number)}").delete
  nil
end

#delete_tax_and_registration_by_number_and_key(organization, number, key) ⇒ Object



7097
7098
7099
7100
7101
7102
7103
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7097

def delete_tax_and_registration_by_number_and_key(organization, number, key)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/tax/registration/#{CGI.escape(key)}").delete
  nil
end

#get(organization, incoming = {}) ⇒ Object

Search orders. Always paginated.



6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6825

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) }),
    :identifier => (x = opts.delete(:identifier); x.nil? ? nil : HttpClient::Preconditions.assert_class('identifier', x, String)),
    :status => (x = opts.delete(:status); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderStatus) ? x : ::Io::Flow::V0::Models::OrderStatus.apply(x)).value),
    :customer_number => (x = opts.delete(:customer_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('customer_number', x, String)),
    :submitted_at_on_or_after => (x = opts.delete(:submitted_at_on_or_after); x.nil? ? nil : HttpClient::Preconditions.assert_class('submitted_at_on_or_after', HttpClient::Helper.to_date_time_iso8601(x), DateTime)),
    :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)),
    :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),
    :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) })
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/orders").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::Order.new(x) }
end

#get_allocations_and_summaries_and_line_by_number(organization, number) ⇒ Object

A simplified, line-based view of order financials.



6971
6972
6973
6974
6975
6976
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6971

def get_allocations_and_summaries_and_line_by_number(organization, number)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/allocations/summaries/line").get
  ::Io::Flow::V0::Models::AllocationLineSummary.new(r)
end

#get_allocations_by_number(organization, number) ⇒ Object

Order allocations provide a granular view of an order that is targeted for accounting / financial views of an order



6963
6964
6965
6966
6967
6968
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6963

def get_allocations_by_number(organization, number)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/allocations").get
  ::Io::Flow::V0::Models::AllocationV2.new(r)
end

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

Returns information about a specific order.



6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6917

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)}/orders/#{CGI.escape(number)}").with_query(query).get
  ::Io::Flow::V0::Models::Order.new(r)
end

#get_identifier_by_identifier(organization, identifier, incoming = {}) ⇒ Object

Returns information about a specific order using an identifier number



6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6868

def get_identifier_by_identifier(organization, identifier, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('identifier', identifier, 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)}/orders/identifier/#{CGI.escape(identifier)}").with_query(query).get
  ::Io::Flow::V0::Models::Order.new(r)
end

#get_status_and_fraud_by_number(organization, number) ⇒ Object

Retrieve the current fraud status for an order.



6817
6818
6819
6820
6821
6822
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6817

def get_status_and_fraud_by_number(organization, number)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/status/fraud").get
  ::Io::Flow::V0::Models::OrderFraudStatus.new(r)
end

#get_versions(organization, incoming = {}) ⇒ Object

Provides visibility into recent changes of each order, including deletion



6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6901

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) }),
    :journal_timestamp_on_or_after => (x = opts.delete(:journal_timestamp_on_or_after); x.nil? ? nil : HttpClient::Preconditions.assert_class('journal_timestamp_on_or_after', HttpClient::Helper.to_date_time_iso8601(x), DateTime)),
    :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)}/orders/versions").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::OrderVersion.new(x) }
end

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

Create an order, using the localized information from the experience selected by the query parameters. Note the order must be submitted before its expiration



6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6849

def post(organization, order_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) }),
    :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? }
  (x = order_form; x.is_a?(::Io::Flow::V0::Models::OrderForm) ? x : ::Io::Flow::V0::Models::OrderForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/orders").with_query(query).with_json(order_form.to_json).post
  ::Io::Flow::V0::Models::Order.new(r)
end

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

Creates an authorization, automatically associating to this order.



6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6979

def (organization, number, authorization_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String))
  }.delete_if { |k, v| v.nil? }
  (x = authorization_form; x.is_a?(::Io::Flow::V0::Models::AuthorizationForm) ? x : ::Io::Flow::V0::Models::AuthorizationForm.from_json(x))
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/authorizations").with_query(query).with_json(authorization_form.to_json).post
  ::Io::Flow::V0::Models::Authorization.from_json(r)
end

#post_labels_and_documents_and_invoice_by_number(organization, number) ⇒ Object

Generate a commercial invoice for the order without providing a label.



7106
7107
7108
7109
7110
7111
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7106

def (organization, number)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/labels/documents/invoice").post
  ::Io::Flow::V0::Models::ShippingLabelDocument.new(r)
end

#post_payments_by_number(organization, number, authorization) ⇒ Object

Creates an order payment by applying the authorization to the order.



7016
7017
7018
7019
7020
7021
7022
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7016

def post_payments_by_number(organization, number, authorization)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  (x = authorization; x.is_a?(::Io::Flow::V0::Models::Authorization) ? x : ::Io::Flow::V0::Models::Authorization.from_json(x))
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/payments").with_json(authorization.to_json).post
  ::Io::Flow::V0::Models::Order.new(r)
end

#post_refunds_and_summaries_by_number(organization, number, order_refund_summary_form) ⇒ Object

Returns a refund order summary for the specified order.



7041
7042
7043
7044
7045
7046
7047
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7041

def post_refunds_and_summaries_by_number(organization, number, order_refund_summary_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  (x = order_refund_summary_form; x.is_a?(::Io::Flow::V0::Models::OrderRefundSummaryForm) ? x : ::Io::Flow::V0::Models::OrderRefundSummaryForm.from_json(x))
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/refunds/summaries").with_json(order_refund_summary_form.to_json).post
  ::Io::Flow::V0::Models::OrderRefundSummary.new(r)
end

#post_replacements_by_number(organization, number, order_replacement_form) ⇒ Object

Creates a replacement order.



7050
7051
7052
7053
7054
7055
7056
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7050

def post_replacements_by_number(organization, number, order_replacement_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  (x = order_replacement_form; x.is_a?(::Io::Flow::V0::Models::OrderReplacementForm) ? x : ::Io::Flow::V0::Models::OrderReplacementForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/replacements").with_json(order_replacement_form.to_json).post
  ::Io::Flow::V0::Models::OrderReplacement.new(r)
end

#post_service_and_changes_by_number(organization, number, order_service_change_form) ⇒ Object



7058
7059
7060
7061
7062
7063
7064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7058

def post_service_and_changes_by_number(organization, number, order_service_change_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  (x = order_service_change_form; x.is_a?(::Io::Flow::V0::Models::OrderServiceChangeForm) ? x : ::Io::Flow::V0::Models::OrderServiceChangeForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/service/changes").with_json(order_service_change_form.to_json).post
  ::Io::Flow::V0::Models::OrderServiceChange.new(r)
end

#post_submissions(organization, order_with_discounts_form, incoming = {}) ⇒ Object

Submits an order. You will get a validation error if the order has already expired (and a new quote could not be automatically recreated for a lower or same price). This method is idempotent - submitting an order a second time has no effect.



6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6885

def post_submissions(organization, order_with_discounts_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, 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) }),
    :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', x, String)),
    :currency => (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, String)),
    :show_selections_only => (x = opts.delete(:show_selections_only); x.nil? ? nil : HttpClient::Preconditions.assert_boolean('show_selections_only', x)),
    :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String))
  }.delete_if { |k, v| v.nil? }
  (x = order_with_discounts_form; x.is_a?(::Io::Flow::V0::Models::OrderWithDiscountsForm) ? x : ::Io::Flow::V0::Models::OrderWithDiscountsForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/orders/submissions").with_query(query).with_json(order_with_discounts_form.to_json).post
  ::Io::Flow::V0::Models::Order.new(r)
end

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

Upserts an order. using the localized information from the experience selected by the query parameters. Note the order must be submitted before its expiration



6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6933

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) }),
    :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? }
  (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)}/orders/#{CGI.escape(number)}").with_query(query).with_json(order_put_form.to_json).put
  ::Io::Flow::V0::Models::Order.new(r)
end

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

Updates an order’s destination address



6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6992

def put_destination_by_number(organization, number, order_destination_put_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String))
  }.delete_if { |k, v| v.nil? }
  (x = order_destination_put_form; x.is_a?(::Io::Flow::V0::Models::OrderDestinationPutForm) ? x : ::Io::Flow::V0::Models::OrderDestinationPutForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/destination").with_query(query).with_json(order_destination_put_form.to_json).put
  ::Io::Flow::V0::Models::Order.new(r)
end

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



7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7004

def put_inventory_and_reservations_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 = {
    :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)}/orders/#{CGI.escape(number)}/inventory/reservations").with_query(query).put
  ::Io::Flow::V0::Models::Reservation.new(r)
end

#put_promotions_and_free_shipping_by_number_and_key(organization, number, key, free_shipping_order_promotion_form, incoming = {}) ⇒ Object

Creates a free shipping promotion for this order, automatically applying it to the order if the order meets the defined promotion trigger.



7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7026

def put_promotions_and_free_shipping_by_number_and_key(organization, number, key, free_shipping_order_promotion_form, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('number', number, String)
  HttpClient::Preconditions.assert_class('key', key, 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 = free_shipping_order_promotion_form; x.is_a?(::Io::Flow::V0::Models::FreeShippingOrderPromotionForm) ? x : ::Io::Flow::V0::Models::FreeShippingOrderPromotionForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/promotions/#{CGI.escape(key)}/free_shipping").with_query(query).with_json(free_shipping_order_promotion_form.to_json).put
  ::Io::Flow::V0::Models::FreeShippingOrderPromotion.new(r)
end

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

Submits an order. You will get a validation error if the order has already expired (and a new quote could not be automatically recreated for a lower or same price). This method is idempotent - submitting an order a second time has no effect.



7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7070

def put_submissions_by_number(organization, number, order_submission_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_submission_form; x.is_a?(::Io::Flow::V0::Models::OrderSubmissionForm) ? x : ::Io::Flow::V0::Models::OrderSubmissionForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/orders/#{CGI.escape(number)}/submissions").with_query(query).with_json(order_submission_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.



7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7085

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 = {
    :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)}/orders/#{CGI.escape(number)}/tax/registration").with_query(query).with_json(tax_registration_form.to_json).put
  ::Io::Flow::V0::Models::TaxRegistration.new(r)
end