Class: Client
- Inherits:
-
Object
- Object
- Client
- Defined in:
- lib/ft_42.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(username) ⇒ Client
constructor
A new instance of Client.
- #user ⇒ Object
- #user_sessions ⇒ Object
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
#token ⇒ Object (readonly)
Returns the value of attribute token.
33 34 35 |
# File 'lib/ft_42.rb', line 33 def token @token end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
33 34 35 |
# File 'lib/ft_42.rb', line 33 def username @username end |
Instance Method Details
#user ⇒ Object
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_sessions ⇒ Object
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 |