Class: TocDoc::Client

Inherits:
Object
  • Object
show all
Includes:
Configurable, Connection, UriUtils
Defined in:
lib/toc_doc/client.rb

Overview

The main entry-point for interacting with the Doctolib API.

A +Client+ inherits the Configurable defaults set at the module level and can override any option per-instance.

Examples:

Creating a client with custom options

client = TocDoc::Client.new(
  api_endpoint: 'https://www.doctolib.de',
  per_page: 5
)

See Also:

Constant Summary

Constants included from Configurable

TocDoc::Configurable::VALID_CONFIG_KEYS

Instance Attribute Summary

Attributes included from Connection

#last_response

Instance Method Summary collapse

Methods included from UriUtils

#dashed_ids

Methods included from Connection

#get, #paginate

Methods included from Configurable

#configure, keys, #options, #pagination_depth=, #per_page=, #reset!, #same_options?

Constructor Details

#initialize(options = {}) ⇒ Client

Creates a new client instance.

Options are merged on top of the module-level Default values. Only keys present in TocDoc::Configurable.keys are accepted; unknown keys are silently ignored.

Examples:

TocDoc::Client.new(api_endpoint: 'https://www.doctolib.it')

Parameters:

  • options (Hash{Symbol => Object}) (defaults to: {})

    configuration overrides

Options Hash (options):

  • :api_endpoint (String)

    Base URL for API requests

  • :user_agent (String)

    User-Agent header value

  • :default_media_type (String)

    Accept / Content-Type header

  • :per_page (Integer)

    Results per page

  • :middleware (Faraday::RackBuilder)

    Custom Faraday middleware

  • :connection_options (Hash)

    Additional Faraday options



42
43
44
45
46
47
# File 'lib/toc_doc/client.rb', line 42

def initialize(options = {})
  reset!
  options.each do |key, value|
    public_send("#{key}=", value) if TocDoc::Configurable.keys.include?(key.to_sym)
  end
end