Class: MetaSms::ISmsProvider
- Inherits:
-
Object
- Object
- MetaSms::ISmsProvider
- Defined in:
- lib/meta_sms/providers/i_sms_provider.rb
Overview
ISmsProvider acts as an interface for all sms providers in this gem. It has a method send_sms, which every sms provider class must override or else error will be thrown. There is a constant REQUIRED_OPTIONS, which represents the required options in order to send message. for now, message_text and mobile_number is the only options that are required.
> ‘Sms provider class’ refers to the class which is a sms service provider and which inherits ISmsProvider. eg: providers/sms_box.rb
Direct Known Subclasses
Constant Summary collapse
- REQUIRED_OPTIONS =
[:message_text, :mobile_number]
Instance Method Summary collapse
- #check_for_valid_mobile_number(mobile_number) ⇒ Object
-
#check_required_option(required_option_key) ⇒ Object
This method checks the presence of the value of the required options key This is called in sms provider class.
-
#initialize(options) ⇒ ISmsProvider
constructor
Initialize options.
-
#send_sms ⇒ Object
Method to overide in every sms provider class in order to send sms.
Constructor Details
#initialize(options) ⇒ ISmsProvider
here message_text and mobile_number are required params and others are optional
Initialize options
23 24 25 |
# File 'lib/meta_sms/providers/i_sms_provider.rb', line 23 def initialize() @options = end |
Instance Method Details
#check_for_valid_mobile_number(mobile_number) ⇒ Object
50 51 52 |
# File 'lib/meta_sms/providers/i_sms_provider.rb', line 50 def check_for_valid_mobile_number(mobile_number) mobile_number end |
#check_required_option(required_option_key) ⇒ Object
This method checks the presence of the value of the required options key This is called in sms provider class.
41 42 43 44 45 46 47 48 |
# File 'lib/meta_sms/providers/i_sms_provider.rb', line 41 def check_required_option(required_option_key) value = @options[required_option_key] if value.blank? ProviderUtility.raise_error_for_blank_value(required_option_key) else value end end |
#send_sms ⇒ Object
Method to overide in every sms provider class in order to send sms
31 32 33 |
# File 'lib/meta_sms/providers/i_sms_provider.rb', line 31 def send_sms raise NotImplementedError, "send_sms" end |