cronofy 0.33.0 → 0.37.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 +30 -0
- data/README.md +2 -4
- data/cronofy.gemspec +2 -2
- data/lib/cronofy/auth.rb +34 -4
- data/lib/cronofy/client.rb +114 -0
- data/lib/cronofy/errors.rb +15 -0
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/auth_spec.rb +80 -0
- data/spec/lib/cronofy/client_spec.rb +217 -0
- metadata +24 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 308d390e34e9ed071119e343cc32f18121ddcff2328fbc945b3a785e64550676
|
4
|
+
data.tar.gz: 2ab98066dd1c8eeef0d44a4ddef32f49945edd2d4b84c16d7f5607bbbb54220a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c61c10c546d52fee5d4af2ed2030f33a477d0b79cce98c89eb977e76cb9a1918250a00cf4fa1d74b2a35eb044da6ba338f504d6427b07173386c542dae48af97
|
7
|
+
data.tar.gz: 844a546be5ef240ebb964e72926363eedf023bc05ce05bfa95e5af7b1adc8bfbef18a53b1415cec348b370367ec322e5513b7330622753b29b350c1ec046fa67
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## [0.37.0]
|
2
|
+
|
3
|
+
* Add `revoke_by_token` and `revoke_by_sub` to the Client [#86]
|
4
|
+
|
5
|
+
## [0.36.1]
|
6
|
+
|
7
|
+
* Loosen the version requirement on Hashie to allow 4.X
|
8
|
+
|
9
|
+
## [0.36.0]
|
10
|
+
|
11
|
+
* Add support for Available Periods [#81]
|
12
|
+
|
13
|
+
## [0.35.0]
|
14
|
+
|
15
|
+
* Add specific errors for network issues [#77]
|
16
|
+
|
17
|
+
## [0.34.0]
|
18
|
+
|
19
|
+
* Support removing a participant from a Smart Invite [#75]
|
20
|
+
|
1
21
|
## [0.33.0]
|
2
22
|
|
3
23
|
* Support listing Availability Rules [#74]
|
@@ -152,6 +172,11 @@
|
|
152
172
|
[0.31.2]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.2
|
153
173
|
[0.32.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.32.0
|
154
174
|
[0.33.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.33.0
|
175
|
+
[0.34.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.34.0
|
176
|
+
[0.35.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.35.0
|
177
|
+
[0.36.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.0
|
178
|
+
[0.36.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.1
|
179
|
+
[0.37.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.0
|
155
180
|
|
156
181
|
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
|
157
182
|
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
|
@@ -189,3 +214,8 @@
|
|
189
214
|
[#72]: https://github.com/cronofy/cronofy-ruby/pull/72
|
190
215
|
[#73]: https://github.com/cronofy/cronofy-ruby/pull/73
|
191
216
|
[#74]: https://github.com/cronofy/cronofy-ruby/pull/74
|
217
|
+
[#75]: https://github.com/cronofy/cronofy-ruby/pull/75
|
218
|
+
[#77]: https://github.com/cronofy/cronofy-ruby/pull/77
|
219
|
+
[#81]: https://github.com/cronofy/cronofy-ruby/pull/81
|
220
|
+
[#85]: https://github.com/cronofy/cronofy-ruby/pull/85
|
221
|
+
[#86]: https://github.com/cronofy/cronofy-ruby/pull/86
|
data/README.md
CHANGED
@@ -23,10 +23,8 @@ bundle install
|
|
23
23
|
|
24
24
|
In order to use the Cronofy API you will need to [create a developer account](https://app.cronofy.com/sign_up/new).
|
25
25
|
|
26
|
-
From there you can [
|
27
|
-
to
|
28
|
-
to obtain an OAuth `client_id` and `client_secret` to be able to use the full
|
29
|
-
API.
|
26
|
+
From there you can [create an OAuth application](https://app.cronofy.com/oauth/applications/new)
|
27
|
+
to obtain an OAuth `client_id` and `client_secret` to be able to use the full API.
|
30
28
|
|
31
29
|
## Creating a client
|
32
30
|
|
data/cronofy.gemspec
CHANGED
@@ -17,11 +17,11 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.files += Dir['spec/**/*.rb']
|
18
18
|
spec.test_files = Dir['spec/**/*.rb']
|
19
19
|
|
20
|
+
spec.add_runtime_dependency "hashie", ">= 2.1", "< 5"
|
20
21
|
spec.add_runtime_dependency "oauth2", "~> 1.0"
|
21
|
-
spec.add_runtime_dependency "hashie", ">= 2.1", "< 4"
|
22
22
|
|
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/auth.rb
CHANGED
@@ -118,20 +118,50 @@ module Cronofy
|
|
118
118
|
def revoke!
|
119
119
|
raise CredentialsMissingError.new("No credentials to revoke") unless access_token
|
120
120
|
|
121
|
+
token = access_token.refresh_token || access_token.token
|
122
|
+
revoke_by_token(token)
|
123
|
+
@access_token = nil
|
124
|
+
end
|
125
|
+
|
126
|
+
# Internal: Revokes an authorization by the sub
|
127
|
+
#
|
128
|
+
# Returns nothing.
|
129
|
+
#
|
130
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
131
|
+
def revoke_by_sub(sub)
|
132
|
+
do_revoke(sub: sub)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Internal: Revokes an authorization via the token
|
136
|
+
#
|
137
|
+
# Returns nothing.
|
138
|
+
#
|
139
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
140
|
+
def revoke_by_token(token)
|
141
|
+
do_revoke(token: token)
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
|
146
|
+
def do_revoke(token: nil, sub: nil)
|
147
|
+
raise CredentialsMissingError.new("No credentials to revoke") unless token || sub
|
148
|
+
|
121
149
|
do_request do
|
122
150
|
body = {
|
123
151
|
client_id: @api_client.id,
|
124
152
|
client_secret: @api_client.secret,
|
125
|
-
token: access_token.refresh_token || access_token.token,
|
126
153
|
}
|
127
154
|
|
155
|
+
if token
|
156
|
+
body.merge!(token: token)
|
157
|
+
else
|
158
|
+
body.merge!(sub: sub)
|
159
|
+
end
|
160
|
+
|
128
161
|
@api_client.request(:post, "/oauth/token/revoke", body: body)
|
129
|
-
@access_token = nil
|
130
162
|
end
|
131
163
|
end
|
132
164
|
|
133
|
-
private
|
134
|
-
|
135
165
|
def do_request(&block)
|
136
166
|
if @client_credentials_missing
|
137
167
|
raise CredentialsMissingError.new("OAuth client_id and client_secret must be set")
|
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
|
@@ -735,6 +737,14 @@ module Cronofy
|
|
735
737
|
@auth.revoke!
|
736
738
|
end
|
737
739
|
|
740
|
+
def revoke_by_sub(sub)
|
741
|
+
@auth.revoke_by_sub(sub)
|
742
|
+
end
|
743
|
+
|
744
|
+
def revoke_by_token(token)
|
745
|
+
@auth.revoke_by_token(token)
|
746
|
+
end
|
747
|
+
|
738
748
|
# Public: Requests elevated permissions for a set of calendars.
|
739
749
|
#
|
740
750
|
# args - A Hash of options used to initialize the request (default: {}):
|
@@ -1323,6 +1333,32 @@ module Cronofy
|
|
1323
1333
|
parse_json(SmartInviteResponse, nil, response)
|
1324
1334
|
end
|
1325
1335
|
|
1336
|
+
# Public: Removes an individual recipient from a multiple recipient smart invite
|
1337
|
+
#
|
1338
|
+
# smart_invite_id - A String uniquely identifying the event for your
|
1339
|
+
# application (note: this is NOT an ID generated
|
1340
|
+
# by Cronofy).
|
1341
|
+
#
|
1342
|
+
# recipient - A Hash containing the recipient to be removed
|
1343
|
+
# :email - A String for the email address of
|
1344
|
+
# the recipient to remove.
|
1345
|
+
#
|
1346
|
+
# See https://docs.cronofy.com/developers/api-alpha/smart-invites/multiple-recipients/#remove-invite-recipient
|
1347
|
+
# for reference.
|
1348
|
+
#
|
1349
|
+
# Returns a SmartInviteResponse
|
1350
|
+
#
|
1351
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1352
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1353
|
+
# parameters.
|
1354
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1355
|
+
# limits for the application.
|
1356
|
+
def remove_recipient_smart_invite(body={})
|
1357
|
+
body[:method] = 'remove'
|
1358
|
+
response = wrapped_request { api_key!.post("/v1/smart_invites", json_request_args(body)) }
|
1359
|
+
parse_json(SmartInviteResponse, nil, response)
|
1360
|
+
end
|
1361
|
+
|
1326
1362
|
# Public: Gets the details for a smart invite.
|
1327
1363
|
#
|
1328
1364
|
# smart_invite_id - A String uniquely identifying the event for your
|
@@ -1466,6 +1502,84 @@ module Cronofy
|
|
1466
1502
|
nil
|
1467
1503
|
end
|
1468
1504
|
|
1505
|
+
# Public: Creates or updates an AvailablePeriod.
|
1506
|
+
#
|
1507
|
+
# available_period_id - A String uniquely identifying the available period
|
1508
|
+
# for the authenticated user in your application
|
1509
|
+
# (note: this is NOT an ID generated by Cronofy).
|
1510
|
+
# body - A Hash describing the available period with
|
1511
|
+
# symbolized keys:
|
1512
|
+
# :start - A String (ISO-8601 date/time)
|
1513
|
+
# :end - A String (ISO-8601 date/time)
|
1514
|
+
#
|
1515
|
+
# See https://docs.cronofy.com/developers/api/scheduling/available-periods/upsert/
|
1516
|
+
# for reference.
|
1517
|
+
#
|
1518
|
+
# Returns nothing.
|
1519
|
+
#
|
1520
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1521
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1522
|
+
# parameters.
|
1523
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1524
|
+
# limits for the application.
|
1525
|
+
def upsert_available_period(available_period_id, body)
|
1526
|
+
payload = body.merge(available_period_id: available_period_id)
|
1527
|
+
wrapped_request { post("/v1/available_periods", payload) }
|
1528
|
+
nil
|
1529
|
+
end
|
1530
|
+
|
1531
|
+
# Public: Gets all AvailablePeriods for an account.
|
1532
|
+
#
|
1533
|
+
# options - The Hash options used to refine the selection (default: {}):
|
1534
|
+
# :from - The minimum Date from which to return periods
|
1535
|
+
# (optional).
|
1536
|
+
# :to - The Date to return periods up until (optional).
|
1537
|
+
# :tzid - A String representing a known time zone
|
1538
|
+
# identifier from the IANA Time Zone Database
|
1539
|
+
# (default: Etc/UTC).
|
1540
|
+
# :localized_times - A Boolean specifying whether the start and
|
1541
|
+
# end times should be returned with any
|
1542
|
+
# available localization information
|
1543
|
+
# (optional).
|
1544
|
+
#
|
1545
|
+
# Returns an array of AvailablePeriods.
|
1546
|
+
#
|
1547
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1548
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1549
|
+
# parameters.
|
1550
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1551
|
+
# limits for the application.
|
1552
|
+
def get_available_periods(options={})
|
1553
|
+
query = {}
|
1554
|
+
query[:from] = to_iso8601(options[:from]) if options[:from]
|
1555
|
+
query[:to] = to_iso8601(options[:to]) if options[:to]
|
1556
|
+
query[:tzid] = options[:tzid] if options[:tzid]
|
1557
|
+
query[:localized_times] = options[:localized_times] if options[:localized_times]
|
1558
|
+
if query.any?
|
1559
|
+
query_string = "?#{URI.encode_www_form(query)}"
|
1560
|
+
end
|
1561
|
+
|
1562
|
+
response = wrapped_request { get("/v1/available_periods#{query_string}") }
|
1563
|
+
parse_collection(AvailablePeriod, 'available_periods', response)
|
1564
|
+
end
|
1565
|
+
|
1566
|
+
# Public: Deletes an AvailablePeriod.
|
1567
|
+
#
|
1568
|
+
# available_period_id - A String uniquely identifying the available period
|
1569
|
+
# for the authenticated user in your application
|
1570
|
+
#
|
1571
|
+
# Returns nothing.
|
1572
|
+
#
|
1573
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1574
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1575
|
+
# parameters.
|
1576
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1577
|
+
# limits for the application.
|
1578
|
+
def delete_available_period(available_period_id)
|
1579
|
+
wrapped_request { delete("/v1/available_periods", available_period_id: available_period_id) }
|
1580
|
+
nil
|
1581
|
+
end
|
1582
|
+
|
1469
1583
|
# Public: Creates a scheduling conversation
|
1470
1584
|
#
|
1471
1585
|
# pre release end-point documentation to follow
|
data/lib/cronofy/errors.rb
CHANGED
@@ -68,6 +68,18 @@ module Cronofy
|
|
68
68
|
class PaymentRequiredError < APIError
|
69
69
|
end
|
70
70
|
|
71
|
+
class ServiceUnreachableError < APIError
|
72
|
+
end
|
73
|
+
|
74
|
+
class BadGatewayError < ServiceUnreachableError
|
75
|
+
end
|
76
|
+
|
77
|
+
class ServiceUnavailableError < ServiceUnreachableError
|
78
|
+
end
|
79
|
+
|
80
|
+
class GatewayTimeoutError < ServiceUnreachableError
|
81
|
+
end
|
82
|
+
|
71
83
|
class UnknownError < APIError
|
72
84
|
end
|
73
85
|
|
@@ -83,6 +95,9 @@ module Cronofy
|
|
83
95
|
423 => AccountLockedError,
|
84
96
|
429 => TooManyRequestsError,
|
85
97
|
500 => ServerError,
|
98
|
+
502 => BadGatewayError,
|
99
|
+
503 => ServiceUnavailableError,
|
100
|
+
504 => GatewayTimeoutError,
|
86
101
|
}.freeze
|
87
102
|
|
88
103
|
def self.map_error(error)
|
data/lib/cronofy/version.rb
CHANGED
@@ -476,4 +476,84 @@ describe Cronofy::Auth do
|
|
476
476
|
end
|
477
477
|
end
|
478
478
|
end
|
479
|
+
|
480
|
+
describe "#revoke_by_sub" do
|
481
|
+
let(:auth) do
|
482
|
+
Cronofy::Auth.new(
|
483
|
+
client_id: client_id,
|
484
|
+
client_secret: client_secret,
|
485
|
+
access_token: access_token,
|
486
|
+
refresh_token: refresh_token,
|
487
|
+
)
|
488
|
+
end
|
489
|
+
|
490
|
+
let!(:revocation_request) do
|
491
|
+
stub_request(:post, "https://api.cronofy.com/oauth/token/revoke")
|
492
|
+
.with(
|
493
|
+
body: {
|
494
|
+
client_id: client_id,
|
495
|
+
client_secret: client_secret,
|
496
|
+
sub: sub,
|
497
|
+
},
|
498
|
+
headers: {
|
499
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
500
|
+
'User-Agent' => "Cronofy Ruby #{Cronofy::VERSION}",
|
501
|
+
}
|
502
|
+
).to_return(status: response_status)
|
503
|
+
end
|
504
|
+
|
505
|
+
let(:sub) { "random_sub_value" }
|
506
|
+
|
507
|
+
before do
|
508
|
+
auth.revoke_by_sub(sub)
|
509
|
+
end
|
510
|
+
|
511
|
+
it "does not unset the access token for the current auth" do
|
512
|
+
expect(auth.access_token).not_to be_nil
|
513
|
+
end
|
514
|
+
|
515
|
+
it "makes the revocation request" do
|
516
|
+
expect(revocation_request).to have_been_requested
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
describe "#revoke_by_token" do
|
521
|
+
let(:auth) do
|
522
|
+
Cronofy::Auth.new(
|
523
|
+
client_id: client_id,
|
524
|
+
client_secret: client_secret,
|
525
|
+
access_token: access_token,
|
526
|
+
refresh_token: refresh_token,
|
527
|
+
)
|
528
|
+
end
|
529
|
+
|
530
|
+
let!(:revocation_request) do
|
531
|
+
stub_request(:post, "https://api.cronofy.com/oauth/token/revoke")
|
532
|
+
.with(
|
533
|
+
body: {
|
534
|
+
client_id: client_id,
|
535
|
+
client_secret: client_secret,
|
536
|
+
token: token,
|
537
|
+
},
|
538
|
+
headers: {
|
539
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
540
|
+
'User-Agent' => "Cronofy Ruby #{Cronofy::VERSION}",
|
541
|
+
}
|
542
|
+
).to_return(status: response_status)
|
543
|
+
end
|
544
|
+
|
545
|
+
let(:token) { "random_token_value" }
|
546
|
+
|
547
|
+
before do
|
548
|
+
auth.revoke_by_token(token)
|
549
|
+
end
|
550
|
+
|
551
|
+
it "does not unset the access token for the current auth" do
|
552
|
+
expect(auth.access_token).not_to be_nil
|
553
|
+
end
|
554
|
+
|
555
|
+
it "makes the revocation request" do
|
556
|
+
expect(revocation_request).to have_been_requested
|
557
|
+
end
|
558
|
+
end
|
479
559
|
end
|
@@ -2630,6 +2630,67 @@ describe Cronofy::Client do
|
|
2630
2630
|
|
2631
2631
|
end
|
2632
2632
|
|
2633
|
+
describe "Remove Recipient Smart Invite", test: true do
|
2634
|
+
let(:request_url) { "https://api.cronofy.com/v1/smart_invites" }
|
2635
|
+
let(:method) { :post }
|
2636
|
+
|
2637
|
+
let(:request_headers) do
|
2638
|
+
{
|
2639
|
+
"Authorization" => "Bearer #{client_secret}",
|
2640
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2641
|
+
"Content-Type" => "application/json; charset=utf-8",
|
2642
|
+
}
|
2643
|
+
end
|
2644
|
+
|
2645
|
+
let(:client_id) { 'example_id' }
|
2646
|
+
let(:client_secret) { 'example_secret' }
|
2647
|
+
|
2648
|
+
let(:client) do
|
2649
|
+
Cronofy::Client.new(
|
2650
|
+
client_id: client_id,
|
2651
|
+
client_secret: client_secret,
|
2652
|
+
)
|
2653
|
+
end
|
2654
|
+
|
2655
|
+
let(:args) do
|
2656
|
+
{
|
2657
|
+
smart_invite_id: "qTtZdczOccgaPncGJaCiLg",
|
2658
|
+
recipient: {
|
2659
|
+
email: "example@example.com"
|
2660
|
+
}
|
2661
|
+
}
|
2662
|
+
end
|
2663
|
+
|
2664
|
+
let(:request_body) do
|
2665
|
+
{
|
2666
|
+
method: 'remove',
|
2667
|
+
smart_invite_id: "qTtZdczOccgaPncGJaCiLg",
|
2668
|
+
recipient: {
|
2669
|
+
email: "example@example.com"
|
2670
|
+
}
|
2671
|
+
}
|
2672
|
+
end
|
2673
|
+
let(:correct_response_code) { 202 }
|
2674
|
+
let(:correct_response_body) do
|
2675
|
+
request_body.merge({
|
2676
|
+
attachments: {
|
2677
|
+
removed: {
|
2678
|
+
email: "example@example.com"
|
2679
|
+
}
|
2680
|
+
}
|
2681
|
+
})
|
2682
|
+
end
|
2683
|
+
|
2684
|
+
let(:correct_mapped_result) do
|
2685
|
+
Cronofy::SmartInviteResponse.new(correct_response_body)
|
2686
|
+
end
|
2687
|
+
|
2688
|
+
subject { client.remove_recipient_smart_invite(request_body) }
|
2689
|
+
|
2690
|
+
it_behaves_like 'a Cronofy request'
|
2691
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2692
|
+
end
|
2693
|
+
|
2633
2694
|
describe "Batch requests" do
|
2634
2695
|
context "upserting an event" do
|
2635
2696
|
let(:calendar_id) { 'calendar_id_123'}
|
@@ -3091,4 +3152,160 @@ describe Cronofy::Client do
|
|
3091
3152
|
|
3092
3153
|
it_behaves_like 'a Cronofy request'
|
3093
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
|
3094
3311
|
end
|
metadata
CHANGED
@@ -1,30 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.37.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:
|
12
|
+
date: 2021-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: oauth2
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '1.0'
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '1.0'
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: hashie
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +20,7 @@ dependencies:
|
|
34
20
|
version: '2.1'
|
35
21
|
- - "<"
|
36
22
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
23
|
+
version: '5'
|
38
24
|
type: :runtime
|
39
25
|
prerelease: false
|
40
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -44,7 +30,21 @@ dependencies:
|
|
44
30
|
version: '2.1'
|
45
31
|
- - "<"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '5'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: oauth2
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: bundler
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.2.4
|
160
|
+
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Cronofy - one API for all the calendars
|
163
163
|
test_files:
|