class ActiveSMS::Backend::Base

Base class for any sms provider service. Provides basic structure and helper methods. While not necessary to be subclassed now, may be necessary later.

Public Class Methods

new(params = {}) click to toggle source

In initializer you may accept secrets which were defined in initializer or other configuration options if any.

@param params [Hash] List of arguments received from configure code.

# File lib/active_sms/backend/base.rb, line 11
def initialize(params = {})
end

Public Instance Methods

send_sms(_phone, _text) click to toggle source

Interface for sending sms. Every subclass should implement method itself. Raises error in default implementation.

@param _phone [String] Phone number to send sms (not used in this implementation) @param _text [String] Sms text (not used in this implementation)

# File lib/active_sms/backend/base.rb, line 20
def send_sms(_phone, _text)
  raise NotImplementedError,
        "You should create your own class for every sms service you use"
end

Protected Instance Methods

respond_with_status(status, meta: nil) click to toggle source

Returns ActiveSMS::Reponse object with status and meta

@param status [Symbol]

Query status, any other than :success considered as failure

@param meta [Hash]

Optional metadata you can return from api or implementation

@return [ActiveSMS::Reponse] Response object with meta and status

# File lib/active_sms/backend/base.rb, line 34
def respond_with_status(status, meta: nil)
  ActiveSMS::Response.new(status: status, meta: meta)
end