Class: WhatsAppNotifier::Client
- Inherits:
-
Object
- Object
- WhatsAppNotifier::Client
- Defined in:
- lib/whatsapp_notifier/client.rb
Instance Method Summary collapse
- #connection_status(metadata: {}, provider: nil) ⇒ Object
- #deliver(to:, body:, metadata: {}, provider: nil, idempotency_key: nil) ⇒ Object
- #deliver_bulk(messages, provider: nil, sleeper: ->(seconds) { sleep(seconds) }, rng: Random.new) ⇒ Object
-
#initialize(configuration:) ⇒ Client
constructor
A new instance of Client.
- #scan_qr(metadata: {}, provider: nil) ⇒ Object
Constructor Details
#initialize(configuration:) ⇒ Client
Returns a new instance of Client.
3 4 5 6 |
# File 'lib/whatsapp_notifier/client.rb', line 3 def initialize(configuration:) @configuration = configuration @providers = {} end |
Instance Method Details
#connection_status(metadata: {}, provider: nil) ⇒ Object
26 27 28 |
# File 'lib/whatsapp_notifier/client.rb', line 26 def connection_status(metadata: {}, provider: nil) provider_for(provider || @configuration.provider).connection_status(metadata: ) end |
#deliver(to:, body:, metadata: {}, provider: nil, idempotency_key: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/whatsapp_notifier/client.rb', line 8 def deliver(to:, body:, metadata: {}, provider: nil, idempotency_key: nil) payload = { to: to, body: body, metadata: , idempotency_key: idempotency_key } provider_for(provider || @configuration.provider).deliver(payload) end |
#deliver_bulk(messages, provider: nil, sleeper: ->(seconds) { sleep(seconds) }, rng: Random.new) ⇒ Object
18 19 20 |
# File 'lib/whatsapp_notifier/client.rb', line 18 def deliver_bulk(, provider: nil, sleeper: ->(seconds) { sleep(seconds) }, rng: Random.new) Bulk::Dispatcher.new(client: self, configuration: @configuration, sleeper: sleeper, rng: rng).deliver(, provider: provider) end |
#scan_qr(metadata: {}, provider: nil) ⇒ Object
22 23 24 |
# File 'lib/whatsapp_notifier/client.rb', line 22 def scan_qr(metadata: {}, provider: nil) provider_for(provider || @configuration.provider).scan_qr(metadata: ) end |