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.



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

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

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



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

def token
  @token
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

#userObject



38
39
40
41
# File 'lib/ft_42.rb', line 38

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

#user_sessionsObject



43
44
45
46
# File 'lib/ft_42.rb', line 43

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