toc_doc 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/POTENTIAL_ENDPOINTS.md +31 -0
- data/README.md +144 -57
- data/TODO.md +33 -37
- data/lib/toc_doc/client.rb +0 -6
- data/lib/toc_doc/core/configurable.rb +0 -3
- data/lib/toc_doc/core/connection.rb +10 -8
- data/lib/toc_doc/core/default.rb +0 -17
- data/lib/toc_doc/core/uri_utils.rb +5 -5
- data/lib/toc_doc/core/version.rb +1 -1
- data/lib/toc_doc/models/availability/collection.rb +103 -0
- data/lib/toc_doc/models/availability.rb +70 -1
- data/lib/toc_doc/models/profile/organization.rb +8 -0
- data/lib/toc_doc/models/profile/practitioner.rb +8 -0
- data/lib/toc_doc/models/profile.rb +42 -0
- data/lib/toc_doc/models/search/result.rb +61 -0
- data/lib/toc_doc/models/search.rb +55 -0
- data/lib/toc_doc/models/speciality.rb +16 -0
- data/lib/toc_doc/models.rb +5 -1
- data/lib/toc_doc.rb +23 -4
- metadata +9 -3
- data/lib/toc_doc/client/availabilities.rb +0 -118
- data/lib/toc_doc/models/response/availability.rb +0 -79
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module TocDoc
|
|
4
|
-
module Response
|
|
5
|
-
# Wraps the top-level response from the Doctolib availabilities API.
|
|
6
|
-
#
|
|
7
|
-
# @example
|
|
8
|
-
# response = TocDoc::Response::Availability.new(parsed_json)
|
|
9
|
-
# response.total #=> 2
|
|
10
|
-
# response.next_slot #=> "2026-02-28T10:00:00.000+01:00"
|
|
11
|
-
# response.availabilities #=> [#<TocDoc::Availability ...>, ...]
|
|
12
|
-
class Availability < Resource
|
|
13
|
-
# The total number of available slots across all dates.
|
|
14
|
-
#
|
|
15
|
-
# @return [Integer]
|
|
16
|
-
#
|
|
17
|
-
# @example
|
|
18
|
-
# response.total #=> 5
|
|
19
|
-
def total
|
|
20
|
-
@attrs['total']
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# The nearest available appointment slot.
|
|
24
|
-
#
|
|
25
|
-
# When the API includes an explicit +next_slot+ key (common when there
|
|
26
|
-
# are no slots in the loaded date window) that value is returned
|
|
27
|
-
# directly. Otherwise the first slot of the first date that has one
|
|
28
|
-
# is returned.
|
|
29
|
-
#
|
|
30
|
-
# @return [String, nil] ISO 8601 datetime string, or +nil+ when no
|
|
31
|
-
# slot is available
|
|
32
|
-
#
|
|
33
|
-
# @example
|
|
34
|
-
# response.next_slot #=> "2026-02-28T10:00:00.000+01:00"
|
|
35
|
-
def next_slot
|
|
36
|
-
return @attrs['next_slot'] if @attrs.key?('next_slot')
|
|
37
|
-
|
|
38
|
-
Array(@attrs['availabilities']).each do |entry|
|
|
39
|
-
slots = Array(entry['slots'])
|
|
40
|
-
return slots.first unless slots.empty?
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
nil
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Dates that have at least one available slot, wrapped as
|
|
47
|
-
# {TocDoc::Availability} objects.
|
|
48
|
-
#
|
|
49
|
-
# @return [Array<TocDoc::Availability>]
|
|
50
|
-
#
|
|
51
|
-
# @example
|
|
52
|
-
# response.availabilities.each do |avail|
|
|
53
|
-
# puts "#{avail.date}: #{avail.slots.size} slot(s)"
|
|
54
|
-
# end
|
|
55
|
-
def availabilities
|
|
56
|
-
@availabilities ||= Array(@attrs['availabilities'])
|
|
57
|
-
.select { |entry| Array(entry['slots']).any? }
|
|
58
|
-
.map { |entry| TocDoc::Availability.new(entry) }
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# All availability date entries, including those with no slots.
|
|
62
|
-
#
|
|
63
|
-
# @return [Array<TocDoc::Availability>]
|
|
64
|
-
def raw_availabilities
|
|
65
|
-
@raw_availabilities ||= Array(@attrs['availabilities']).map do |entry|
|
|
66
|
-
TocDoc::Availability.new(entry)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Returns a plain Hash representation, with nested +availabilities+
|
|
71
|
-
# expanded back to raw Hashes.
|
|
72
|
-
#
|
|
73
|
-
# @return [Hash{String => Object}]
|
|
74
|
-
def to_h
|
|
75
|
-
super.merge('availabilities' => availabilities.map(&:to_h))
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|