Class: Rushover::Client
- Inherits:
-
Object
- Object
- Rushover::Client
- Defined in:
- lib/rushover.rb
Constant Summary collapse
- BASE_URL =
"https://api.pushover.net/1".freeze
- MESSAGES_ENDPOINT =
"#{BASE_URL}/messages.json".freeze
- VALIDATE_ENDPOINT =
"#{BASE_URL}/users/validate.json".freeze
- RECEIPT_ENDPOINT =
"#{BASE_URL}/receipts/%s.json".freeze
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
- #notify(user_key, message, options = {}) ⇒ Object
- #receipt(id) ⇒ Object
- #validate(user_key, device = nil) ⇒ Object
- #validate!(user_key, device = nil) ⇒ Object
Constructor Details
#initialize(token) ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/rushover.rb', line 14 def initialize(token) @token = token end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
12 13 14 |
# File 'lib/rushover.rb', line 12 def token @token end |
Instance Method Details
#notify(user_key, message, options = {}) ⇒ Object
18 19 20 21 22 |
# File 'lib/rushover.rb', line 18 def notify(user_key, , = {}) data = { :token => token, :user => user_key, :message => } data.merge!() post_json(MESSAGES_ENDPOINT, data) end |
#receipt(id) ⇒ Object
34 35 36 37 38 |
# File 'lib/rushover.rb', line 34 def receipt(id) data = { :token => token } url = RECEIPT_ENDPOINT % id get_json(url, data) end |
#validate(user_key, device = nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/rushover.rb', line 24 def validate(user_key, device = nil) data = { :token => token, :user => user_key } data[:device] = device if device post_json(VALIDATE_ENDPOINT, data) end |
#validate!(user_key, device = nil) ⇒ Object
30 31 32 |
# File 'lib/rushover.rb', line 30 def validate!(user_key, device = nil) validate(user_key, device).ok? end |