lib/epitech_api/user.rb in epitech_api-0.1.1 vs lib/epitech_api/user.rb in epitech_api-0.1.2
- old
+ new
@@ -1,29 +1,31 @@
require 'json'
require_relative 'Exceptions/invalid_rights'
require_relative 'gatherer'
-class User
+module EpitechApi
+ class User
- def initialize(token)
- @token = token
- end
+ def initialize(token)
+ @token = token
+ end
- def gatherer
- Gatherer.new @token
- end
+ def gatherer
+ Gatherer.new @token
+ end
- def info
- uri = URI('https://intra.epitech.eu/user/?format=json')
+ def info
+ uri = URI('https://intra.epitech.eu/user/?format=json')
- req = Net::HTTP::Get.new uri
- req['Cookie'] = "#{@token}"
+ req = Net::HTTP::Get.new uri
+ req['Cookie'] = "#{@token}"
- http = Net::HTTP.new(uri.hostname, uri.port)
- http.use_ssl = true
+ http = Net::HTTP.new(uri.hostname, uri.port)
+ http.use_ssl = true
- response = http.request req
+ response = http.request req
- raise InvalidRights unless response.code.to_i == 200
- JSON.parse response.body
+ raise InvalidRights unless response.code.to_i == 200
+ JSON.parse response.body
+ end
end
end
\ No newline at end of file