class Noticed::DeliveryMethods::Vonage

Public Instance Methods

deliver() click to toggle source
# File lib/noticed/delivery_methods/vonage.rb, line 4
def deliver
  response = post("https://rest.nexmo.com/sms/json", json: format)
  status = response.parse.dig("messages", 0, "status")
  if !options[:ignore_failure] && status != "0"
    raise ResponseUnsuccessful.new(response)
  end

  response
end

Private Instance Methods

credentials() click to toggle source
# File lib/noticed/delivery_methods/vonage.rb, line 31
def credentials
  if (method = options[:credentials])
    notification.send(method)
  else
    Rails.application.credentials.vonage
  end
end
format() click to toggle source
# File lib/noticed/delivery_methods/vonage.rb, line 16
def format
  if (method = options[:format])
    notification.send(method)
  else
    {
      api_key: credentials[:api_key],
      api_secret: credentials[:api_secret],
      from: notification.params[:from],
      text: notification.params[:body],
      to: notification.params[:to],
      type: "unicode"
    }
  end
end