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_device_location_request(account_name, txid) ⇒ TransactionID

Cancel a queued or unfinished device location request. “##########-#####”. cancel, from the synchronous response to the original request.

Parameters:

  • account_name (String)

    Required parameter: Account identifier in

  • txid (String)

    Required parameter: Transaction ID of the request to

Returns:



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

def cancel_device_location_request(,
                                   txid)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/devicelocations/{txid}',
                                 Server::DEVICE_LOCATION)
               .query_param(new_parameter(, key: 'accountName'))
               .template_param(new_parameter(txid, key: 'txid')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oAuth2')))
    .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

#cancel_queued_location_report_generation(account, txid) ⇒ TransactionID

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

Parameters:

  • account (String)

    Required parameter: Account identifier in

  • txid (String)

    Required parameter: Transaction ID of the report to

Returns:



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/verizon/controllers/devices_locations_controller.rb', line 178

def cancel_queued_location_report_generation(,
                                             txid)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/locationreports/{account}/report/{txid}',
                                 Server::DEVICE_LOCATION)
               .template_param(new_parameter(, key: 'account')
                                .should_encode(true))
               .template_param(new_parameter(txid, key: 'txid')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oAuth2')))
    .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) ⇒ AsynchronousLocationRequestResult

Request an asynchronous device location report. location report.

Parameters:

Returns:



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

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(Single.new('oAuth2')))
    .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, txid) ⇒ LocationReportStatus

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

Parameters:

  • account (String)

    Required parameter: Account identifier in

  • txid (String)

    Required parameter: Transaction ID of the report.

Returns:



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

def get_location_report_status(,
                               txid)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/locationreports/{account}/report/{txid}/status',
                                 Server::DEVICE_LOCATION)
               .template_param(new_parameter(, key: 'account')
                                .should_encode(true))
               .template_param(new_parameter(txid, key: 'txid')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oAuth2')))
    .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) ⇒ SynchronousLocationRequestResult

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:



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(Single.new('oAuth2')))
    .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) ⇒ Array[Location]

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

Parameters:

Returns:

  • (Array[Location])

    response from the API call



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(Single.new('oAuth2')))
    .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, txid, startindex) ⇒ LocationReport

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

Parameters:

  • account (String)

    Required parameter: Account identifier in

  • txid (String)

    Required parameter: Transaction ID from POST

  • startindex (Integer)

    Required parameter: Zero-based number of the

Returns:



120
121
122
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 120

def retrieve_location_report(,
                             txid,
                             startindex)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/locationreports/{account}/report/{txid}/index/{startindex}',
                                 Server::DEVICE_LOCATION)
               .template_param(new_parameter(, key: 'account')
                                .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(Single.new('oAuth2')))
    .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