Class: Airthings::DevicesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/airthings/api/devices_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ DevicesApi

Returns a new instance of DevicesApi.



19
20
21
# File 'lib/airthings/api/devices_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/airthings/api/devices_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#device_info(serial_number, opts = {}) ⇒ GetDeviceDetailedResponse

Get info about a specific Device

Parameters:

  • serial_number (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :organization_id (String)
  • :user_group_id (String)

Returns:



29
30
31
32
# File 'lib/airthings/api/devices_api.rb', line 29

def device_info(serial_number, opts = {})
  data, _status_code, _headers = device_info_with_http_info(serial_number, opts)
  data
end

#device_info_with_http_info(serial_number, opts = {}) ⇒ Array<(GetDeviceDetailedResponse, Integer, Hash)>

Get info about a specific Device

Parameters:

  • serial_number (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :organization_id (String)
  • :user_group_id (String)

Returns:

  • (Array<(GetDeviceDetailedResponse, Integer, Hash)>)

    GetDeviceDetailedResponse data, response status code and response headers



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/airthings/api/devices_api.rb', line 40

def device_info_with_http_info(serial_number, opts = {})
  @api_client.config.logger.debug "Calling API: DevicesApi.device_info ..." if @api_client.config.debugging
  # verify the required parameter 'serial_number' is set
  if @api_client.config.client_side_validation && serial_number.nil?
    raise ArgumentError, "Missing the required parameter 'serial_number' when calling DevicesApi.device_info"
  end

  # resource path
  local_var_path = "/devices/{serialNumber}".sub("{serialNumber}", CGI.escape(serial_number.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:organizationId] = opts[:organization_id] unless opts[:organization_id].nil?
  query_params[:userGroupId] = opts[:user_group_id] unless opts[:user_group_id].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params["Accept"] = @api_client.select_header_accept(["application/json"])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || "GetDeviceDetailedResponse"

  # auth_names
  auth_names = opts[:debug_auth_names] || ["AirthingsAccounts"]

  new_options = opts.merge(
    operation: :"DevicesApi.device_info",
    header_params: header_params,
    query_params: query_params,
    form_params: form_params,
    body: post_body,
    auth_names: auth_names,
    return_type: return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DevicesApi#device_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#device_samples_latest_values(serial_number, opts = {}) ⇒ SingleSampleResponse

Get latest Samples belonging to a specific Device (latest segment)

Parameters:

  • serial_number (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :organization_id (String)
  • :user_group_id (String)

Returns:



95
96
97
98
# File 'lib/airthings/api/devices_api.rb', line 95

def device_samples_latest_values(serial_number, opts = {})
  data, _status_code, _headers = device_samples_latest_values_with_http_info(serial_number, opts)
  data
end

#device_samples_latest_values_with_http_info(serial_number, opts = {}) ⇒ Array<(SingleSampleResponse, Integer, Hash)>

Get latest Samples belonging to a specific Device (latest segment)

Parameters:

  • serial_number (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :organization_id (String)
  • :user_group_id (String)

Returns:

  • (Array<(SingleSampleResponse, Integer, Hash)>)

    SingleSampleResponse data, response status code and response headers



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/airthings/api/devices_api.rb', line 106

def device_samples_latest_values_with_http_info(serial_number, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DevicesApi.device_samples_latest_values ..."
  end
  # verify the required parameter 'serial_number' is set
  if @api_client.config.client_side_validation && serial_number.nil?
    raise ArgumentError, "Missing the required parameter 'serial_number' when calling DevicesApi.device_samples_latest_values"
  end

  # resource path
  local_var_path = "/devices/{serialNumber}/latest-samples".sub("{serialNumber}", CGI.escape(serial_number.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:organizationId] = opts[:organization_id] unless opts[:organization_id].nil?
  query_params[:userGroupId] = opts[:user_group_id] unless opts[:user_group_id].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params["Accept"] = @api_client.select_header_accept(["application/json"])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || "SingleSampleResponse"

  # auth_names
  auth_names = opts[:debug_auth_names] || ["AirthingsAccounts"]

  new_options = opts.merge(
    operation: :"DevicesApi.device_samples_latest_values",
    header_params: header_params,
    query_params: query_params,
    form_params: form_params,
    body: post_body,
    auth_names: auth_names,
    return_type: return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DevicesApi#device_samples_latest_values\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#devices_list(opts = {}) ⇒ GetDevicesResponse

Get Devices belonging to the Account

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :show_inactive (Boolean) — default: default to false
  • :organization_id (String)
  • :user_group_id (String)

Returns:



163
164
165
166
# File 'lib/airthings/api/devices_api.rb', line 163

def devices_list(opts = {})
  data, _status_code, _headers = devices_list_with_http_info(opts)
  data
end

#devices_list_with_http_info(opts = {}) ⇒ Array<(GetDevicesResponse, Integer, Hash)>

Get Devices belonging to the Account

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :show_inactive (Boolean) — default: default to false
  • :organization_id (String)
  • :user_group_id (String)

Returns:

  • (Array<(GetDevicesResponse, Integer, Hash)>)

    GetDevicesResponse data, response status code and response headers



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/airthings/api/devices_api.rb', line 174

def devices_list_with_http_info(opts = {})
  @api_client.config.logger.debug "Calling API: DevicesApi.devices_list ..." if @api_client.config.debugging
  # resource path
  local_var_path = "/devices"

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:showInactive] = opts[:show_inactive] unless opts[:show_inactive].nil?
  query_params[:organizationId] = opts[:organization_id] unless opts[:organization_id].nil?
  query_params[:userGroupId] = opts[:user_group_id] unless opts[:user_group_id].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params["Accept"] = @api_client.select_header_accept(["application/json"])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || "GetDevicesResponse"

  # auth_names
  auth_names = opts[:debug_auth_names] || ["AirthingsAccounts"]

  new_options = opts.merge(
    operation: :"DevicesApi.devices_list",
    header_params: header_params,
    query_params: query_params,
    form_params: form_params,
    body: post_body,
    auth_names: auth_names,
    return_type: return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DevicesApi#devices_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end