Class: Io::Flow::V0::Clients::TierRules
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::TierRules
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(organization, tier_id, id) ⇒ Object
- #get(organization, tier_id, incoming = {}) ⇒ Object
- #get_by_id(organization, tier_id, id) ⇒ Object
- #get_versions(organization, tier_id, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ TierRules
constructor
A new instance of TierRules.
- #post(organization, tier_id, tier_rule_form) ⇒ Object
- #put_by_id(organization, tier_id, id, tier_rule_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ TierRules
Returns a new instance of TierRules.
4093 4094 4095 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4093 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, tier_id, id) ⇒ Object
4151 4152 4153 4154 4155 4156 4157 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4151 def delete_by_id(organization, tier_id, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('tier_id', tier_id, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/tiers/#{CGI.escape(tier_id)}/rules/#{CGI.escape(id)}").delete nil end |
#get(organization, tier_id, incoming = {}) ⇒ Object
4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4097 def get(organization, tier_id, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('tier_id', tier_id, 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)}/tiers/#{CGI.escape(tier_id)}/rules").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TierRule.new(x) } end |
#get_by_id(organization, tier_id, id) ⇒ Object
4134 4135 4136 4137 4138 4139 4140 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4134 def get_by_id(organization, tier_id, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('tier_id', tier_id, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/tiers/#{CGI.escape(tier_id)}/rules/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::TierRule.new(r) end |
#get_versions(organization, tier_id, incoming = {}) ⇒ Object
4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4119 def get_versions(organization, tier_id, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('tier_id', tier_id, 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) }), :tier_rule => (x = opts.delete(:tier_rule); x.nil? ? nil : HttpClient::Preconditions.assert_class('tier_rule', x, Array).map { |v| HttpClient::Preconditions.assert_class('tier_rule', 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)}/tiers/#{CGI.escape(tier_id)}/rules/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TierRuleVersion.new(x) } end |
#post(organization, tier_id, tier_rule_form) ⇒ Object
4111 4112 4113 4114 4115 4116 4117 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4111 def post(organization, tier_id, tier_rule_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('tier_id', tier_id, String) (x = tier_rule_form; x.is_a?(::Io::Flow::V0::Models::TierRuleForm) ? x : ::Io::Flow::V0::Models::TierRuleForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/tiers/#{CGI.escape(tier_id)}/rules").with_json(tier_rule_form.to_json).post ::Io::Flow::V0::Models::TierRule.new(r) end |
#put_by_id(organization, tier_id, id, tier_rule_form) ⇒ Object
4142 4143 4144 4145 4146 4147 4148 4149 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4142 def put_by_id(organization, tier_id, id, tier_rule_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('tier_id', tier_id, String) HttpClient::Preconditions.assert_class('id', id, String) (x = tier_rule_form; x.is_a?(::Io::Flow::V0::Models::TierRuleForm) ? x : ::Io::Flow::V0::Models::TierRuleForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/tiers/#{CGI.escape(tier_id)}/rules/#{CGI.escape(id)}").with_json(tier_rule_form.to_json).put ::Io::Flow::V0::Models::TierRule.new(r) end |