Class: Verizon::UsageTriggerManagementApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/verizon/apis/usage_trigger_management_api.rb

Overview

UsageTriggerManagementApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Verizon::BaseApi

Instance Method Details

#create_new_trigger(body: nil) ⇒ ApiResponse

Create a new usage trigger, which will send an alert when the number of device location service transactions reaches a specified percentage of the monthly subscription amount. assignment.

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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

def create_new_trigger(body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/usage/triggers',
                                 Server::SUBSCRIPTION_SERVER)
               .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(UsageTriggerResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Unexpected error',
                             DeviceLocationResultException))
    .execute
end

#delete_trigger(account_name, trigger_id) ⇒ ApiResponse

eletes the specified usage trigger from the given account

Parameters:

  • account_name (String)

    Required parameter: Account name

  • trigger_id (String)

    Required parameter: Usage trigger ID

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/verizon/apis/usage_trigger_management_api.rb', line 68

def delete_trigger(,
                   trigger_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/usage/accounts/{accountName}/triggers/{triggerId}',
                                 Server::SUBSCRIPTION_SERVER)
               .template_param(new_parameter(, key: 'accountName')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(trigger_id, key: 'triggerId')
                                .is_required(true)
                                .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',
                             'Unexpected error',
                             DeviceLocationResultException))
    .execute
end

#update_trigger(trigger_id, body: nil) ⇒ ApiResponse

Update an existing usage trigger values

Parameters:

  • trigger_id (String)

    Required parameter: Usage trigger ID

  • body (UsageTriggerUpdateRequest) (defaults to: nil)

    Optional parameter: New trigger

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/verizon/apis/usage_trigger_management_api.rb', line 40

def update_trigger(trigger_id,
                   body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/usage/triggers/{triggerId}',
                                 Server::SUBSCRIPTION_SERVER)
               .template_param(new_parameter(trigger_id, key: 'triggerId')
                                .is_required(true)
                                .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(UsageTriggerResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Unexpected error',
                             DeviceLocationResultException))
    .execute
end