Class: HeyYou::Channels::Nexmo
- Inherits:
-
Base
- Object
- Base
- HeyYou::Channels::Nexmo
- Defined in:
- lib/hey_you/channels/nexmo.rb
Defined Under Namespace
Classes: CredentialsNotExists, ResponseError
Constant Summary collapse
- ERROR_MESSAGES =
{ from_required: 'You must pass `from` globally (to configure) or in your notifications', config_required: 'You must pass `{%{options}}` to `configure``', to_required: 'You must pass `to` as option. Can not send sms to nowhere.', callback_required: 'You must pass `callback` to `configure` if `status_report_req` is true' }.freeze
Class Method Summary collapse
Class Method Details
.send!(builder, **options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hey_you/channels/nexmo.rb', line 19 def send!(builder, **) raise CredentialsNotExists, ERROR_MESSAGES[:config_required] % { options: required_credentials } unless credentials_present? raise CredentialsNotExists, ERROR_MESSAGES[:to_required] unless [:to] params = build_params(builder, **) result = config.nexmo.client.sms.send(params) config.nexmo.response_handler.call(result) if config.nexmo.response_handler result rescue ::Vonage::Error => e fail ResponseError, e end |