Class: Io::Flow::V0::Clients::Orders
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Orders
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_number(organization, number) ⇒ Object
Delete an order.
- #delete_tax_and_registration_by_number_and_key(organization, number, key) ⇒ Object
-
#get(organization, incoming = {}) ⇒ Object
Search orders.
-
#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.
-
#get_by_number(organization, number, incoming = {}) ⇒ Object
Returns information about a specific order.
-
#get_identifier_by_identifier(organization, identifier, incoming = {}) ⇒ Object
Returns information about a specific order using an identifier number.
-
#get_status_and_fraud_by_number(organization, number) ⇒ Object
Retrieve the current fraud status for an order.
-
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each order, including deletion.
-
#initialize(client) ⇒ Orders
constructor
A new instance of Orders.
-
#post(organization, order_form, incoming = {}) ⇒ Object
Create an order, using the localized information from the experience selected by the query parameters.
-
#post_authorizations_by_number(organization, number, authorization_form, incoming = {}) ⇒ Object
Creates an authorization, automatically associating to this order.
-
#post_labels_and_documents_and_invoice_by_number(organization, number) ⇒ Object
Generate a commercial invoice for the order without providing a label.
-
#post_payments_by_number(organization, number, authorization) ⇒ Object
Creates an order payment by applying the authorization to the order.
- #post_service_and_changes_by_number(organization, number, order_service_change_form) ⇒ Object
-
#post_submissions(organization, order_with_discounts_form, incoming = {}) ⇒ Object
Submits an order.
-
#put_by_number(organization, number, order_put_form, incoming = {}) ⇒ Object
Upserts an order.
-
#put_destination_by_number(organization, number, order_destination_put_form, incoming = {}) ⇒ Object
Updates an order’s destination address.
- #put_inventory_and_reservations_by_number(organization, number, incoming = {}) ⇒ Object
-
#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.
-
#put_submissions_by_number(organization, number, order_submission_form, incoming = {}) ⇒ Object
Submits an order.
-
#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.
Constructor Details
#initialize(client) ⇒ Orders
Returns a new instance of Orders.
1797 1798 1799 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1797 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).
1931 1932 1933 1934 1935 1936 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1931 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
2049 2050 2051 2052 2053 2054 2055 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2049 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.
1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1802 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_by_number(organization, number) ⇒ Object
Order allocations provide a granular view of an order that is targeted for accounting / financial views of an order
1940 1941 1942 1943 1944 1945 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1940 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.
1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1894 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
1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1845 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.
2058 2059 2060 2061 2062 2063 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2058 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
1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1878 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
1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1826 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.
1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1948 def (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) }), :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String)) }.delete_if { |k, v| v.nil? } (x = ; 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(.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.
2066 2067 2068 2069 2070 2071 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2066 def post_labels_and_documents_and_invoice_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)}/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.
1986 1987 1988 1989 1990 1991 1992 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1986 def post_payments_by_number(organization, number, ) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) (x = ; 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(.to_json).post ::Io::Flow::V0::Models::Order.new(r) end |
#post_service_and_changes_by_number(organization, number, order_service_change_form) ⇒ Object
2010 2011 2012 2013 2014 2015 2016 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2010 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.
1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1862 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
1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1910 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
1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1962 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
1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1974 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.
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1996 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.
2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2022 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.
2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2037 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 |