Class: Verizon::DevicesLocationsController

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

Overview

DevicesLocationsController

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

#cancel_queued_location_report_generation(account_name, txid) ⇒ ApiResponse

Cancel a queued device location report. “##########-#####”. cancel.

Parameters:

  • account_name (String)

    Required parameter: Account identifier in

  • txid (String)

    Required parameter: Transaction ID of the report to

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/verizon/controllers/devices_locations_controller.rb', line 151

def cancel_queued_location_report_generation(,
                                             txid)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/locationreports/{accountName}/report/{txid}',
                                 Server::DEVICE_LOCATION)
               .template_param(new_parameter(, key: 'accountName')
                                .should_encode(true))
               .template_param(new_parameter(txid, key: 'txid')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TransactionID.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Unexpected error.',
                             DeviceLocationResultException))
    .execute
end

#create_location_report(body) ⇒ ApiResponse

Request an asynchronous device location report. location report.

Parameters:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/verizon/controllers/devices_locations_controller.rb', line 65

def create_location_report(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/locationreports',
                                 Server::DEVICE_LOCATION)
               .header_param(new_parameter('*/*', 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(AsynchronousLocationRequestResult.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Unexpected error.',
                             DeviceLocationResultException))
    .execute
end

#get_location_report_status(account_name, txid) ⇒ ApiResponse

Returns the current status of a requested device location report. “##########-#####”.

Parameters:

  • account_name (String)

    Required parameter: Account identifier in

  • txid (String)

    Required parameter: Transaction ID of the report.

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/verizon/controllers/devices_locations_controller.rb', line 123

def get_location_report_status(,
                               txid)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/locationreports/{accountName}/report/{txid}/status',
                                 Server::DEVICE_LOCATION)
               .template_param(new_parameter(, key: 'accountName')
                                .should_encode(true))
               .template_param(new_parameter(txid, key: 'txid')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(LocationReportStatus.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Unexpected error.',
                             DeviceLocationResultException))
    .execute
end

#list_devices_locations_asynchronous(body) ⇒ ApiResponse

Requests the current or cached location of up to 10,000 IoT or consumer devices (phones, tablets. etc.). This request returns a synchronous transaction ID, and the location information for each device is returned asynchronously as a DeviceLocation callback message. to obtain locations of devices.

Parameters:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/verizon/controllers/devices_locations_controller.rb', line 41

def list_devices_locations_asynchronous(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devicelocations',
                                 Server::DEVICE_LOCATION)
               .header_param(new_parameter('*/*', 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(SynchronousLocationRequestResult.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Unexpected error.',
                             DeviceLocationResultException))
    .execute
end

#list_devices_locations_synchronous(body) ⇒ ApiResponse

This locations endpoint retrieves the locations for a list of devices. location of devices.

Parameters:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



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

def list_devices_locations_synchronous(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/locations',
                                 Server::DEVICE_LOCATION)
               .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(Location.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true)
                .local_error('default',
                             'Unexpected error.',
                             DeviceLocationResultException))
    .execute
end

#retrieve_location_report(account_name, txid, startindex) ⇒ ApiResponse

Download a completed asynchronous device location report. “##########-#####”. /locationreports response. first record to return.

Parameters:

  • account_name (String)

    Required parameter: Account identifier in

  • txid (String)

    Required parameter: Transaction ID from POST

  • startindex (Integer)

    Required parameter: Zero-based number of the

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/verizon/controllers/devices_locations_controller.rb', line 93

def retrieve_location_report(,
                             txid,
                             startindex)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/locationreports/{accountName}/report/{txid}/index/{startindex}',
                                 Server::DEVICE_LOCATION)
               .template_param(new_parameter(, key: 'accountName')
                                .should_encode(true))
               .template_param(new_parameter(txid, key: 'txid')
                                .should_encode(true))
               .template_param(new_parameter(startindex, key: 'startindex')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(LocationReport.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Unexpected error.',
                             DeviceLocationResultException))
    .execute
end