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.
5954 5955 5956 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5954 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.
5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5959 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
5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5979 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
5972 5973 5974 5975 5976 5977 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5972 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.
5994 5995 5996 5997 5998 5999 6000 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5994 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.
6004 6005 6006 6007 6008 6009 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6004 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 |