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


22
23
24
25
26
27
28
29
# File 'lib/chess_api/client.rb', line 22

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

#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