Class: Io::Flow::V0::Clients::TierDefaults
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::TierDefaults
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ TierDefaults
constructor
A new instance of TierDefaults.
- #post(organization, tier_default_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ TierDefaults
Returns a new instance of TierDefaults.
3396 3397 3398 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3396 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3400 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) }), :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', x, Array).map { |v| HttpClient::Preconditions.assert_class('experience', 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)}/tier_defaults").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TierDefault.new(x) } end |
#get_by_id(organization, id) ⇒ Object
3421 3422 3423 3424 3425 3426 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3421 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)}/tier_defaults/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::TierDefault.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3428 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_default => (x = opts.delete(:tier_default); x.nil? ? nil : HttpClient::Preconditions.assert_class('tier_default', x, Array).map { |v| HttpClient::Preconditions.assert_class('tier_default', 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)}/tier_defaults/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TierDefaultVersion.new(x) } end |
#post(organization, tier_default_form) ⇒ Object
3414 3415 3416 3417 3418 3419 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3414 def post(organization, tier_default_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = tier_default_form; x.is_a?(::Io::Flow::V0::Models::TierDefaultForm) ? x : ::Io::Flow::V0::Models::TierDefaultForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/tier_defaults").with_json(tier_default_form.to_json).post ::Io::Flow::V0::Models::TierDefault.new(r) end |