Class: Io::Flow::V0::Clients::RatecardLanes
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::RatecardLanes
- 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
-
#initialize(client) ⇒ RatecardLanes
constructor
A new instance of RatecardLanes.
- #post(organization, ratecard_lane_form) ⇒ Object
- #put_by_id(organization, id, ratecard_lane_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ RatecardLanes
Returns a new instance of RatecardLanes.
4478 4479 4480 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4478 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
4523 4524 4525 4526 4527 4528 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4523 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
4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4482 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
4508 4509 4510 4511 4512 4513 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4508 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
4501 4502 4503 4504 4505 4506 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4501 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
4515 4516 4517 4518 4519 4520 4521 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4515 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 |