Class: Amee::Service
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
Class Method Summary collapse
Instance Method Summary collapse
- #delete(method, path, options = {}) ⇒ Object
- #get(method, path, options = {}) ⇒ Object
-
#initialize(auth_token) ⇒ Service
constructor
A new instance of Service.
- #post(method, path, options = {}) ⇒ Object
- #put(method, path, options = {}) ⇒ Object
Constructor Details
#initialize(auth_token) ⇒ Service
Returns a new instance of Service.
9 10 11 |
# File 'lib/amee/service.rb', line 9 def initialize(auth_token) @auth_token = auth_token end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
7 8 9 |
# File 'lib/amee/service.rb', line 7 def auth_token @auth_token end |
Class Method Details
.auth_token(username, password, path) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/amee/service.rb', line 29 def self.auth_token(username, password, path) response = Net::HTTP.post_form( URI.parse("http://#{Amee::Config[:server]}#{path}"), {'username'=> username, 'password'=>password} ) response['authToken'] rescue Errno::ECONNREFUSED, SocketError raise Amee::Session::ServerNotFound, "Amee Server could not be found" end |
Instance Method Details
#delete(method, path, options = {}) ⇒ Object
25 26 27 |
# File 'lib/amee/service.rb', line 25 def delete(method, path, = {}) perform_request(:delete, method, full_path(path), ) end |
#get(method, path, options = {}) ⇒ Object
17 18 19 |
# File 'lib/amee/service.rb', line 17 def get(method, path, = {}) perform_request(:get, method,full_path(path), ) end |
#post(method, path, options = {}) ⇒ Object
13 14 15 |
# File 'lib/amee/service.rb', line 13 def post(method, path, = {}) perform_request(:post, method, full_path(path), ) end |
#put(method, path, options = {}) ⇒ Object
21 22 23 |
# File 'lib/amee/service.rb', line 21 def put(method, path, = {}) perform_request(:put, method, full_path(path), ) end |