Class: Verizon::DeviceLocationCallbacksController

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

Overview

DeviceLocationCallbacksController

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_async_report(account_name, txid) ⇒ ApiResponse

Cancel an asynchronous report request. “##########-#####”.

Parameters:

  • account_name (String)

    Required parameter: Account identifier in

  • txid (String)

    Required parameter: The ‘transactionId` value.

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
30
31
32
33
# File 'lib/verizon/controllers/device_location_callbacks_controller.rb', line 14

def cancel_async_report(,
                        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(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

#deregister_callback(account_name, service) ⇒ ApiResponse

Deregister a URL to stop receiving callback messages. service name.

Parameters:

  • account_name (String)

    Required parameter: Account number.

  • service (CallbackServiceNameEnum)

    Required parameter: Callback

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



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

def deregister_callback(,
                        service)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/callbacks/{accountName}/name/{service}',
                                 Server::DEVICE_LOCATION)
               .template_param(new_parameter(, key: 'accountName')
                                .should_encode(true))
               .template_param(new_parameter(service, key: 'service')
                                .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(DeviceLocationSuccessResult.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Error response.',
                             DeviceLocationResultException))
    .execute
end

#list_registered_callbacks(account_name) ⇒ ApiResponse

Returns a list of all registered callback URLs for the account.

Parameters:

  • account_name (String)

    Required parameter: Account number.

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/verizon/controllers/device_location_callbacks_controller.rb', line 38

def list_registered_callbacks()
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/callbacks/{accountName}',
                                 Server::DEVICE_LOCATION)
               .template_param(new_parameter(, key: 'accountName')
                                .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(DeviceLocationCallback.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true)
                .local_error('400',
                             'Error response.',
                             DeviceLocationResultException))
    .execute
end

#register_callback(account_name, body) ⇒ ApiResponse

Provide a URL to receive messages from a ThingSpace callback service. register a callback.

Parameters:

  • account_name (String)

    Required parameter: Account number.

  • body (DeviceLocationCallback)

    Required parameter: Request to

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



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

def register_callback(,
                      body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/callbacks/{accountName}',
                                 Server::DEVICE_LOCATION)
               .template_param(new_parameter(, key: 'accountName')
                                .should_encode(true))
               .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(CallbackRegistrationResult.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Error response.',
                             DeviceLocationResultException))
    .execute
end