Class: Io::Flow::V0::Clients::TierDefaults

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TierDefaults



3443
3444
3445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3443

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#get(organization, incoming = {}) ⇒ Object



3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3447

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



3468
3469
3470
3471
3472
3473
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3468

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



3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3475

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



3461
3462
3463
3464
3465
3466
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3461

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