Class: ChessApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/chess_api/client.rb

Constant Summary collapse

BASE_URL =
'https://api.chess.com/pub/'

Instance Method Summary collapse

Constructor Details

#initialize(adapter: Faraday.default_adapter) ⇒ Client

Returns a new instance of Client.



10
11
12
# File 'lib/chess_api/client.rb', line 10

def initialize(adapter: Faraday.default_adapter)
  @adapter = adapter
end

Instance Method Details

#connectionObject



30
31
32
33
34
35
36
37
# File 'lib/chess_api/client.rb', line 30

def connection
  @connection ||= Faraday.new do |conn|
    conn.url_prefix = BASE_URL
    conn.request :json
    conn.response :json, content_type: 'application/json'
    conn.adapter @adapter
  end
end

#daily_puzzleObject



26
27
28
# File 'lib/chess_api/client.rb', line 26

def daily_puzzle
  DailyPuzzleResource.new(self)
end

#monthly_game_archiveObject



22
23
24
# File 'lib/chess_api/client.rb', line 22

def monthly_game_archive
  MonthlyGameArchiveResource.new(self)
end

#playerObject



14
15
16
# File 'lib/chess_api/client.rb', line 14

def player
  PlayerResource.new(self)
end

#titled_playerObject



18
19
20
# File 'lib/chess_api/client.rb', line 18

def titled_player
  TitledPlayerResource.new(self)
end