Class: Nexmo::SMS

Inherits:
Namespace
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/nexmo/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/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 [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