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
Returns a new instance of HarmonizedItems.
2081 2082 2083 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2081 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_number(organization, number) ⇒ Object
2122 2123 2124 2125 2126 2127 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2122 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
2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2085 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
2106 2107 2108 2109 2110 2111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2106 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
2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2130 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
2099 2100 2101 2102 2103 2104 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2099 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
2114 2115 2116 2117 2118 2119 2120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2114 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 |