Class: Samsara::CarrierProposedAssignmentsClient

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::CarrierProposedAssignmentsClient

Parameters:



19
20
21
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 19

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientSamsara::RequestClient (readonly)



14
15
16
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 14

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”)



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 107

def create(active_time: nil, driver_id:, shipping_docs: nil, trailer_ids: nil, trailer_names: nil, vehicle_id:, request_options: nil)
  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

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

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



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 148

def delete(id:, request_options: nil)
  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

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

api.carrier_proposed_assignments.list



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/samsara_api/carrier_proposed_assignments/client.rb', line 57

def list(limit: nil, after: nil, driver_ids: nil, active_time: nil, request_options: nil)
  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