Class: Samsara::AsyncAssetsClient
- Inherits:
-
Object
- Object
- Samsara::AsyncAssetsClient
- Defined in:
- lib/samsara_api/assets/client.rb
Instance Attribute Summary collapse
- #location_and_speed ⇒ Samsara::Assets::LocationAndSpeedClient readonly
- #request_client ⇒ Samsara::AsyncRequestClient readonly
Instance Method Summary collapse
-
#create(external_ids: nil, license_plate: nil, make: nil, model: nil, name: nil, notes: nil, regulation_mode: nil, serial_number: nil, type: nil, vin: nil, year: nil, request_options: nil) ⇒ Object
api.assets.create.
-
#delete(id:, request_options: nil) ⇒ Object
api.assets.delete(id: “id”).
- #initialize(request_client:) ⇒ Samsara::AsyncAssetsClient constructor
-
#list(type: nil, after: nil, updated_after_time: nil, include_external_ids: nil, include_tags: nil, tag_ids: nil, parent_tag_ids: nil, ids: nil, attribute_value_ids: nil, request_options: nil) ⇒ Object
api.assets.list.
-
#update(id:, external_ids: nil, license_plate: nil, make: nil, model: nil, name: nil, notes: nil, regulation_mode: nil, serial_number: nil, type: nil, vin: nil, year: nil, request_options: nil) ⇒ Object
api.assets.update(id: “id”).
Constructor Details
#initialize(request_client:) ⇒ Samsara::AsyncAssetsClient
278 279 280 281 |
# File 'lib/samsara_api/assets/client.rb', line 278 def initialize(request_client:) @request_client = request_client @location_and_speed = Samsara::Assets::AsyncLocationAndSpeedClient.new(request_client: request_client) end |
Instance Attribute Details
#location_and_speed ⇒ Samsara::Assets::LocationAndSpeedClient (readonly)
273 274 275 |
# File 'lib/samsara_api/assets/client.rb', line 273 def location_and_speed @location_and_speed end |
#request_client ⇒ Samsara::AsyncRequestClient (readonly)
271 272 273 |
# File 'lib/samsara_api/assets/client.rb', line 271 def request_client @request_client end |
Instance Method Details
#create(external_ids: nil, license_plate: nil, make: nil, model: nil, name: nil, notes: nil, regulation_mode: nil, serial_number: nil, type: nil, vin: nil, year: nil, request_options: nil) ⇒ Object
api.assets.create
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/samsara_api/assets/client.rb', line 398 def create(external_ids: nil, license_plate: nil, make: nil, model: nil, name: nil, notes: nil, regulation_mode: nil, serial_number: nil, type: nil, vin: nil, year: nil, request_options: nil) Async do response = @request_client.conn.post 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 || {}), externalIds: external_ids, licensePlate: license_plate, make: make, model: model, name: name, notes: notes, regulationMode: regulation_mode, serialNumber: serial_number, type: type, vin: vin, year: year }.compact req.url "#{@request_client.get_url(request_options: request_options)}/assets" end Samsara::Types::AssetsCreateAssetResponseBody.from_json(json_object: response.body) end end |
#delete(id:, request_options: nil) ⇒ Object
api.assets.delete(id: “id”)
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'lib/samsara_api/assets/client.rb', line 442 def delete(id:, request_options: nil) Async do response = @request_client.conn.delete 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 || {}), "id": id }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: request_options)}/assets" end end end |
#list(type: nil, after: nil, updated_after_time: nil, include_external_ids: nil, include_tags: nil, tag_ids: nil, parent_tag_ids: nil, ids: nil, attribute_value_ids: nil, request_options: nil) ⇒ Object
api.assets.list
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/samsara_api/assets/client.rb', line 331 def list(type: nil, after: nil, updated_after_time: nil, include_external_ids: nil, include_tags: nil, tag_ids: nil, parent_tag_ids: nil, ids: nil, attribute_value_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 || {}), "type": type, "after": after, "updatedAfterTime": updated_after_time, "includeExternalIds": include_external_ids, "includeTags": , "tagIds": tag_ids, "parentTagIds": parent_tag_ids, "ids": ids, "attributeValueIds": attribute_value_ids }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: request_options)}/assets" end Samsara::Types::AssetsListAssetsResponseBody.from_json(json_object: response.body) end end |
#update(id:, external_ids: nil, license_plate: nil, make: nil, model: nil, name: nil, notes: nil, regulation_mode: nil, serial_number: nil, type: nil, vin: nil, year: nil, request_options: nil) ⇒ Object
api.assets.update(id: “id”)
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/samsara_api/assets/client.rb', line 509 def update(id:, external_ids: nil, license_plate: nil, make: nil, model: nil, name: nil, notes: nil, regulation_mode: nil, serial_number: nil, type: nil, vin: nil, year: 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 req.params = { **(&.additional_query_parameters || {}), "id": id }.compact req.body = { **(&.additional_body_parameters || {}), externalIds: external_ids, licensePlate: license_plate, make: make, model: model, name: name, notes: notes, regulationMode: regulation_mode, serialNumber: serial_number, type: type, vin: vin, year: year }.compact req.url "#{@request_client.get_url(request_options: request_options)}/assets" end Samsara::Types::AssetsUpdateAssetResponseBody.from_json(json_object: response.body) end end |