Module: MitakeSms

Defined in:
lib/mitake_sms.rb,
lib/mitake_sms/client.rb,
lib/mitake_sms/version.rb,
lib/mitake_sms/response.rb,
lib/mitake_sms/configuration.rb,
sig/mitake_sms.rbs

Defined Under Namespace

Classes: AuthenticationError, Client, Configuration, Error, InvalidRequestError, Response, ServerError

Constant Summary collapse

VERSION =

Returns:

  • (String)
"3.0.0"

Class Method Summary collapse

Class Method Details

.batch_send(messages, options = {}) ⇒ MitakeSms::Response+

Send multiple SMS messages in a single request The Mitake SMS API has a limit of 500 messages per request If more than 500 messages are provided, they will be automatically split into multiple requests

Parameters:

  • messages (Array<Hash>)

    array of message hashes Each hash requires :to and :text, and may include :client_id, :dlvtime, :vldtime, :destname and :response_url

  • options (Hash) (defaults to: {})

    any other documented SmBulkSend field

Returns:

Raises:

  • (ArgumentError)

    if a field other than :text contains '$$' or a line break



66
67
68
# File 'lib/mitake_sms.rb', line 66

def batch_send(messages, options = {})
  client.batch_send(messages, options)
end

.clientMitakeSms::Client

Create a new client with the current configuration

Returns:



34
35
36
# File 'lib/mitake_sms.rb', line 34

def client
  @client ||= Client.new
end

.configObject

Return the Dry::Configurable object directly



28
29
30
# File 'lib/mitake_sms.rb', line 28

def config
  Configuration.config
end

.configure {|MitakeSms::Configuration| ... } ⇒ Object

Configure the gem

Examples:

MitakeSms.configure do |config|
  config.username = 'your_username'
  config.password = 'your_password'
end

Yields:



22
23
24
# File 'lib/mitake_sms.rb', line 22

def configure
  yield(config) if block_given?
end

.send_sms(to:, text:, destname: nil, response_url: nil, client_id: nil, **options) ⇒ MitakeSms::Response

Send a single SMS message

Parameters:

  • to (String)

    recipient phone number

  • text (String)

    message content

  • destname (String) (defaults to: nil)

    recipient name or key value for system integration (optional)

  • response_url (String) (defaults to: nil)

    callback URL for delivery reports (optional)

  • client_id (String) (defaults to: nil)

    client reference ID (optional)

  • options (Hash)

    any other documented SmSend field

Returns:



46
47
48
49
50
51
52
53
54
55
# File 'lib/mitake_sms.rb', line 46

def send_sms(to:, text:, destname: nil, response_url: nil, client_id: nil, **options)
  client.send_sms(
    to: to,
    text: text,
    destname: destname,
    response_url: response_url,
    client_id: client_id,
    **options
  )
end