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.



1989
1990
1991
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1989

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.



2155
2156
2157
2158
2159
2160
2161
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2155

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.



2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2030

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



1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1993

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.



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

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



2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2060

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



2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2042

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



2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2010

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



2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2073

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



2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2086

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



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

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



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

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.



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

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.



2174
2175
2176
2177
2178
2179
2180
2181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2174

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.



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

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.



2145
2146
2147
2148
2149
2150
2151
2152
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2145

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.



2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2185

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