Class: ChessApi::Client
- Inherits:
-
Object
- Object
- ChessApi::Client
- Defined in:
- lib/chess_api/client.rb
Constant Summary collapse
- BASE_URL =
'https://api.chess.com/pub/'
Instance Method Summary collapse
- #connection ⇒ Object
- #daily_puzzle ⇒ Object
-
#initialize(adapter: Faraday.default_adapter) ⇒ Client
constructor
A new instance of Client.
- #monthly_game_archive ⇒ Object
- #player ⇒ Object
- #titled_player ⇒ Object
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
#connection ⇒ Object
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_puzzle ⇒ Object
26 27 28 |
# File 'lib/chess_api/client.rb', line 26 def daily_puzzle DailyPuzzleResource.new(self) end |
#monthly_game_archive ⇒ Object
22 23 24 |
# File 'lib/chess_api/client.rb', line 22 def monthly_game_archive MonthlyGameArchiveResource.new(self) end |
#player ⇒ Object
14 15 16 |
# File 'lib/chess_api/client.rb', line 14 def player PlayerResource.new(self) end |
#titled_player ⇒ Object
18 19 20 |
# File 'lib/chess_api/client.rb', line 18 def titled_player TitledPlayerResource.new(self) end |