Class: Noticed::DeliveryMethods::VonageSms

Inherits:
Noticed::DeliveryMethod show all
Defined in:
lib/noticed/delivery_methods/vonage_sms.rb

Constant Summary collapse

DEFAULT_URL =
"https://rest.nexmo.com/sms/json"

Instance Attribute Summary

Attributes inherited from Noticed::DeliveryMethod

#config, #event, #notification

Instance Method Summary collapse

Methods inherited from Noticed::DeliveryMethod

#evaluate_option, #fetch_constant, #perform

Methods included from ApiClient

#post_request

Instance Method Details

#deliverObject



8
9
10
11
12
13
# File 'lib/noticed/delivery_methods/vonage_sms.rb', line 8

def deliver
  headers = evaluate_option(:headers)
  json = evaluate_option(:json)
  response = post_request url, headers: headers, json: json
  raise ResponseUnsuccessful.new(response, url, headers: headers, json: json) if JSON.parse(response.body).dig("messages", 0, "status") != "0"
end

#urlObject



15
16
17
# File 'lib/noticed/delivery_methods/vonage_sms.rb', line 15

def url
  evaluate_option(:url) || DEFAULT_URL
end