Class: Verizon::SMSController
- Inherits:
-
BaseController
- Object
- BaseController
- Verizon::SMSController
- Defined in:
- lib/verizon/controllers/sms_controller.rb
Overview
SMSController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#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.
-
#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.
-
#start_queued_sms_delivery(aname) ⇒ ApiResponse
Tells the ThingSpace Platform to start sending mobile-originated SMS messages through the EnhancedConnectivityService callback service.
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
#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.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/verizon/controllers/sms_controller.rb', line 41 def (aname, mnext: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/m2m/v1/sms/{aname}/history', 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(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.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/verizon/controllers/sms_controller.rb', line 14 def send_sms_to_device(body) new_api_call_builder .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)) .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.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/verizon/controllers/sms_controller.rb', line 69 def start_queued_sms_delivery(aname) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/m2m/v1/sms/{aname}/startCallbacks', 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(ConnectivityManagementSuccessResult.method(:from_hash)) .is_api_response(true) .local_error('400', 'Error response.', ConnectivityManagementResultException)) .execute end |