=begin #ARTIK Cloud API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 2.0.0 Generated by: https://github.com/swagger-api/swagger-codegen.git =end require "uri" module ArtikCloud class DevicesApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Add Device # Create a device # @param device Device to be added to the user # @param [Hash] opts the optional parameters # @return [DeviceEnvelope] def add_device(device, opts = {}) data, _status_code, _headers = add_device_with_http_info(device, opts) return data end # Add Device # Create a device # @param device Device to be added to the user # @param [Hash] opts the optional parameters # @return [Array<(DeviceEnvelope, Fixnum, Hash)>] DeviceEnvelope data, response status code and response headers def add_device_with_http_info(device, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: DevicesApi.add_device ..." end # verify the required parameter 'device' is set fail ArgumentError, "Missing the required parameter 'device' when calling DevicesApi.add_device" if device.nil? # resource path local_var_path = "/devices".sub('{format}','json') # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(device) auth_names = ['artikcloud_oauth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DeviceEnvelope') if @api_client.config.debugging @api_client.config.logger.debug "API called: DevicesApi#add_device\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Device # Deletes a device # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [DeviceEnvelope] def delete_device(device_id, opts = {}) data, _status_code, _headers = delete_device_with_http_info(device_id, opts) return data end # Delete Device # Deletes a device # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [Array<(DeviceEnvelope, Fixnum, Hash)>] DeviceEnvelope data, response status code and response headers def delete_device_with_http_info(device_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: DevicesApi.delete_device ..." end # verify the required parameter 'device_id' is set fail ArgumentError, "Missing the required parameter 'device_id' when calling DevicesApi.delete_device" if device_id.nil? # resource path local_var_path = "/devices/{deviceId}".sub('{format}','json').sub('{' + 'deviceId' + '}', device_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['artikcloud_oauth'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DeviceEnvelope') if @api_client.config.debugging @api_client.config.logger.debug "API called: DevicesApi#delete_device\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Device Token # Deletes a device's token # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [DeviceTokenEnvelope] def delete_device_token(device_id, opts = {}) data, _status_code, _headers = delete_device_token_with_http_info(device_id, opts) return data end # Delete Device Token # Deletes a device's token # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [Array<(DeviceTokenEnvelope, Fixnum, Hash)>] DeviceTokenEnvelope data, response status code and response headers def delete_device_token_with_http_info(device_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: DevicesApi.delete_device_token ..." end # verify the required parameter 'device_id' is set fail ArgumentError, "Missing the required parameter 'device_id' when calling DevicesApi.delete_device_token" if device_id.nil? # resource path local_var_path = "/devices/{deviceId}/tokens".sub('{format}','json').sub('{' + 'deviceId' + '}', device_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['artikcloud_oauth'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DeviceTokenEnvelope') if @api_client.config.debugging @api_client.config.logger.debug "API called: DevicesApi#delete_device_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Device # Retrieves a device # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [DeviceEnvelope] def get_device(device_id, opts = {}) data, _status_code, _headers = get_device_with_http_info(device_id, opts) return data end # Get Device # Retrieves a device # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [Array<(DeviceEnvelope, Fixnum, Hash)>] DeviceEnvelope data, response status code and response headers def get_device_with_http_info(device_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: DevicesApi.get_device ..." end # verify the required parameter 'device_id' is set fail ArgumentError, "Missing the required parameter 'device_id' when calling DevicesApi.get_device" if device_id.nil? # resource path local_var_path = "/devices/{deviceId}".sub('{format}','json').sub('{' + 'deviceId' + '}', device_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['artikcloud_oauth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DeviceEnvelope') if @api_client.config.debugging @api_client.config.logger.debug "API called: DevicesApi#get_device\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get device presence information # Return the presence status of the given device along with the time it was last seen # @param device_id Device ID. # @param [Hash] opts the optional parameters # @return [PresenceEnvelope] def get_device_presence(device_id, opts = {}) data, _status_code, _headers = get_device_presence_with_http_info(device_id, opts) return data end # Get device presence information # Return the presence status of the given device along with the time it was last seen # @param device_id Device ID. # @param [Hash] opts the optional parameters # @return [Array<(PresenceEnvelope, Fixnum, Hash)>] PresenceEnvelope data, response status code and response headers def get_device_presence_with_http_info(device_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: DevicesApi.get_device_presence ..." end # verify the required parameter 'device_id' is set fail ArgumentError, "Missing the required parameter 'device_id' when calling DevicesApi.get_device_presence" if device_id.nil? # resource path local_var_path = "/devices/{deviceId}/presence".sub('{format}','json').sub('{' + 'deviceId' + '}', device_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['artikcloud_oauth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'PresenceEnvelope') if @api_client.config.debugging @api_client.config.logger.debug "API called: DevicesApi#get_device_presence\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Device Token # Retrieves a device's token # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [DeviceTokenEnvelope] def get_device_token(device_id, opts = {}) data, _status_code, _headers = get_device_token_with_http_info(device_id, opts) return data end # Get Device Token # Retrieves a device's token # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [Array<(DeviceTokenEnvelope, Fixnum, Hash)>] DeviceTokenEnvelope data, response status code and response headers def get_device_token_with_http_info(device_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: DevicesApi.get_device_token ..." end # verify the required parameter 'device_id' is set fail ArgumentError, "Missing the required parameter 'device_id' when calling DevicesApi.get_device_token" if device_id.nil? # resource path local_var_path = "/devices/{deviceId}/tokens".sub('{format}','json').sub('{' + 'deviceId' + '}', device_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['artikcloud_oauth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DeviceTokenEnvelope') if @api_client.config.debugging @api_client.config.logger.debug "API called: DevicesApi#get_device_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Device # Updates a device # @param device_id deviceId # @param device Device to be updated # @param [Hash] opts the optional parameters # @return [DeviceEnvelope] def update_device(device_id, device, opts = {}) data, _status_code, _headers = update_device_with_http_info(device_id, device, opts) return data end # Update Device # Updates a device # @param device_id deviceId # @param device Device to be updated # @param [Hash] opts the optional parameters # @return [Array<(DeviceEnvelope, Fixnum, Hash)>] DeviceEnvelope data, response status code and response headers def update_device_with_http_info(device_id, device, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: DevicesApi.update_device ..." end # verify the required parameter 'device_id' is set fail ArgumentError, "Missing the required parameter 'device_id' when calling DevicesApi.update_device" if device_id.nil? # verify the required parameter 'device' is set fail ArgumentError, "Missing the required parameter 'device' when calling DevicesApi.update_device" if device.nil? # resource path local_var_path = "/devices/{deviceId}".sub('{format}','json').sub('{' + 'deviceId' + '}', device_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(device) auth_names = ['artikcloud_oauth'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DeviceEnvelope') if @api_client.config.debugging @api_client.config.logger.debug "API called: DevicesApi#update_device\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Device Token # Updates a device's token # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [DeviceTokenEnvelope] def update_device_token(device_id, opts = {}) data, _status_code, _headers = update_device_token_with_http_info(device_id, opts) return data end # Update Device Token # Updates a device's token # @param device_id deviceId # @param [Hash] opts the optional parameters # @return [Array<(DeviceTokenEnvelope, Fixnum, Hash)>] DeviceTokenEnvelope data, response status code and response headers def update_device_token_with_http_info(device_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: DevicesApi.update_device_token ..." end # verify the required parameter 'device_id' is set fail ArgumentError, "Missing the required parameter 'device_id' when calling DevicesApi.update_device_token" if device_id.nil? # resource path local_var_path = "/devices/{deviceId}/tokens".sub('{format}','json').sub('{' + 'deviceId' + '}', device_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['text/plain']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['artikcloud_oauth'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DeviceTokenEnvelope') if @api_client.config.debugging @api_client.config.logger.debug "API called: DevicesApi#update_device_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end