Class: Io::Flow::V0::Clients::Tiers
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Tiers
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(organization, id) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ Tiers
constructor
A new instance of Tiers.
- #post(organization, tier_form) ⇒ Object
- #put_by_id(organization, id, tier_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ Tiers
Returns a new instance of Tiers.
3330 3331 3332 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3330 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
3371 3372 3373 3374 3375 3376 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3371 def delete_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/tiers/#{CGI.escape(id)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3334 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) }), :tier_direction => (x = opts.delete(:tier_direction); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::TierDirection) ? x : ::Io::Flow::V0::Models::TierDirection.apply(x)).value), :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', x, 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? ? "name" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/tiers").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Tier.new(x) } end |
#get_by_id(organization, id) ⇒ Object
3356 3357 3358 3359 3360 3361 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3356 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)}/tiers/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Tier.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3378 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) }), :tier => (x = opts.delete(:tier); x.nil? ? nil : HttpClient::Preconditions.assert_class('tier', x, Array).map { |v| HttpClient::Preconditions.assert_class('tier', 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/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TierVersion.new(x) } end |
#post(organization, tier_form) ⇒ Object
3349 3350 3351 3352 3353 3354 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3349 def post(organization, tier_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = tier_form; x.is_a?(::Io::Flow::V0::Models::TierForm) ? x : ::Io::Flow::V0::Models::TierForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/tiers").with_json(tier_form.to_json).post ::Io::Flow::V0::Models::Tier.new(r) end |
#put_by_id(organization, id, tier_form) ⇒ Object
3363 3364 3365 3366 3367 3368 3369 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3363 def put_by_id(organization, id, tier_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) (x = tier_form; x.is_a?(::Io::Flow::V0::Models::TierForm) ? x : ::Io::Flow::V0::Models::TierForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/tiers/#{CGI.escape(id)}").with_json(tier_form.to_json).put ::Io::Flow::V0::Models::Tier.new(r) end |