cronofy 0.35.0 → 0.36.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/cronofy.gemspec +1 -1
- data/lib/cronofy/client.rb +80 -0
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/client_spec.rb +156 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e085c07872654ff1e239fcdce81beeb212856ce2ff7d9c3168e71c3f2778e6d5
|
4
|
+
data.tar.gz: 0ce2421b8e0aa2b39c76a72eaeeddd4a474573690a6d3ccdf437c1d57dbf0028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8df4506dfe09d4454c8901e312dbda5d03a27d1ec8a0cb28506327f8802a691fa5abf00abd8028ee6f04d9c09eae73f3a0ea417409e7164b2fa1e0e4530bb2a3
|
7
|
+
data.tar.gz: fe07ce98f72073fa8c0254510a089fbf04d37d5da2a12b7c12d1de77e19e1666c394d14aca6d32d96ad2ee7093b1e276ad5571f0ffcfd615a4d269e70031e07b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [0.36.0]
|
2
|
+
|
3
|
+
* Add support for Available Periods [#81]
|
4
|
+
|
1
5
|
## [0.35.0]
|
2
6
|
|
3
7
|
* Add specific errors for network issues [#77]
|
@@ -162,6 +166,7 @@
|
|
162
166
|
[0.33.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.33.0
|
163
167
|
[0.34.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.34.0
|
164
168
|
[0.35.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.35.0
|
169
|
+
[0.36.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.0
|
165
170
|
|
166
171
|
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
|
167
172
|
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
|
@@ -201,3 +206,4 @@
|
|
201
206
|
[#74]: https://github.com/cronofy/cronofy-ruby/pull/74
|
202
207
|
[#75]: https://github.com/cronofy/cronofy-ruby/pull/75
|
203
208
|
[#77]: https://github.com/cronofy/cronofy-ruby/pull/77
|
209
|
+
[#81]: https://github.com/cronofy/cronofy-ruby/pull/81
|
data/cronofy.gemspec
CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", ">= 1.6", "< 3"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.2"
|
26
|
-
spec.add_development_dependency "webmock", "~> 1
|
26
|
+
spec.add_development_dependency "webmock", "~> 3.9.1"
|
27
27
|
end
|
data/lib/cronofy/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
1
3
|
module Cronofy
|
2
4
|
# Public: Primary class for interacting with the Cronofy API.
|
3
5
|
class Client
|
@@ -1492,6 +1494,84 @@ module Cronofy
|
|
1492
1494
|
nil
|
1493
1495
|
end
|
1494
1496
|
|
1497
|
+
# Public: Creates or updates an AvailablePeriod.
|
1498
|
+
#
|
1499
|
+
# available_period_id - A String uniquely identifying the available period
|
1500
|
+
# for the authenticated user in your application
|
1501
|
+
# (note: this is NOT an ID generated by Cronofy).
|
1502
|
+
# body - A Hash describing the available period with
|
1503
|
+
# symbolized keys:
|
1504
|
+
# :start - A String (ISO-8601 date/time)
|
1505
|
+
# :end - A String (ISO-8601 date/time)
|
1506
|
+
#
|
1507
|
+
# See https://docs.cronofy.com/developers/api/scheduling/available-periods/upsert/
|
1508
|
+
# for reference.
|
1509
|
+
#
|
1510
|
+
# Returns nothing.
|
1511
|
+
#
|
1512
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1513
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1514
|
+
# parameters.
|
1515
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1516
|
+
# limits for the application.
|
1517
|
+
def upsert_available_period(available_period_id, body)
|
1518
|
+
payload = body.merge(available_period_id: available_period_id)
|
1519
|
+
wrapped_request { post("/v1/available_periods", payload) }
|
1520
|
+
nil
|
1521
|
+
end
|
1522
|
+
|
1523
|
+
# Public: Gets all AvailablePeriods for an account.
|
1524
|
+
#
|
1525
|
+
# options - The Hash options used to refine the selection (default: {}):
|
1526
|
+
# :from - The minimum Date from which to return periods
|
1527
|
+
# (optional).
|
1528
|
+
# :to - The Date to return periods up until (optional).
|
1529
|
+
# :tzid - A String representing a known time zone
|
1530
|
+
# identifier from the IANA Time Zone Database
|
1531
|
+
# (default: Etc/UTC).
|
1532
|
+
# :localized_times - A Boolean specifying whether the start and
|
1533
|
+
# end times should be returned with any
|
1534
|
+
# available localization information
|
1535
|
+
# (optional).
|
1536
|
+
#
|
1537
|
+
# Returns an array of AvailablePeriods.
|
1538
|
+
#
|
1539
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1540
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1541
|
+
# parameters.
|
1542
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1543
|
+
# limits for the application.
|
1544
|
+
def get_available_periods(options={})
|
1545
|
+
query = {}
|
1546
|
+
query[:from] = to_iso8601(options[:from]) if options[:from]
|
1547
|
+
query[:to] = to_iso8601(options[:to]) if options[:to]
|
1548
|
+
query[:tzid] = options[:tzid] if options[:tzid]
|
1549
|
+
query[:localized_times] = options[:localized_times] if options[:localized_times]
|
1550
|
+
if query.any?
|
1551
|
+
query_string = "?#{URI.encode_www_form(query)}"
|
1552
|
+
end
|
1553
|
+
|
1554
|
+
response = wrapped_request { get("/v1/available_periods#{query_string}") }
|
1555
|
+
parse_collection(AvailablePeriod, 'available_periods', response)
|
1556
|
+
end
|
1557
|
+
|
1558
|
+
# Public: Deletes an AvailablePeriod.
|
1559
|
+
#
|
1560
|
+
# available_period_id - A String uniquely identifying the available period
|
1561
|
+
# for the authenticated user in your application
|
1562
|
+
#
|
1563
|
+
# Returns nothing.
|
1564
|
+
#
|
1565
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1566
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1567
|
+
# parameters.
|
1568
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1569
|
+
# limits for the application.
|
1570
|
+
def delete_available_period(available_period_id)
|
1571
|
+
wrapped_request { delete("/v1/available_periods", available_period_id: available_period_id) }
|
1572
|
+
nil
|
1573
|
+
end
|
1574
|
+
|
1495
1575
|
# Public: Creates a scheduling conversation
|
1496
1576
|
#
|
1497
1577
|
# pre release end-point documentation to follow
|
data/lib/cronofy/version.rb
CHANGED
@@ -3152,4 +3152,160 @@ describe Cronofy::Client do
|
|
3152
3152
|
|
3153
3153
|
it_behaves_like 'a Cronofy request'
|
3154
3154
|
end
|
3155
|
+
|
3156
|
+
describe "#upsert_available_period" do
|
3157
|
+
let(:request_url) { 'https://api.cronofy.com/v1/available_periods' }
|
3158
|
+
let(:method) { :post }
|
3159
|
+
let(:available_period_id) { "test" }
|
3160
|
+
let(:request_body) do
|
3161
|
+
{
|
3162
|
+
available_period_id: available_period_id,
|
3163
|
+
start: "2020-07-26T15:30:00Z",
|
3164
|
+
end: "2020-07-26T17:00:00Z"
|
3165
|
+
}
|
3166
|
+
end
|
3167
|
+
|
3168
|
+
let(:correct_response_code) { 202 }
|
3169
|
+
let(:correct_response_body) { "" }
|
3170
|
+
let(:correct_mapped_result) { nil }
|
3171
|
+
|
3172
|
+
subject {
|
3173
|
+
client.upsert_available_period(available_period_id,
|
3174
|
+
start: request_body[:start],
|
3175
|
+
end: request_body[:end]
|
3176
|
+
)
|
3177
|
+
}
|
3178
|
+
|
3179
|
+
it_behaves_like 'a Cronofy request'
|
3180
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3181
|
+
end
|
3182
|
+
|
3183
|
+
describe "#get_available_periods" do
|
3184
|
+
context "unfiltered" do
|
3185
|
+
let(:request_url) { "https://api.cronofy.com/v1/available_periods" }
|
3186
|
+
let(:method) { :get }
|
3187
|
+
|
3188
|
+
let(:correct_response_code) { 200 }
|
3189
|
+
let(:correct_response_body) do
|
3190
|
+
{
|
3191
|
+
"available_periods" => [
|
3192
|
+
{
|
3193
|
+
"available_period_id" => "qTtZdczOccgaPncGJaCiLg",
|
3194
|
+
"start" => "2020-07-26T15:30:00Z",
|
3195
|
+
"end" => "2020-07-26T17:00:00Z"
|
3196
|
+
}
|
3197
|
+
]
|
3198
|
+
}
|
3199
|
+
end
|
3200
|
+
|
3201
|
+
let(:correct_mapped_result) do
|
3202
|
+
period = correct_response_body['available_periods'][0]
|
3203
|
+
|
3204
|
+
[
|
3205
|
+
Cronofy::AvailablePeriod.new(
|
3206
|
+
available_period_id: period['available_period_id'],
|
3207
|
+
start: period['start'],
|
3208
|
+
end: period['end']
|
3209
|
+
)
|
3210
|
+
]
|
3211
|
+
end
|
3212
|
+
|
3213
|
+
subject { client.get_available_periods }
|
3214
|
+
|
3215
|
+
it_behaves_like 'a Cronofy request'
|
3216
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3217
|
+
end
|
3218
|
+
|
3219
|
+
context "filterd by date range" do
|
3220
|
+
let(:tzid) { "America/New_York" }
|
3221
|
+
let(:from) { "2020-07-01" }
|
3222
|
+
let(:to) { "2020-07-31" }
|
3223
|
+
let(:request_url) { "https://api.cronofy.com/v1/available_periods?from=#{from}&to=#{to}&tzid=#{tzid}" }
|
3224
|
+
let(:method) { :get }
|
3225
|
+
|
3226
|
+
let(:correct_response_code) { 200 }
|
3227
|
+
let(:correct_response_body) do
|
3228
|
+
{
|
3229
|
+
"available_periods" => [
|
3230
|
+
{
|
3231
|
+
"available_period_id" => "qTtZdczOccgaPncGJaCiLg",
|
3232
|
+
"start" => "2020-07-26T15:30:00Z",
|
3233
|
+
"end" => "2020-07-26T17:00:00Z"
|
3234
|
+
}
|
3235
|
+
]
|
3236
|
+
}
|
3237
|
+
end
|
3238
|
+
|
3239
|
+
let(:correct_mapped_result) do
|
3240
|
+
period = correct_response_body['available_periods'][0]
|
3241
|
+
|
3242
|
+
[
|
3243
|
+
Cronofy::AvailablePeriod.new(
|
3244
|
+
available_period_id: period['available_period_id'],
|
3245
|
+
start: period['start'],
|
3246
|
+
end: period['end']
|
3247
|
+
)
|
3248
|
+
]
|
3249
|
+
end
|
3250
|
+
|
3251
|
+
subject { client.get_available_periods(from: from, to: to, tzid: tzid) }
|
3252
|
+
|
3253
|
+
it_behaves_like 'a Cronofy request'
|
3254
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3255
|
+
end
|
3256
|
+
|
3257
|
+
context "requesting localized times" do
|
3258
|
+
let(:tzid) { "America/New_York" }
|
3259
|
+
let(:localized_times) { true }
|
3260
|
+
let(:request_url) { "https://api.cronofy.com/v1/available_periods?tzid=#{tzid}&localized_times=true" }
|
3261
|
+
let(:method) { :get }
|
3262
|
+
|
3263
|
+
let(:correct_response_code) { 200 }
|
3264
|
+
let(:correct_response_body) do
|
3265
|
+
{
|
3266
|
+
"available_periods" => [
|
3267
|
+
{
|
3268
|
+
"available_period_id" => "qTtZdczOccgaPncGJaCiLg",
|
3269
|
+
"start" => "2020-07-26T15:30:00Z",
|
3270
|
+
"end" => "2020-07-26T17:00:00Z"
|
3271
|
+
}
|
3272
|
+
]
|
3273
|
+
}
|
3274
|
+
end
|
3275
|
+
|
3276
|
+
let(:correct_mapped_result) do
|
3277
|
+
period = correct_response_body['available_periods'][0]
|
3278
|
+
|
3279
|
+
[
|
3280
|
+
Cronofy::AvailablePeriod.new(
|
3281
|
+
available_period_id: period['available_period_id'],
|
3282
|
+
start: period['start'],
|
3283
|
+
end: period['end']
|
3284
|
+
)
|
3285
|
+
]
|
3286
|
+
end
|
3287
|
+
|
3288
|
+
subject { client.get_available_periods(tzid: tzid, localized_times: true) }
|
3289
|
+
|
3290
|
+
it_behaves_like 'a Cronofy request'
|
3291
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3292
|
+
end
|
3293
|
+
end
|
3294
|
+
|
3295
|
+
describe '#delete_available_period' do
|
3296
|
+
let(:available_period_id) { 'default'}
|
3297
|
+
let(:request_url) { "https://api.cronofy.com/v1/available_periods" }
|
3298
|
+
let(:method) { :delete }
|
3299
|
+
let(:request_body) {
|
3300
|
+
{ available_period_id: available_period_id}
|
3301
|
+
}
|
3302
|
+
let(:correct_response_code) { 202 }
|
3303
|
+
let(:correct_response_body) { "" }
|
3304
|
+
let(:correct_mapped_result) { nil }
|
3305
|
+
|
3306
|
+
subject { client.delete_available_period(available_period_id) }
|
3307
|
+
|
3308
|
+
it_behaves_like 'a Cronofy request'
|
3309
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3310
|
+
end
|
3155
3311
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.36.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergii Paryzhskyi
|
8
8
|
- Garry Shutler
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
@@ -99,14 +99,14 @@ dependencies:
|
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: 3.9.1
|
103
103
|
type: :development
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: 3.9.1
|
110
110
|
description: Ruby wrapper for Cronofy's unified calendar API
|
111
111
|
email:
|
112
112
|
- parizhskiy@gmail.com
|
@@ -141,7 +141,7 @@ homepage: https://github.com/cronofy/cronofy-ruby
|
|
141
141
|
licenses:
|
142
142
|
- MIT
|
143
143
|
metadata: {}
|
144
|
-
post_install_message:
|
144
|
+
post_install_message:
|
145
145
|
rdoc_options: []
|
146
146
|
require_paths:
|
147
147
|
- lib
|
@@ -156,8 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
160
|
-
signing_key:
|
159
|
+
rubygems_version: 3.1.2
|
160
|
+
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Cronofy - one API for all the calendars
|
163
163
|
test_files:
|