Class: Verizon::CloudConnectorDevicesController

Inherits:
BaseController show all
Defined in:
lib/verizon/controllers/cloud_connector_devices_controller.rb

Overview

CloudConnectorDevicesController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from Verizon::BaseController

Instance Method Details

#delete_device_from_account(body) ⇒ ApiResponse

Remove a device from a ThingSpace account. identifies the device to delete.

Parameters:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/verizon/controllers/cloud_connector_devices_controller.rb', line 129

def (body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/actions/delete',
                                 Server::CLOUD_CONNECTOR)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true))
    .execute
end

#find_device_by_property_values(body) ⇒ ApiResponse

Find devices by property values. Returns an array of all matching device resources. body specifies fields and values to match.

Parameters:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/verizon/controllers/cloud_connector_devices_controller.rb', line 36

def find_device_by_property_values(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/actions/query',
                                 Server::CLOUD_CONNECTOR)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(FindDeviceByPropertyResponseList.method(:from_hash))
                .is_api_response(true))
    .execute
end

#search_device_event_history(body) ⇒ ApiResponse

Search device event history to find events that match criteria.Sensor readings, configuration changes, and other device data are all stored as events. device identifier and fields to match in the search.

Parameters:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/verizon/controllers/cloud_connector_devices_controller.rb', line 81

def search_device_event_history(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/fields/actions/history/search',
                                 Server::CLOUD_CONNECTOR)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SearchDeviceEventHistoryResponseList.method(:from_hash))
                .is_api_response(true))
    .execute
end

#search_devices_resources_by_property_values(body) ⇒ ApiResponse

Search for devices by property values. Returns an array of all matching device resources. body specifies fields and values to match.

Parameters:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/verizon/controllers/cloud_connector_devices_controller.rb', line 58

def search_devices_resources_by_property_values(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/actions/search',
                                 Server::CLOUD_CONNECTOR)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SearchDeviceByPropertyResponseList.method(:from_hash))
                .is_api_response(true))
    .execute
end

#search_sensor_readings(fieldname, body) ⇒ ApiResponse

Returns the readings of a specified sensor, with the most recent reading first. Sensor readings are stored as events; this request an array of events. identifier and fields to match in the search.

Parameters:

  • fieldname (String)

    Required parameter: The name of the sensor.

  • body (SearchSensorHistoryRequest)

    Required parameter: The device

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/verizon/controllers/cloud_connector_devices_controller.rb', line 105

def search_sensor_readings(fieldname,
                           body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/fields/{fieldname}/actions/history',
                                 Server::CLOUD_CONNECTOR)
               .template_param(new_parameter(fieldname, key: 'fieldname')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SearchSensorHistoryResponseList.method(:from_hash))
                .is_api_response(true))
    .execute
end

#update_devices_configuration_value(body) ⇒ ApiResponse

Change configuration values on a device, such as setting how often a device records and reports sensor readings. body changes configuration values on a device.

Parameters:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/verizon/controllers/cloud_connector_devices_controller.rb', line 14

def update_devices_configuration_value(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/configuration/actions/set',
                                 Server::CLOUD_CONNECTOR)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ChangeConfigurationResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end