class Nexmo::SMS

Public Instance Methods

send(params) click to toggle source
# File lib/nexmo/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 support@nexmo.com 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

Private Instance Methods

unicode?(text) click to toggle source
# File lib/nexmo/sms.rb, line 117
def unicode?(text)
  !Nexmo::GSM7.encoded?(text)
end