Module: TocDoc

Extended by:
Configurable
Defined in:
lib/toc_doc.rb,
lib/toc_doc/client.rb,
lib/toc_doc/core/error.rb,
lib/toc_doc/core/default.rb,
lib/toc_doc/core/version.rb,
lib/toc_doc/models/place.rb,
lib/toc_doc/models/agenda.rb,
lib/toc_doc/models/search.rb,
lib/toc_doc/core/uri_utils.rb,
lib/toc_doc/models/profile.rb,
lib/toc_doc/core/connection.rb,
lib/toc_doc/models/resource.rb,
lib/toc_doc/core/configurable.rb,
lib/toc_doc/models/speciality.rb,
lib/toc_doc/cache/memory_store.rb,
lib/toc_doc/core/authentication.rb,
lib/toc_doc/models/availability.rb,
lib/toc_doc/models/booking_info.rb,
lib/toc_doc/models/visit_motive.rb,
lib/toc_doc/models/search/result.rb,
lib/toc_doc/http/middleware/cache.rb,
lib/toc_doc/http/middleware/logging.rb,
lib/toc_doc/http/middleware/raise_error.rb,
lib/toc_doc/models/profile/organization.rb,
lib/toc_doc/models/profile/practitioner.rb,
lib/toc_doc/http/middleware/rate_limiter.rb,
lib/toc_doc/http/rate_limiter/token_bucket.rb,
lib/toc_doc/models/availability/collection.rb

Overview

The main module for TocDoc — a Ruby client for the Doctolib API.

Configuration can be set at the module level and will be inherited by every Client instance created via TocDoc.client or TocDoc.setup.

Examples:

Quick start

TocDoc.setup do |config|
  config.api_endpoint = 'https://www.doctolib.de'
end

TocDoc.availabilities(
  visit_motive_ids: 7_767_829,
  agenda_ids: 1_101_600,
  practice_ids: 377_272
)

See Also:

Defined Under Namespace

Modules: Authentication, Cache, Configurable, Connection, Default, Middleware, RateLimiter, UriUtils Classes: Agenda, Availability, BadRequest, BookingInfo, Client, ClientError, ConnectionError, Error, NotFound, Place, Profile, Resource, ResponseError, Search, ServerError, Speciality, TooManyRequests, UnprocessableEntity, VisitMotive

Constant Summary collapse

VERSION =

The current version of the TocDoc gem.

Returns:

  • (String)
'1.10.0'

Constants included from Configurable

Configurable::VALID_CONFIG_KEYS

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Configurable

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

Class Attribute Details

.clientTocDoc::Client

Returns a memoized Client configured with the current module-level options. A new client is created whenever the options have changed since the last call.

Returns:



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

def client
  if !defined?(@client) || @client.nil? || !@client.respond_to?(:same_options?) || !@client.same_options?(options)
    @client = TocDoc::Client.new(options)
  end
  @client
end

Class Method Details

.availabilitiesTocDoc::Availability::Collection

Returns available appointment slots.

Delegates to TocDoc::Availability.where — see that method for full parameter documentation.



75
76
77
# File 'lib/toc_doc.rb', line 75

def availabilities(**)
  TocDoc::Availability.where(**)
end

.booking_info(identifier) ⇒ TocDoc::BookingInfo

Fetches booking context data for a profile by slug or numeric ID.

Delegates to TocDoc::BookingInfo.find — see that method for full parameter documentation.

Parameters:

  • identifier (String, Integer)

    profile slug or numeric ID

Returns:



110
111
112
# File 'lib/toc_doc.rb', line 110

def booking_info(identifier)
  TocDoc::BookingInfo.find(identifier)
end

.profile(identifier) ⇒ TocDoc::Profile::Practitioner, TocDoc::Profile::Organization

Fetches a full profile page by slug or numeric ID.

Delegates to TocDoc::Profile.find — see that method for full parameter documentation.

Parameters:

  • identifier (String, Integer)

    profile slug or numeric ID

Returns:



99
100
101
# File 'lib/toc_doc.rb', line 99

def profile(identifier)
  TocDoc::Profile.find(identifier)
end

.searchTocDoc::Search::Result, ...

Queries the autocomplete / search endpoint.

Delegates to TocDoc::Search.where — see that method for full parameter documentation.

Returns:



88
89
90
# File 'lib/toc_doc.rb', line 88

def search(**)
  TocDoc::Search.where(**)
end

.setup {|config| ... } ⇒ TocDoc::Client

Configure TocDoc at the module level and return the client.

Examples:

TocDoc.setup do |config|
  config.api_endpoint = 'https://www.doctolib.de'
end

Yields:

  • (config)

    yields self so options can be set in a block

Yield Parameters:

Returns:

  • (TocDoc::Client)

    the memoized client, reflecting the new configuration



64
65
66
67
# File 'lib/toc_doc.rb', line 64

def setup
  yield self if block_given?
  client
end