Class: Decidim::ActionDelegator::SmsGateway

Inherits:
Object
  • Object
show all
Defined in:
app/services/decidim/action_delegator/sms_gateway.rb

Constant Summary collapse

SMS_GATEWAY_PROVIDER_JOBS =
{
  som_connexio: SendSmsJob,
  twilio: TwilioSendSmsJob
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mobile_phone_number, code) ⇒ SmsGateway

Returns a new instance of SmsGateway.



13
14
15
16
# File 'app/services/decidim/action_delegator/sms_gateway.rb', line 13

def initialize(mobile_phone_number, code)
  @mobile_phone_number = mobile_phone_number
  @code = code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'app/services/decidim/action_delegator/sms_gateway.rb', line 6

def code
  @code
end

#mobile_phone_numberObject (readonly)

Returns the value of attribute mobile_phone_number.



6
7
8
# File 'app/services/decidim/action_delegator/sms_gateway.rb', line 6

def mobile_phone_number
  @mobile_phone_number
end

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'app/services/decidim/action_delegator/sms_gateway.rb', line 6

def response
  @response
end

Instance Method Details

#deliver_codeObject



18
19
20
21
22
23
24
# File 'app/services/decidim/action_delegator/sms_gateway.rb', line 18

def deliver_code
  return false unless sms_gateway_provider_valid?

  sms_gateway_job.perform_later(sender, mobile_phone_number, message)

  true
end