Class: Verizon::SmsApi

Inherits:
BaseApi show all
Defined in:
lib/verizon/apis/sms_api.rb

Overview

SmsApi

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

#list_devices_sms_messages(aname, mnext: nil) ⇒ ApiResponse

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

Parameters:

  • aname (String)

    Required parameter: Account name.

  • mnext (Integer) (defaults to: nil)

    Optional parameter: Continue the previous query

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

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

#send_sms_to_device(body) ⇒ ApiResponse

The messages are queued on the ThingSpace Platform and sent as soon as possible, but they may be delayed due to traffic and routing considerations.

Parameters:

Returns:

  • (ApiResponse)

    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/apis/sms_api.rb', line 14

def send_sms_to_device(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(DeviceManagementResult.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Error response.',
                             ConnectivityManagementResultException))
    .execute
end

#start_queued_sms_delivery(aname) ⇒ ApiResponse

Tells the ThingSpace Platform to start sending mobile-originated SMS messages through the EnhancedConnectivityService callback service. SMS messages from devices are queued until they are retrieved by your application, either by callback or synchronously with GET /sms/accountName/history.

Parameters:

  • aname (String)

    Required parameter: Account name.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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

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