Class: Verizon::DeviceSmsMessagingApi

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

Overview

DeviceSmsMessagingApi

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

#get_sms_messages(account_name, mnext: nil) ⇒ ApiResponse

Retrieves queued SMS messages sent by all M2M MC devices associated with an account. the pageUrl in Location Header

Parameters:

  • account_name (String)

    Required parameter: Numeric account name

  • mnext (String) (defaults to: nil)

    Optional parameter: Continue the previous query from

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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/device_sms_messaging_api.rb', line 42

def get_sms_messages(,
                     mnext: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/m2m/v1/sms/{accountName}/history',
                                 Server::THINGSPACE)
               .template_param(new_parameter(, key: 'accountName')
                                .is_required(true)
                                .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(SmsMessagesResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Error response',
                             GioRestErrorResponseException))
    .execute
end

#list_sms_message_history(body) ⇒ ApiResponse

Returns a list of sms history for a given device during a specified time frame.

Parameters:

Returns:

  • (ApiResponse)

    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
# File 'lib/verizon/apis/device_sms_messaging_api.rb', line 91

def list_sms_message_history(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/m2m/v1/devices/sms/history/actions/list',
                                 Server::THINGSPACE)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .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(GioRequestResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Error response',
                             GioRestErrorResponseException))
    .execute
end

#send_an_sms_message(body) ⇒ ApiResponse

Sends an SMS message to one device. Messages are queued on the M2M MC Platform and sent as soon as possible, but they may be delayed due to traffic and routing considerations. indiividual device.

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
34
# File 'lib/verizon/apis/device_sms_messaging_api.rb', line 15

def send_an_sms_message(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/m2m/v1/sms',
                                 Server::THINGSPACE)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .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(GioRequestResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Error response',
                             GioRestErrorResponseException))
    .execute
end

#start_sms_message_delivery(account_name) ⇒ ApiResponse

Starts delivery of SMS messages for the specified account.

Parameters:

  • account_name (String)

    Required parameter: Numeric account name

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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

def start_sms_message_delivery()
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/m2m/v1/sms/{accountName}/startCallbacks',
                                 Server::THINGSPACE)
               .template_param(new_parameter(, key: 'accountName')
                                .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(SuccessResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Error response',
                             GioRestErrorResponseException))
    .execute
end