Class: Io::Flow::V0::Clients::ExclusionRules
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::ExclusionRules
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#get(organization, incoming = {}) ⇒ Object
Returns a list of exclusions rules.
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ ExclusionRules
constructor
A new instance of ExclusionRules.
- #post(organization, exclusion_rule_form) ⇒ Object
-
#put_by_id(organization, id, exclusion_rule_form) ⇒ Object
Updates the specified exclusion rule.
-
#put_deletion_by_id(organization, id) ⇒ Object
Marks the exclusion rule deleted.
Constructor Details
#initialize(client) ⇒ ExclusionRules
Returns a new instance of ExclusionRules.
6799 6800 6801 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6799 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
Returns a list of exclusions rules.
6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6804 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)}/exclusion/rules").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ExclusionRule.new(x) } end |
#get_versions(organization, incoming = {}) ⇒ Object
6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6824 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) }), :exclusion_rule_id => (x = opts.delete(:exclusion_rule_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('exclusion_rule_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('exclusion_rule_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)}/exclusion/rules/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ExclusionRuleVersion.new(x) } end |
#post(organization, exclusion_rule_form) ⇒ Object
6817 6818 6819 6820 6821 6822 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6817 def post(organization, exclusion_rule_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = exclusion_rule_form; x.is_a?(::Io::Flow::V0::Models::ExclusionRuleForm) ? x : ::Io::Flow::V0::Models::ExclusionRuleForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/exclusion/rules").with_json(exclusion_rule_form.to_json).post ::Io::Flow::V0::Models::ExclusionRule.new(r) end |
#put_by_id(organization, id, exclusion_rule_form) ⇒ Object
Updates the specified exclusion rule.
6839 6840 6841 6842 6843 6844 6845 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6839 def put_by_id(organization, id, exclusion_rule_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) (x = exclusion_rule_form; x.is_a?(::Io::Flow::V0::Models::ExclusionRuleForm) ? x : ::Io::Flow::V0::Models::ExclusionRuleForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/exclusion/rules/#{CGI.escape(id)}").with_json(exclusion_rule_form.to_json).put ::Io::Flow::V0::Models::ExclusionRule.new(r) end |
#put_deletion_by_id(organization, id) ⇒ Object
Marks the exclusion rule deleted. Once updated, the rule itself will be deleted.
6849 6850 6851 6852 6853 6854 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6849 def put_deletion_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/exclusion/rules/#{CGI.escape(id)}/deletion").put ::Io::Flow::V0::Models::ExclusionRule.new(r) end |