Sha256: 625adc40a4979d7a37577d28660547e9e73d8d5ca568cf25bd9d1c3671636ede

Contents?: true

Size: 462 Bytes

Versions: 1

Compression:

Stored size: 462 Bytes

Contents

require_relative 'Exceptions/InvalidRights'
require 'json'

class User

  def initialize(token)
    @token = token
  end

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
epitech_api-0.1.0 lib/epitech_api/User.rb