Module: SmsRu::Client::Api::Sms

Included in:
SmsRu::Client::Api
Defined in:
lib/sms_ru/client/api/sms.rb

Constant Summary collapse

SEND_PATH =
'sms/send'.freeze

Instance Method Summary collapse

Instance Method Details

#send_sms(request) ⇒ SmsRu::Responses::SendSms

Parameters:

Returns:

Raises:

  • (SmsRu::Responses::SendSms::Error)


11
12
13
14
15
16
17
18
19
# File 'lib/sms_ru/client/api/sms.rb', line 11

def send_sms(request)
  request = Requests::SendSms.new(request) unless request.is_a?(Requests::SendSms)
  response = http_post(SEND_PATH, params: request)
  json = JSON.parse(response.body)
  result = Responses::SendSms.new(json)
  return result if result.success?

  raise result.to_error
end