class AnySMS::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/any_sms/backend/base.rb, line 11 def initialize(params = {}); end
Public Instance Methods
send_sms(_phone, _text, _args = {})
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/any_sms/backend/base.rb, line 19 def send_sms(_phone, _text, _args = {}) 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 AnySMS::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 [AnySMS::Reponse] Response
object with meta and status
# File lib/any_sms/backend/base.rb, line 33 def respond_with_status(status, meta: nil) AnySMS::Response.new(status: status, meta: meta) end