Module: IpTracker::Client::Authentication

Defined in:
lib/ip_tracker/client/authentication.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auth_tokenObject

Returns the value of attribute auth_token.



4
5
6
# File 'lib/ip_tracker/client/authentication.rb', line 4

def auth_token
  @auth_token
end

#userObject (readonly)

Returns the value of attribute user.



5
6
7
# File 'lib/ip_tracker/client/authentication.rb', line 5

def user
  @user
end

Instance Method Details

#login(username, password) ⇒ Object

Raises:



7
8
9
10
11
12
13
14
15
# File 'lib/ip_tracker/client/authentication.rb', line 7

def (username, password)
  response = post("#{IpTracker::USERS_PATH}/#{username}/tokens",
                  :body => { :password => password })

  raise TargetError if response.code == 200

  @user = username
  @auth_token = response.token
end