Class: Io::Flow::V0::Clients::RatecardLanes

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ RatecardLanes

Returns a new instance of RatecardLanes.



3970
3971
3972
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3970

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

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



4015
4016
4017
4018
4019
4020
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4015

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)}/ratecard-lanes/#{CGI.escape(id)}").delete
  nil
end

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



3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3974

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) }),
    :delivered_duty => (x = opts.delete(:delivered_duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x)).value),
    :destination => (x = opts.delete(:destination); x.nil? ? nil : HttpClient::Preconditions.assert_class('destination', x, String)),
    :origin => (x = opts.delete(:origin); x.nil? ? nil : HttpClient::Preconditions.assert_class('origin', x, String)),
    :ratecard_id => (x = opts.delete(:ratecard_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('ratecard_id', x, String)),
    :service => (x = opts.delete(:service); x.nil? ? nil : HttpClient::Preconditions.assert_class('service', x, String)),
    :ratecard_owner => (x = opts.delete(:ratecard_owner); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::RatecardOwner) ? x : ::Io::Flow::V0::Models::RatecardOwner.apply(x)).value),
    :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)}/ratecard-lanes").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::RatecardLane.new(x) }
end

#get_by_id(organization, id) ⇒ Object



4000
4001
4002
4003
4004
4005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4000

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)}/ratecard-lanes/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::RatecardLane.new(r)
end

#post(organization, ratecard_lane_form) ⇒ Object



3993
3994
3995
3996
3997
3998
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3993

def post(organization, ratecard_lane_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = ratecard_lane_form; x.is_a?(::Io::Flow::V0::Models::RatecardLaneForm) ? x : ::Io::Flow::V0::Models::RatecardLaneForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/ratecard-lanes").with_json(ratecard_lane_form.to_json).post
  ::Io::Flow::V0::Models::RatecardLane.new(r)
end

#put_by_id(organization, id, ratecard_lane_form) ⇒ Object



4007
4008
4009
4010
4011
4012
4013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4007

def put_by_id(organization, id, ratecard_lane_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = ratecard_lane_form; x.is_a?(::Io::Flow::V0::Models::RatecardLaneForm) ? x : ::Io::Flow::V0::Models::RatecardLaneForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/ratecard-lanes/#{CGI.escape(id)}").with_json(ratecard_lane_form.to_json).put
  ::Io::Flow::V0::Models::RatecardLane.new(r)
end