Class: Io::Flow::V0::Clients::InventoryRules
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::InventoryRules
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(organization, incoming = {}) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ InventoryRules
constructor
A new instance of InventoryRules.
- #post(organization, inventory_rule_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ InventoryRules
3675 3676 3677 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3675 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3679 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) }), :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_rules").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::InventoryRule.new(x) } end |
#get_versions(organization, incoming = {}) ⇒ Object
3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3699 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) }), :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_rules/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::InventoryRuleVersion.new(x) } end |
#post(organization, inventory_rule_form) ⇒ Object
3692 3693 3694 3695 3696 3697 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3692 def post(organization, inventory_rule_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = inventory_rule_form; x.is_a?(::Io::Flow::V0::Models::InventoryRuleForm) ? x : ::Io::Flow::V0::Models::InventoryRuleForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/inventory_rules").with_json(inventory_rule_form.to_json).post ::Io::Flow::V0::Models::InventoryRule.new(r) end |