Class: MetaSms::ProviderUtility
- Inherits:
-
Object
- Object
- MetaSms::ProviderUtility
- Defined in:
- lib/meta_sms/providers/provider_utility.rb
Overview
This is a utility class for sms providers. This encapsulates some common class methods as
> raise_low_balance_exception
This method will be used to raise an exception if the balance in sms service provider account is low.
This method can be called in the respective sms provider class. eg: sms_box.rb.
> raise_error_for_blank_value
This method is used to raise ArgumentError. This can be called in the sms_provider_interface (i_sms_provider) in order to raise the exception is value of any
required option is blank.
> check_required_config_param
This method is used to check presence of required config variables. It can be called in the respective sms provider class. eg: sms_box.rb.
Class Method Summary collapse
-
.authentication_error ⇒ Object
This method will raise authentication error.
-
.check_required_config_param(config_param) ⇒ Object
This method is used to check presence of required config variables.
-
.raise_error_for_blank_value(key) ⇒ Object
This method will raise ArgumentError.
-
.raise_low_balance_exception ⇒ Object
This method will raise low balance error.
Class Method Details
.authentication_error ⇒ Object
This method will raise authentication error
53 54 55 |
# File 'lib/meta_sms/providers/provider_utility.rb', line 53 def self.authentication_error raise SecurityError.new 'Authentication Failed. Please Try Again.' end |
.check_required_config_param(config_param) ⇒ Object
This method is used to check presence of required config variables
24 25 26 27 28 29 30 |
# File 'lib/meta_sms/providers/provider_utility.rb', line 24 def self.check_required_config_param(config_param) value = eval "MetaSms.config.#{config_param}" if value.blank? raise ArgumentError.new "Property #{config_param} is not found. Please check required parameters in initializer file (config/initializers/meta_sms.rb)." end value end |
.raise_error_for_blank_value(key) ⇒ Object
This method will raise ArgumentError
37 38 39 |
# File 'lib/meta_sms/providers/provider_utility.rb', line 37 def self.raise_error_for_blank_value(key) raise ArgumentError.new "No #{key} found." end |
.raise_low_balance_exception ⇒ Object
This method will raise low balance error
45 46 47 |
# File 'lib/meta_sms/providers/provider_utility.rb', line 45 def self.raise_low_balance_exception raise MetaSmsError.new "Your balance is low for sending message." end |