Class: Vonage::SMS

Inherits:
Namespace
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/vonage/sms.rb

Instance Method Summary collapse

Instance Method Details

#send(params) ⇒ Object


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/vonage/sms.rb', line 96

def send(params)
  if unicode?(params.fetch(:text)) && params[:type] != 'unicode'
    message = 'Sending unicode text SMS without setting the type parameter to "unicode". ' \
      'See https://developer.nexmo.com/messaging/sms for details, ' \
      'or email [email protected] if you have any questions.'

    logger.warn(message)
  end

  response = request('/sms/json', params: hyphenate(params), type: Post)

  unless response.messages.first.status == '0'
    raise Error, response.messages.first[:error_text]
  end

  response
end