Class: Samsara::AsyncCarrierProposedAssignmentsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/carrier_proposed_assignments/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Samsara::AsyncCarrierProposedAssignmentsClient



176
177
178
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 176

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientSamsara::AsyncRequestClient (readonly)



171
172
173
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 171

def request_client
  @request_client
end

Instance Method Details

#create(active_time: nil, driver_id:, shipping_docs: nil, trailer_ids: nil, trailer_names: nil, vehicle_id:, request_options: nil) ⇒ Object

api.carrier_proposed_assignments.create(driver_id: “42”, vehicle_id: “123”)



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 266

def create(active_time: nil, driver_id:, shipping_docs: nil, trailer_ids: nil, trailer_names: nil, vehicle_id:, request_options: nil)
  Async do
    response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
req.headers["Authorization"] = request_options.token
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), activeTime: active_time, driverId: driver_id, shippingDocs: shipping_docs, trailerIds: trailer_ids, trailerNames: trailer_names, vehicleId: vehicle_id }.compact
  req.url "#{@request_client.get_url(request_options: request_options)}/fleet/carrier-proposed-assignments"
end
    Samsara::Types::CarrierProposedAssignmentResponse.from_json(json_object: response.body)
  end
end

#delete(id:, request_options: nil) ⇒ Object

api.carrier_proposed_assignments.delete(id: “id”)



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 309

def delete(id:, request_options: nil)
  Async do
    response = @request_client.conn.delete do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
req.headers["Authorization"] = request_options.token
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
  end
  req.url "#{@request_client.get_url(request_options: request_options)}/fleet/carrier-proposed-assignments/#{id}"
end
    parsed_json = JSON.parse(response.body)
    parsed_json
  end
end

#list(limit: nil, after: nil, driver_ids: nil, active_time: nil, request_options: nil) ⇒ Object

api.carrier_proposed_assignments.list



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 214

def list(limit: nil, after: nil, driver_ids: nil, active_time: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
req.headers["Authorization"] = request_options.token
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "after": after, "driverIds": driver_ids, "activeTime": active_time }.compact
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
  end
  req.url "#{@request_client.get_url(request_options: request_options)}/fleet/carrier-proposed-assignments"
end
    Samsara::Types::ListCarrierProposedAssignmentResponse.from_json(json_object: response.body)
  end
end