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.
2527 2528 2529 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2527 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2531 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
2552 2553 2554 2555 2556 2557 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2552 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
2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2559 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
2545 2546 2547 2548 2549 2550 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2545 def post(organization, tier_default_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('tier_default_form', tier_default_form, ::Io::Flow::V0::Models::TierDefaultForm) r = @client.request("/#{CGI.escape(organization)}/tier_defaults").with_json(tier_default_form.to_json).post ::Io::Flow::V0::Models::TierDefault.new(r) end |