Class: CommandTower::Messaging::Pushover::Adapters::FakeAdapter
- Inherits:
-
Object
- Object
- CommandTower::Messaging::Pushover::Adapters::FakeAdapter
- Defined in:
- app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb
Overview
In-memory / no-network adapter for tests and local development. Inject failures via FakeAdapter.fail_with = :invalid_user | :invalid_token | :invalid_credentials | :timeout | :provider_unavailable | :rate_limited
Class Attribute Summary collapse
-
.fail_with ⇒ Object
Returns the value of attribute fail_with.
-
.messages ⇒ Object
Returns the value of attribute messages.
-
.test_notifications ⇒ Object
Returns the value of attribute test_notifications.
-
.validations ⇒ Object
Returns the value of attribute validations.
Class Method Summary collapse
Instance Method Summary collapse
- #send_message!(user_key:, application_token:, title:, message:) ⇒ Object
- #send_test_notification!(user_key:, application_token:, title:, message:) ⇒ Object
- #validate_user!(user_key:, application_token:) ⇒ Object
Class Attribute Details
.fail_with ⇒ Object
Returns the value of attribute fail_with.
12 13 14 |
# File 'app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb', line 12 def fail_with @fail_with end |
.messages ⇒ Object
Returns the value of attribute messages.
12 13 14 |
# File 'app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb', line 12 def @messages end |
.test_notifications ⇒ Object
Returns the value of attribute test_notifications.
12 13 14 |
# File 'app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb', line 12 def test_notifications @test_notifications end |
.validations ⇒ Object
Returns the value of attribute validations.
12 13 14 |
# File 'app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb', line 12 def validations @validations end |
Class Method Details
.reset! ⇒ Object
14 15 16 17 18 19 |
# File 'app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb', line 14 def reset! self.validations = [] self.test_notifications = [] self. = [] self.fail_with = nil end |
Instance Method Details
#send_message!(user_key:, application_token:, title:, message:) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb', line 48 def (user_key:, application_token:, title:, message:) failure = injected_failure return failure if failure self.class. << { user_key_present: user_key.to_s.present?, application_token_present: application_token.to_s.present?, title: title.to_s, message: .to_s, } Result.ok(provider_request_id: "fake-request-#{self.class..size}") end |
#send_test_notification!(user_key:, application_token:, title:, message:) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb', line 35 def send_test_notification!(user_key:, application_token:, title:, message:) failure = injected_failure return failure if failure self.class.test_notifications << { user_key_present: user_key.to_s.present?, application_token_present: application_token.to_s.present?, title: title.to_s, message: .to_s, } Result.ok end |
#validate_user!(user_key:, application_token:) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb', line 24 def validate_user!(user_key:, application_token:) failure = injected_failure return failure if failure self.class.validations << { user_key_present: user_key.to_s.present?, application_token_present: application_token.to_s.present?, } Result.ok end |