Class: Hoot::Client
- Inherits:
-
Object
- Object
- Hoot::Client
- Defined in:
- lib/hoot/client.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#hedwig ⇒ Object
Returns the value of attribute hedwig.
Instance Method Summary collapse
- #authenticate(credentials) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #push(message = nil) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
17 18 19 |
# File 'lib/hoot/client.rb', line 17 def initialize @hedwig = ENV['HEDWING_ENDPOINT'] || HEDWING_ENDPOINT end |
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
15 16 17 |
# File 'lib/hoot/client.rb', line 15 def credentials @credentials end |
#hedwig ⇒ Object
Returns the value of attribute hedwig.
14 15 16 |
# File 'lib/hoot/client.rb', line 14 def hedwig @hedwig end |
Instance Method Details
#authenticate(credentials) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hoot/client.rb', line 46 def authenticate(credentials) data = { :credentials => { :email => credentials[0], :password => credentials[1] } } response = request('authenticate', data) if response['result'] Hoot::Keychain.save(credentials) abort('Authentication successful.') end puts 'Authentication failed.' Hoot::User::login end |
#push(message = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/hoot/client.rb', line 21 def push( = nil) @credentials = Hoot::Keychain::credentials if .nil? = 'Hoot! Your command has completed! Come back!' end data = { :credentials => { :email => @credentials[0], :password => @credentials[1] }, :message => , :metadata => Hoot::Metadata.get } response = request('send', data) if response['result'] abort('A Hoot was sent to your device.') end abort('A server error occurred.') end |