Sha256: 6f6562dff22d75449f24615e3c0b0a9be1270594ecb0271216b89f1451c3caae

Contents?: true

Size: 565 Bytes

Versions: 1

Compression:

Stored size: 565 Bytes

Contents

require 'json'
require_relative 'Exceptions/invalid_rights'
require_relative 'gatherer'

class User

  def initialize(token)
    @token = token
  end

  def gatherer
    Gatherer.new @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.1 lib/epitech_api/user.rb