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

Defined Under Namespace

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

Constant Summary collapse

VERSION =
"2.0.0"

Class Method Summary collapse

Class Method Details

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

Returns response object or array of response objects if batch was split.

Returns:



99
100
101
# File 'lib/mitake_sms.rb', line 99

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

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

Returns response object or array of response objects if batch was split.

Returns:



69
70
71
# File 'lib/mitake_sms.rb', line 69

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

.batch_send_with_limit(messages, limit = 500, options = {}) ⇒ MitakeSms::Response+

Returns response object or array of response objects if batch was split.

Returns:



81
82
83
# File 'lib/mitake_sms.rb', line 81

def batch_send_with_limit(messages, limit = 500, options = {})
  client.batch_send_with_limit(messages, limit, 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, charset: 'UTF8', **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)

  • charset (String) (defaults to: 'UTF8')

    character encoding, defaults to ‘UTF8’ (optional)

  • options (Hash)

    additional options (optional)

Returns:



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

def send_sms(to:, text:, destname: nil, response_url: nil, client_id: nil, charset: 'UTF8', **options)
  # Forward all parameters to the client method using named parameters
  client.send_sms(
    to: to,
    text: text,
    destname: destname,
    response_url: response_url,
    client_id: client_id,
    charset: charset,
    **options
  )
end