Class: Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ft_42.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username) ⇒ Client

Returns a new instance of Client.



30
31
32
33
# File 'lib/ft_42.rb', line 30

def initialize(username)
  @username = username
  @token    = Token.new.token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



28
29
30
# File 'lib/ft_42.rb', line 28

def token
  @token
end

#usernameObject (readonly)

Returns the value of attribute username.



28
29
30
# File 'lib/ft_42.rb', line 28

def username
  @username
end

Instance Method Details

#userObject



35
36
37
38
# File 'lib/ft_42.rb', line 35

def user
  puts "Getting #{username}'s info..."
  token.get("/v2/users/#{username}", params: { per_page: 100 }).parsed
end

#user_sessionsObject



40
41
42
43
# File 'lib/ft_42.rb', line 40

def user_sessions
  puts "Getting #{username}'s session this week..."
  token.get("/v2/users/#{username}/locations?range[begin_at]=#{time_ago},#{right_now}", params: { per_page: 100 }).parsed
end