Class: Io::Flow::V0::Clients::InventoryUpdates
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::InventoryUpdates
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ InventoryUpdates
constructor
A new instance of InventoryUpdates.
- #post(organization, inventory_update_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ InventoryUpdates
Returns a new instance of InventoryUpdates.
4228 4229 4230 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4228 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4232 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) }), :center => (x = opts.delete(:center); x.nil? ? nil : HttpClient::Preconditions.assert_class('center', x, Array).map { |v| HttpClient::Preconditions.assert_class('center', v, String) }), :item_number => (x = opts.delete(:item_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('item_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('item_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? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/inventory_updates").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::InventoryUpdate.new(x) } end |
#get_by_id(organization, id) ⇒ Object
4268 4269 4270 4271 4272 4273 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4268 def get_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/inventory_updates/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::InventoryUpdate.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4254 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) }), :inventory_update => (x = opts.delete(:inventory_update); x.nil? ? nil : HttpClient::Preconditions.assert_class('inventory_update', x, Array).map { |v| HttpClient::Preconditions.assert_class('inventory_update', 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)}/inventory_updates/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::InventoryUpdateVersion.new(x) } end |
#post(organization, inventory_update_form) ⇒ Object
4247 4248 4249 4250 4251 4252 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4247 def post(organization, inventory_update_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = inventory_update_form; x.is_a?(::Io::Flow::V0::Models::InventoryUpdateForm) ? x : ::Io::Flow::V0::Models::InventoryUpdateForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/inventory_updates").with_json(inventory_update_form.to_json).post ::Io::Flow::V0::Models::InventoryUpdate.new(r) end |