Class: WhatsAppNotifier::Session::QrService
- Inherits:
-
Object
- Object
- WhatsAppNotifier::Session::QrService
- Defined in:
- lib/whatsapp_notifier/session/qr_service.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #activate!(token) ⇒ Object
-
#initialize(store:, adapter:) ⇒ QrService
constructor
A new instance of QrService.
- #qr_code(metadata: {}) ⇒ Object
Constructor Details
#initialize(store:, adapter:) ⇒ QrService
Returns a new instance of QrService.
6 7 8 9 |
# File 'lib/whatsapp_notifier/session/qr_service.rb', line 6 def initialize(store:, adapter:) @store = store @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
4 5 6 |
# File 'lib/whatsapp_notifier/session/qr_service.rb', line 4 def adapter @adapter end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
4 5 6 |
# File 'lib/whatsapp_notifier/session/qr_service.rb', line 4 def store @store end |
Instance Method Details
#activate!(token) ⇒ Object
19 20 21 22 |
# File 'lib/whatsapp_notifier/session/qr_service.rb', line 19 def activate!(token) session = store.load store.save(session.merge(active: true, token: token, qr_code: nil)) end |
#qr_code(metadata: {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/whatsapp_notifier/session/qr_service.rb', line 11 def qr_code(metadata: {}) generated = adapter.fetch_qr_code(metadata: ) # We don't cache the QR code because it expires every ~20 seconds # The underlying adapter/service is responsible for providing the latest one generated end |