calendly 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e93c2dc16d8ea8b5c14d890394dbaf898935d1ac3bfa85d091056be51fc5e30
4
- data.tar.gz: 49b3c47b087a73d2fb86e00e301daa7661bf0b5d0bf3014142806dd64006f9a5
3
+ metadata.gz: f28a38b908de51d9f237545fcf0d59aab6a6d25747c2118b17529380c68c7918
4
+ data.tar.gz: 126bbd0048717b51f5c923e48b74928263eaa1f55865dc73ef790ee11f097133
5
5
  SHA512:
6
- metadata.gz: 5e1d557c0df74d1ab77237bbea0199c0771576d780fac4e91147ee06cdbf7d215536220ff643b3167f026437c04ba650368f810cc3d554425c05eeb817b71d9e
7
- data.tar.gz: 69d38a1904609257682374b562d3c45fc3cba63fdfab4654c83fa1739c1bb14bbbfb308a8b9a2a3aa1fdda69263a8fde3cc12e0d857d518e5ef0587c2963a7d0
6
+ metadata.gz: fad893cae7dbcbf7ab5c7d3aede8da1e7852885b3491eb65cad4ec7253a68d31655233d3308d00460a2a244756e7b4a7b31922381085f97c0e3229f775c50cc2
7
+ data.tar.gz: cc9aca55ae9c25bccb69a2a320526d449b2a5b70807bd47e4e4e1db5903ee2618b276065b400c0c60183a4625b82e04840a2620f6180e69577a841350806550c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.13.0 - 2022-08-03
4
+
5
+ - supported List Event Type Available Times API. (#57)
6
+ - changed were followings:
7
+ - Client
8
+ - (Add method) event_type_available_times
9
+ - EventType model
10
+ - (Add method) available_times
11
+
3
12
  ## 0.12.0 - 2022-07-16
4
13
 
5
14
  - supported Routing Form APIs. (#55)
data/README.md CHANGED
@@ -64,9 +64,21 @@ me.scheduling_url
64
64
  #
65
65
  event_types = me.event_types
66
66
  # => [#<Calendly::EventType uuid="ET001", name="15 Minute Meeting", type="StandardEventType", slug="15min", active=true, kind="solo", scheduling_url="https://calendly.com/foobar/15min", ..>, #<Calendly::EventType uuid="ET002", name="30 Minute Meeting", type="StandardEventType", slug="30min", active=true, kind="solo", scheduling_url="https://calendly.com/foobar/30min", ..>]
67
- event_types.first.scheduling_url
67
+
68
+ event_type = event_types.first
69
+ event_type.scheduling_url
68
70
  # => "https://calendly.com/foobar/15min"
69
71
 
72
+ #
73
+ # get available times for the event type
74
+ #
75
+ available_times = event_type.available_times
76
+ available_times.map(&:start_time)
77
+ # => [2022-08-04 01:00:00 UTC, 2022-08-04 01:15:00 UTC, 2022-08-04 01:30:00 UTC]
78
+
79
+ # you can specify the date range
80
+ event_type.available_times(start_time: "2022-08-04T10:30:00Z", end_time: "2022-08-05T10:30:00Z")
81
+
70
82
  #
71
83
  # get scheduled events
72
84
  #
data/calendly.gemspec CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_runtime_dependency 'faraday', '>= 1.0.0', '< 3.0.0'
32
32
  spec.add_runtime_dependency 'oauth2', '~> 1.4', '>= 1.4.4'
33
33
 
34
+ spec.add_development_dependency 'activesupport'
34
35
  spec.add_development_dependency 'bundler'
35
36
  spec.add_development_dependency 'codecov'
36
37
  spec.add_development_dependency 'minitest'
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'time'
3
4
  require 'oauth2'
4
5
  require 'calendly/loggable'
5
6
 
@@ -159,6 +160,35 @@ module Calendly
159
160
  [ev_types, next_page_params(body)]
160
161
  end
161
162
 
163
+ #
164
+ # Returns a list of available times for an event type within a specified date range.
165
+ # Date range can be no greater than 1 week (7 days).
166
+ #
167
+ # @param [String] event_type_uri The uri associated with the event type.
168
+ # @param [String] start_time Start time of the requested availability range.
169
+ # @param [String] end_time End time of the requested availability range.
170
+ # @return [Array<Calendly::EventTypeAvailableTime>] The set of available times for the event type matching the criteria.
171
+ # @raise [Calendly::Error] if the event_type_uri arg is empty.
172
+ # @raise [Calendly::ApiError] if the api returns error code.
173
+ # @since 0.13.0
174
+ def event_type_available_times(event_type_uri, start_time: nil, end_time: nil)
175
+ check_not_empty event_type_uri, 'event_type_uri'
176
+
177
+ start_time_buffer = 60 # For working around an invalid request which be caused by specifying a past time
178
+ max_date_range = 60 * 60 * 24 * 7 # 7 days
179
+
180
+ # If start_time is undefined, set it to now.
181
+ start_time ||= (Time.now + start_time_buffer).utc.iso8601
182
+ # If end_time is undefined, set it to in the max date range from start_time.
183
+ end_time ||= (Time.parse(start_time) + max_date_range).utc.iso8601
184
+
185
+ params = {event_type: event_type_uri, start_time: start_time, end_time: end_time}
186
+ body = request :get, 'event_type_available_times', params: params
187
+
188
+ items = body[:collection] || []
189
+ items.map { |item| EventTypeAvailableTime.new item, self }
190
+ end
191
+
162
192
  #
163
193
  # Returns a single Event by its URI.
164
194
  #
@@ -118,6 +118,20 @@ module Calendly
118
118
  client.event_type uuid
119
119
  end
120
120
 
121
+ #
122
+ # Returns a list of available times for an event type within a specified date range.
123
+ # Date range can be no greater than 1 week (7 days).
124
+ #
125
+ # @param [String] start_time Start time of the requested availability range.
126
+ # @param [String] end_time End time of the requested availability range.
127
+ # @return [Array<Calendly::EventTypeAvailableTime>] The set of available times for the event type matching the criteria.
128
+ # @raise [Calendly::Error] if the uri is empty.
129
+ # @raise [Calendly::ApiError] if the api returns error code.
130
+ # @since 0.13.0
131
+ def available_times(start_time: nil, end_time: nil)
132
+ client.event_type_available_times uri, start_time: start_time, end_time: end_time
133
+ end
134
+
121
135
  #
122
136
  # Create an associated scheduling link.
123
137
  #
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Calendly
4
+ # An available meeting time slot for the given event type.
5
+ class EventTypeAvailableTime
6
+ include ModelUtils
7
+ TIME_FIELDS = %i[start_time].freeze
8
+
9
+ # Indicates that the open time slot is "available".
10
+ # @return [String]
11
+ attr_accessor :status
12
+
13
+ # Total remaining invitees for this available time.
14
+ # For Group Event Type, more than one invitee can book in this available time.
15
+ # For all other Event Types, only one invitee can book in this available time.
16
+ # @return [Integer]
17
+ attr_accessor :invitees_remaining
18
+
19
+ # The moment the event was scheduled to start in UTC time.
20
+ # @return [Time]
21
+ attr_accessor :start_time
22
+
23
+ # The URL of the user’s scheduling site where invitees book this event type.
24
+ # @return [Time]
25
+ attr_accessor :scheduling_url
26
+
27
+ private
28
+
29
+ def inspect_attributes
30
+ super + %i[start_time invitees_remaining]
31
+ end
32
+ end
33
+ end
@@ -42,7 +42,7 @@ module Calendly
42
42
  # The URI of the organization that's associated with the routing form.
43
43
  attr_accessor :organization
44
44
 
45
- # @return [Calendly::RoutingFormQuestion]
45
+ # @return [Array<Calendly::RoutingFormQuestion>]
46
46
  # An ordered collection of Routing Form non-deleted questions.
47
47
  attr_accessor :questions
48
48
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Calendly
4
- VERSION = '0.12.0'
4
+ VERSION = '0.13.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calendly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenji Koshikawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-16 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -50,6 +50,20 @@ dependencies:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 1.4.4
53
+ - !ruby/object:Gem::Dependency
54
+ name: activesupport
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: bundler
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -176,6 +190,7 @@ files:
176
190
  - lib/calendly/loggable.rb
177
191
  - lib/calendly/models/event.rb
178
192
  - lib/calendly/models/event_type.rb
193
+ - lib/calendly/models/event_type_available_type.rb
179
194
  - lib/calendly/models/event_type_custom_question.rb
180
195
  - lib/calendly/models/event_type_profile.rb
181
196
  - lib/calendly/models/guest.rb
@@ -209,7 +224,7 @@ metadata:
209
224
  homepage_uri: https://github.com/koshilife/calendly-api-ruby-client
210
225
  source_code_uri: https://github.com/koshilife/calendly-api-ruby-client
211
226
  changelog_uri: https://github.com/koshilife/calendly-api-ruby-client/blob/master/CHANGELOG.md
212
- documentation_uri: https://www.rubydoc.info/gems/calendly/0.12.0
227
+ documentation_uri: https://www.rubydoc.info/gems/calendly/0.13.0
213
228
  post_install_message:
214
229
  rdoc_options: []
215
230
  require_paths: