Class: ActionTexter::NexmoClient
- Defined in:
- lib/action_texter/nexmo.rb
Overview
Implementation of client for Nexmo: nexmo.com
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
- #deliver(message) ⇒ Object
-
#initialize(key, secret) ⇒ NexmoClient
constructor
Create a new Nexmo client with key and secret.
- #to_s ⇒ Object
Methods inherited from Client
Constructor Details
#initialize(key, secret) ⇒ NexmoClient
Create a new Nexmo client with key and secret.
63 64 65 66 67 |
# File 'lib/action_texter/nexmo.rb', line 63 def initialize(key, secret) super() self.key = key self.secret = secret end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
57 58 59 |
# File 'lib/action_texter/nexmo.rb', line 57 def key @key end |
#secret ⇒ Object
Returns the value of attribute secret.
57 58 59 |
# File 'lib/action_texter/nexmo.rb', line 57 def secret @secret end |
Instance Method Details
#deliver(message) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/action_texter/nexmo.rb', line 69 def deliver() client = Net::HTTP.new("rest.nexmo.com", 443) client.use_ssl = true response = client.post( "/sms/json", URI.encode_www_form("username" => @key, "password" => @secret, "from" => .from, "to" => .to, "text" => .text, "client-ref" => .reference), {"Content-Type" => "application/x-www-form-urlencoded"}) return ActionTexter::NexmoResponse.new(response.body) end |
#to_s ⇒ Object
86 87 88 |
# File 'lib/action_texter/nexmo.rb', line 86 def to_s "#<#{self.class.name}:#{key}>" end |