Class: CommandTower::Messaging::Execution::Adapters::Sms::Configuration

Inherits:
Object
  • Object
show all
Defined in:
app/services/command_tower/messaging/execution/adapters/sms/configuration.rb

Overview

Platform readiness detector for notification SMS. Ready only when adapter is twilio and credentials + sender are complete. disabled / fake / log never count as platform_configured.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.sms_configured?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/services/command_tower/messaging/execution/adapters/sms/configuration.rb', line 12

def self.sms_configured?
  new.sms_configured?
end

Instance Method Details

#account_sidObject



26
27
28
# File 'app/services/command_tower/messaging/execution/adapters/sms/configuration.rb', line 26

def 
  CredentialResolution.resolve(:twilio).
end

#adapter_nameObject



22
23
24
# File 'app/services/command_tower/messaging/execution/adapters/sms/configuration.rb', line 22

def adapter_name
  CommandTower.config.messaging.sms.adapter.to_s
end

#auth_tokenObject



30
31
32
# File 'app/services/command_tower/messaging/execution/adapters/sms/configuration.rb', line 30

def auth_token
  CredentialResolution.resolve(:twilio).auth_token
end

#from_numberObject



39
40
41
42
43
44
# File 'app/services/command_tower/messaging/execution/adapters/sms/configuration.rb', line 39

def from_number
  configured = CommandTower.config.messaging.sms.from_number.to_s.strip.presence
  configured ||
    ENV["TWILIO_FROM"].to_s.strip.presence ||
    ENV["TWILIO_FROM_NUMBER"].to_s.strip.presence
end

#messaging_service_sidObject

Prefer Messaging Service SID when both sender mechanisms are set.



35
36
37
# File 'app/services/command_tower/messaging/execution/adapters/sms/configuration.rb', line 35

def messaging_service_sid
  CommandTower.config.messaging.sms.messaging_service_sid.to_s.strip.presence
end

#sender_identity_present?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/services/command_tower/messaging/execution/adapters/sms/configuration.rb', line 46

def sender_identity_present?
  messaging_service_sid.present? || from_number.present?
end

#sms_configured?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'app/services/command_tower/messaging/execution/adapters/sms/configuration.rb', line 16

def sms_configured?
  return false unless adapter_name == "twilio"

  .present? && auth_token.present? && sender_identity_present?
end

#use_messaging_service?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'app/services/command_tower/messaging/execution/adapters/sms/configuration.rb', line 50

def use_messaging_service?
  messaging_service_sid.present?
end