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.



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

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

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



33
34
35
# File 'lib/ft_42.rb', line 33

def token
  @token
end

#usernameObject (readonly)

Returns the value of attribute username.



33
34
35
# File 'lib/ft_42.rb', line 33

def username
  @username
end

Instance Method Details

#userObject



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

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

#user_sessionsObject



45
46
47
48
# File 'lib/ft_42.rb', line 45

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