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.
4152 4153 4154 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4152 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
4196 4197 4198 4199 4200 4201 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4196 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
4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4156 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)), :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
4181 4182 4183 4184 4185 4186 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4181 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
4174 4175 4176 4177 4178 4179 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4174 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
4188 4189 4190 4191 4192 4193 4194 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4188 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 |