Class: Samsara::AsyncDevicesClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Samsara::AsyncDevicesClient

Parameters:



85
86
87
# File 'lib/samsara_api/devices/client.rb', line 85

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientSamsara::AsyncRequestClient (readonly)



80
81
82
# File 'lib/samsara_api/devices/client.rb', line 80

def request_client
  @request_client
end

Instance Method Details

#list(models: nil, health_statuses: nil, include_health: nil, after: nil, limit: nil, request_options: nil) ⇒ Object

api.devices.list



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/samsara_api/devices/client.rb', line 130

def list(models: nil, health_statuses: nil, include_health: nil, after: nil, limit: 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 || {}), "models": models, "healthStatuses": health_statuses, "includeHealth": include_health, "after": after, "limit": limit }.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)}/devices"
end
    Samsara::Types::DevicesGetDevicesResponseBody.from_json(json_object: response.body)
  end
end