Class: Samsara::AsyncDefectsClient
- Inherits:
-
Object
- Object
- Samsara::AsyncDefectsClient
- Defined in:
- lib/samsara_api/defects/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#get(id:, include_external_ids: nil, request_options: nil) ⇒ Object
api.defects.get(id: “id”).
-
#history(limit: nil, after: nil, start_time:, end_time:, is_resolved: nil, request_options: nil) ⇒ Object
api.defects.history(start_time: “startTime”, end_time: “endTime”).
- #initialize(request_client:) ⇒ Samsara::AsyncDefectsClient constructor
-
#stream(after: nil, limit: nil, start_time:, end_time: nil, include_external_ids: nil, is_resolved: nil, request_options: nil) ⇒ Object
api.defects.stream(start_time: “startTime”).
-
#update(id:, is_resolved: nil, mechanic_notes: nil, resolved_at_time: nil, resolved_by: nil, request_options: nil) ⇒ Object
api.defects.update(id: “id”).
Constructor Details
#initialize(request_client:) ⇒ Samsara::AsyncDefectsClient
231 232 233 |
# File 'lib/samsara_api/defects/client.rb', line 231 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Samsara::AsyncRequestClient (readonly)
226 227 228 |
# File 'lib/samsara_api/defects/client.rb', line 226 def request_client @request_client end |
Instance Method Details
#get(id:, include_external_ids: nil, request_options: nil) ⇒ Object
api.defects.get(id: “id”)
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/samsara_api/defects/client.rb', line 314 def get(id:, include_external_ids: nil, request_options: nil) Async do response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "includeExternalIds": include_external_ids }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/defects/#{id}" end Samsara::Types::DvirDefectGetDefectResponseBody.from_json(json_object: response.body) end end |
#history(limit: nil, after: nil, start_time:, end_time:, is_resolved: nil, request_options: nil) ⇒ Object
api.defects.history(start_time: “startTime”, end_time: “endTime”)
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/samsara_api/defects/client.rb', line 372 def history(limit: nil, after: nil, start_time:, end_time:, is_resolved: nil, request_options: nil) Async do response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "limit": limit, "after": after, "startTime": start_time, "endTime": end_time, "isResolved": is_resolved }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/fleet/defects/history" end Samsara::Types::DefectsResponse.from_json(json_object: response.body) end end |
#stream(after: nil, limit: nil, start_time:, end_time: nil, include_external_ids: nil, is_resolved: nil, request_options: nil) ⇒ Object
api.defects.stream(start_time: “startTime”)
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/samsara_api/defects/client.rb', line 269 def stream(after: nil, limit: nil, start_time:, end_time: nil, include_external_ids: nil, is_resolved: nil, request_options: nil) Async do response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "after": after, "limit": limit, "startTime": start_time, "endTime": end_time, "includeExternalIds": include_external_ids, "isResolved": is_resolved }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/defects/stream" end Samsara::Types::DvirDefectStreamDefectsResponseBody.from_json(json_object: response.body) end end |
#update(id:, is_resolved: nil, mechanic_notes: nil, resolved_at_time: nil, resolved_by: nil, request_options: nil) ⇒ Object
api.defects.update(id: “id”)
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/samsara_api/defects/client.rb', line 421 def update(id:, is_resolved: nil, mechanic_notes: nil, resolved_at_time: nil, resolved_by: nil, request_options: nil) Async do response = @request_client.conn.patch do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), isResolved: is_resolved, mechanicNotes: mechanic_notes, resolvedAtTime: resolved_at_time, resolvedBy: resolved_by }.compact req.url "#{@request_client.get_url(request_options: )}/fleet/defects/#{id}" end Samsara::Types::DefectResponse.from_json(json_object: response.body) end end |