Class: CommandTower::Identity::PhoneVerification::SmsTransport::Adapters::FakeAdapter

Inherits:
Object
  • Object
show all
Defined in:
app/services/command_tower/identity/phone_verification/sms_transport/adapters/fake_adapter.rb

Overview

In-memory / no-network adapter for tests and local default.

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.deliveries ⇒ Object

Returns the value of attribute deliveries.



11
12
13
# File 'app/services/command_tower/identity/phone_verification/sms_transport/adapters/fake_adapter.rb', line 11

def deliveries
  @deliveries
end

.fail_with ⇒ Object

Returns the value of attribute fail_with.



11
12
13
# File 'app/services/command_tower/identity/phone_verification/sms_transport/adapters/fake_adapter.rb', line 11

def fail_with
  @fail_with
end

Class Method Details

.reset! ⇒ Object



13
14
15
16
# File 'app/services/command_tower/identity/phone_verification/sms_transport/adapters/fake_adapter.rb', line 13

def reset!
  self.deliveries = []
  self.fail_with = nil
end

Instance Method Details

#deliver(to:, body:) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'app/services/command_tower/identity/phone_verification/sms_transport/adapters/fake_adapter.rb', line 21

def deliver(to:, body:)
  if self.class.fail_with
    code, message = self.class.fail_with
    return SmsTransport::Result.new(success?: false, error_code: code, error_message: message)
  end

  self.class.deliveries << { to: to, body: body }
  SmsTransport::Result.new(success?: true, error_code: nil, error_message: nil)
end