Sha256: 8cbe625858f69a973716b68a14b670b51c0d2208ab294b78f25ebcf6c7b27b01
Contents?: true
Size: 910 Bytes
Versions: 3
Compression:
Stored size: 910 Bytes
Contents
require "json" module Lichess class UsersGateway attr_reader :client def initialize(client) @client = client end def get(username) path = "/api/user/#{username}" result = @client.get(path) if result.code == 404 raise Lichess::Exception::UserNotFound.new("#{username} not found") end JSON.parse(result.body) end def activity(username) path = "/api/user/#{username}/activity" result = @client.get(path) if result.body.to_s == "[]" raise Lichess::Exception::UserNotFound.new("#{username} not found") end JSON.parse(result.body) end def all_top_ten path = "/player" JSON.parse(@client.get(path).body) end def leaderboard(variant, number_of_users = 10) path = "/player/top/#{number_of_users}/#{variant}" JSON.parse(@client.get(path).body) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby-lichess-0.2.1 | lib/lichess/users_gateway.rb |
ruby-lichess-0.2.0 | lib/lichess/users_gateway.rb |
ruby-lichess-0.1.0 | lib/lichess/users_gateway.rb |