Class: EpitechApi::User
- Inherits:
-
Object
- Object
- EpitechApi::User
- Defined in:
- lib/epitech_api/user.rb
Instance Method Summary collapse
- #gatherer ⇒ Object
- #info ⇒ Object
-
#initialize(token) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(token) ⇒ User
Returns a new instance of User.
8 9 10 |
# File 'lib/epitech_api/user.rb', line 8 def initialize(token) @token = token end |
Instance Method Details
#gatherer ⇒ Object
12 13 14 |
# File 'lib/epitech_api/user.rb', line 12 def gatherer Gatherer.new @token end |
#info ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/epitech_api/user.rb', line 16 def info uri = URI('https://intra.epitech.eu/user/?format=json') req = Net::HTTP::Get.new uri req['Cookie'] = "#{@token}" http = Net::HTTP.new(uri.hostname, uri.port) http.use_ssl = true response = http.request req raise InvalidRights unless response.code.to_i == 200 JSON.parse response.body end |