Class: WhatsAppNotifier::Configuration
- Inherits:
-
Object
- Object
- WhatsAppNotifier::Configuration
- Defined in:
- lib/whatsapp_notifier/configuration.rb
Instance Attribute Summary collapse
-
#bulk_base_delay_seconds ⇒ Object
Returns the value of attribute bulk_base_delay_seconds.
-
#bulk_jitter_seconds ⇒ Object
Returns the value of attribute bulk_jitter_seconds.
-
#bulk_max_attempts ⇒ Object
Returns the value of attribute bulk_max_attempts.
-
#bulk_max_recipients ⇒ Object
Returns the value of attribute bulk_max_recipients.
-
#bulk_retryable_error_codes ⇒ Object
Returns the value of attribute bulk_retryable_error_codes.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#warn_on_risky_provider ⇒ Object
Returns the value of attribute warn_on_risky_provider.
-
#web_adapter ⇒ Object
Returns the value of attribute web_adapter.
-
#web_automation_enabled ⇒ Object
Returns the value of attribute web_automation_enabled.
-
#web_session_path ⇒ Object
Returns the value of attribute web_session_path.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/whatsapp_notifier/configuration.rb', line 10 def initialize @provider = :web_automation @web_adapter = WebAdapter.new @web_session_path = "tmp/whatsapp_notifier/session.json" @bulk_base_delay_seconds = 1.0 @bulk_jitter_seconds = 0.3 @bulk_max_recipients = 500 @bulk_max_attempts = 3 @bulk_retryable_error_codes = %i[rate_limited network_error temporary_failure].freeze @logger = Logger.new($stdout) @web_automation_enabled = true @warn_on_risky_provider = true end |
Instance Attribute Details
#bulk_base_delay_seconds ⇒ Object
Returns the value of attribute bulk_base_delay_seconds.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def bulk_base_delay_seconds @bulk_base_delay_seconds end |
#bulk_jitter_seconds ⇒ Object
Returns the value of attribute bulk_jitter_seconds.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def bulk_jitter_seconds @bulk_jitter_seconds end |
#bulk_max_attempts ⇒ Object
Returns the value of attribute bulk_max_attempts.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def bulk_max_attempts @bulk_max_attempts end |
#bulk_max_recipients ⇒ Object
Returns the value of attribute bulk_max_recipients.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def bulk_max_recipients @bulk_max_recipients end |
#bulk_retryable_error_codes ⇒ Object
Returns the value of attribute bulk_retryable_error_codes.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def bulk_retryable_error_codes @bulk_retryable_error_codes end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def logger @logger end |
#provider ⇒ Object
Returns the value of attribute provider.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def provider @provider end |
#warn_on_risky_provider ⇒ Object
Returns the value of attribute warn_on_risky_provider.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def warn_on_risky_provider @warn_on_risky_provider end |
#web_adapter ⇒ Object
Returns the value of attribute web_adapter.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def web_adapter @web_adapter end |
#web_automation_enabled ⇒ Object
Returns the value of attribute web_automation_enabled.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def web_automation_enabled @web_automation_enabled end |
#web_session_path ⇒ Object
Returns the value of attribute web_session_path.
5 6 7 |
# File 'lib/whatsapp_notifier/configuration.rb', line 5 def web_session_path @web_session_path end |
Instance Method Details
#validate! ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/whatsapp_notifier/configuration.rb', line 24 def validate! raise ConfigurationError, "provider is required" if provider.nil? raise ConfigurationError, "only :web_automation provider is supported" unless provider.to_sym == :web_automation raise ConfigurationError, "bulk_max_recipients must be positive" if bulk_max_recipients.to_i <= 0 raise ConfigurationError, "bulk_max_attempts must be positive" if bulk_max_attempts.to_i <= 0 raise ConfigurationError, "web_adapter must be configured and respond to send_message, fetch_qr_code, connection_status" unless valid_web_adapter? end |