File: messaging.rb

package info (click to toggle)
ruby-telesign 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 104 kB
  • sloc: ruby: 254; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 1,092 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'telesign/rest'

MESSAGING_RESOURCE = '/v1/messaging'
MESSAGING_STATUS_RESOURCE = '/v1/messaging/%{reference_id}'

module Telesign

  # TeleSign's Messaging API allows you to easily send SMS messages. You can send alerts, reminders, and notifications,
  # or you can send verification messages containing one-time passcodes (OTP).
  class MessagingClient < RestClient

    # Send an SMS message to the target phone number.
    #
    # See https://developer.telesign.com/docs/messaging-api for detailed API documentation.
    def message(phone_number, message, message_type, **params)

      self.post(MESSAGING_RESOURCE,
                phone_number: phone_number,
                message: message,
                message_type: message_type,
                **params)
    end

    # Retrieve the status of an SMS transaction.
    #
    # See https://developer.telesign.com/docs/messaging-api for detailed API documentation.
    def status(reference_id, **params)

      self.get(MESSAGING_STATUS_RESOURCE % {:reference_id => reference_id},
               **params)
    end
  end
end