Class: Verizon::AccountsController

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

Overview

AccountsController

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

#get_account_information(aname) ⇒ ApiResponse

Returns information about a specified account.

Parameters:

  • aname (String)

    Required parameter: Account name.

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



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

def (aname)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/m2m/v1/accounts/{aname}',
                                 Server::THINGSPACE)
               .template_param(new_parameter(aname, key: 'aname')
                                .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(Account.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Error response.',
                             ConnectivityManagementResultException))
    .execute
end

#list_account_leads(aname, mnext: nil) ⇒ ApiResponse

When HTTP status is 202, a URL will be returned in the Location header of the form /leads/aname?next=token. This URL can be used to request the next set of leads. from the pageUrl in Location Header.

Parameters:

  • aname (String)

    Required parameter: Account name.

  • mnext (Integer) (defaults to: nil)

    Optional parameter: Continue the previous query

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/verizon/controllers/accounts_controller.rb', line 61

def (aname,
                       mnext: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/m2m/v1/leads/{aname}',
                                 Server::THINGSPACE)
               .template_param(new_parameter(aname, key: 'aname')
                                .should_encode(true))
               .query_param(new_parameter(mnext, key: 'next'))
               .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(AccountLeadsResult.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Error response.',
                             ConnectivityManagementResultException))
    .execute
end

#list_account_states_and_services(aname) ⇒ ApiResponse

Returns a list and details of all custom services and states defined for a specified account.

Parameters:

  • aname (String)

    Required parameter: Account name.

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



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

def (aname)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/m2m/v1/accounts/{aname}/statesandservices',
                                 Server::THINGSPACE)
               .template_param(new_parameter(aname, key: 'aname')
                                .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(AccountStatesAndServices.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Error response.',
                             ConnectivityManagementResultException))
    .execute
end