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.



1941
1942
1943
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1941

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).



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

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



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

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.



1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1946

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.



2092
2093
2094
2095
2096
2097
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2092

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



2084
2085
2086
2087
2088
2089
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2084

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.



2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2038

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



1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1989

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.



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

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



2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2022

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



1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1970

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.



2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2100

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.



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

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.



2137
2138
2139
2140
2141
2142
2143
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2137

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.



2162
2163
2164
2165
2166
2167
2168
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2162

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.



2171
2172
2173
2174
2175
2176
2177
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2171

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



2179
2180
2181
2182
2183
2184
2185
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2179

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.



2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2006

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



2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2054

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



2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2113

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



2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2125

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.



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

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.



2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2191

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.



2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2206

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