Class: Io::Flow::V0::Clients::HarmonizedItems
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::HarmonizedItems
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_number(organization, number) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_number(organization, number) ⇒ Object
-
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion.
-
#initialize(client) ⇒ HarmonizedItems
constructor
A new instance of HarmonizedItems.
- #post(organization, harmonized_item_form) ⇒ Object
-
#put_by_number(organization, number, harmonized_item_put_form) ⇒ Object
Create or update an item to harmonize.
Constructor Details
#initialize(client) ⇒ HarmonizedItems
1979 1980 1981 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1979 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_number(organization, number) ⇒ Object
2020 2021 2022 2023 2024 2025 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2020 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)}/harmonization/items/#{CGI.escape(number)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1983 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) }), :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? ? "name" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/harmonization/items").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::HarmonizedItem.new(x) } end |
#get_by_number(organization, number) ⇒ Object
2004 2005 2006 2007 2008 2009 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2004 def get_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/harmonization/items/#{CGI.escape(number)}").get ::Io::Flow::V0::Models::HarmonizedItem.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2028 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) }), :item_id => (x = opts.delete(:item_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('item_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('item_id', v, 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? ? "journal_timestamp" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/harmonization/items/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::HarmonizedItemVersion.new(x) } end |
#post(organization, harmonized_item_form) ⇒ Object
1997 1998 1999 2000 2001 2002 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1997 def post(organization, harmonized_item_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = harmonized_item_form; x.is_a?(::Io::Flow::V0::Models::HarmonizedItemForm) ? x : ::Io::Flow::V0::Models::HarmonizedItemForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/harmonization/items").with_json(harmonized_item_form.to_json).post ::Io::Flow::V0::Models::HarmonizedItem.new(r) end |
#put_by_number(organization, number, harmonized_item_put_form) ⇒ Object
Create or update an item to harmonize
2012 2013 2014 2015 2016 2017 2018 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2012 def put_by_number(organization, number, harmonized_item_put_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) (x = harmonized_item_put_form; x.is_a?(::Io::Flow::V0::Models::HarmonizedItemPutForm) ? x : ::Io::Flow::V0::Models::HarmonizedItemPutForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/harmonization/items/#{CGI.escape(number)}").with_json(harmonized_item_put_form.to_json).put ::Io::Flow::V0::Models::HarmonizedItem.new(r) end |