Sha256: 39d1eb340b62aee0f6ee3d74b342d5beab76b08f6ec4f3dbc10ed6251fc0d02a
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
require "net/http" require "http" module Lichess class Client attr_reader :token def initialize(token) @token = token end def users @users_gateway ||= UsersGateway.new(self) end def games @games_gateway ||= GamesGateway.new(self) end def get(path, http_headers: {}) url = "#{base_url}#{path}" http_headers[:accept] ||= "application/vnd.lichess.v3+json" http_headers[:content_type] ||= "application/json" http_headers[:authorization] ||= "Bearer #{@token}" response = HTTP .headers(http_headers) .get(url) return response end def post(path, body: nil, http_headers: {}) url = "#{base_url}#{path}" http_headers[:accept] ||= "application/vnd.lichess.v3+json" http_headers[:content_type] ||= "application/json" response = HTTP .headers(http_headers) .post(url) return response end private def base_url "https://lichess.org" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-lichess-0.1.0 | lib/lichess/client.rb |