Class: SpreeCmCommissioner::TelegramGateway::PinCodeSender
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::TelegramGateway::PinCodeSender
- Defined in:
- app/services/spree_cm_commissioner/telegram_gateway/pin_code_sender.rb
Overview
Sends an OTP through Telegram Gateway’s sendVerificationMessage endpoint. Telegram generates the OTP code itself; we never see the digits. Verification flows through Telegram via PinCode#verify_with_telegram.
The Telegram request_id was already persisted into pin_code.code by PinCodeSender (synchronously, from checkSendAbility), so verification works even if the user types the code before this job runs.
On any failure: mark the SmsLog row :failed, log to the debug channel, and re-raise so Sidekiq’s normal retry kicks in. There is NO in-flight fallback to SMS — we don’t have an OTP code to send via SMS, since Telegram generated it.
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#pin_code ⇒ Object
readonly
Returns the value of attribute pin_code.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#tenant_id ⇒ Object
readonly
Returns the value of attribute tenant_id.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(pin_code:, from:, request_id:, tenant_id:) ⇒ PinCodeSender
constructor
A new instance of PinCodeSender.
Constructor Details
#initialize(pin_code:, from:, request_id:, tenant_id:) ⇒ PinCodeSender
Returns a new instance of PinCodeSender.
22 23 24 25 26 27 |
# File 'app/services/spree_cm_commissioner/telegram_gateway/pin_code_sender.rb', line 22 def initialize(pin_code:, from:, request_id:, tenant_id:) @pin_code = pin_code @from = from @request_id = request_id @tenant_id = tenant_id end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
16 17 18 |
# File 'app/services/spree_cm_commissioner/telegram_gateway/pin_code_sender.rb', line 16 def from @from end |
#pin_code ⇒ Object (readonly)
Returns the value of attribute pin_code.
16 17 18 |
# File 'app/services/spree_cm_commissioner/telegram_gateway/pin_code_sender.rb', line 16 def pin_code @pin_code end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
16 17 18 |
# File 'app/services/spree_cm_commissioner/telegram_gateway/pin_code_sender.rb', line 16 def request_id @request_id end |
#tenant_id ⇒ Object (readonly)
Returns the value of attribute tenant_id.
16 17 18 |
# File 'app/services/spree_cm_commissioner/telegram_gateway/pin_code_sender.rb', line 16 def tenant_id @tenant_id end |
Class Method Details
.call(pin_code:, from:, request_id:, tenant_id:) ⇒ Object
18 19 20 |
# File 'app/services/spree_cm_commissioner/telegram_gateway/pin_code_sender.rb', line 18 def self.call(pin_code:, from:, request_id:, tenant_id:) new(pin_code: pin_code, from: from, request_id: request_id, tenant_id: tenant_id).call end |
Instance Method Details
#call ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/services/spree_cm_commissioner/telegram_gateway/pin_code_sender.rb', line 29 def call raise ArgumentError, I18n.t('pincode_sender.pincode.blank') if pin_code.nil? begin create_sms_log rescue StandardError => e @sms_log&.update(error: e., status: :failed) log_error_to_telegram(e.) raise end end |