cronofy 0.32.0 → 0.36.1
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/client.rb +120 -0
- data/lib/cronofy/errors.rb +15 -0
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/client_spec.rb +267 -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: f05693cffaf2848f4ff1d8dbc874ca832a04a13670ab5c30219a4927e04d0d4b
|
4
|
+
data.tar.gz: cdbd7c8463b2ae594d7fce826343e453c1099d2f603fd267c0e2b9e1cb98e145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44018884d14fe47332fe1e5fca9754ef1357005d9643fb91960886a04d20afec8670a8e340a36ed19b5fb4e04a6e7e02454b48a959474d46f9985998e7079d77
|
7
|
+
data.tar.gz: eca3eb5a85e980ebd72d3416b48b945d6f0dfb832cf63ad8baf7c0cecf3b4429b5682ea69ea9a41b93ad08f498228f7e901f84941a2e6f0e784cfdc444b2b192
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## [0.36.1]
|
2
|
+
|
3
|
+
* Loosen the version requirement on Hashie to allow 4.X
|
4
|
+
|
5
|
+
## [0.36.0]
|
6
|
+
|
7
|
+
* Add support for Available Periods [#81]
|
8
|
+
|
9
|
+
## [0.35.0]
|
10
|
+
|
11
|
+
* Add specific errors for network issues [#77]
|
12
|
+
|
13
|
+
## [0.34.0]
|
14
|
+
|
15
|
+
* Support removing a participant from a Smart Invite [#75]
|
16
|
+
|
17
|
+
## [0.33.0]
|
18
|
+
|
19
|
+
* Support listing Availability Rules [#74]
|
20
|
+
|
1
21
|
## [0.32.0]
|
2
22
|
|
3
23
|
* Support Availability Rules and Scheduling Conversations [#64]
|
@@ -147,6 +167,11 @@
|
|
147
167
|
[0.31.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.1
|
148
168
|
[0.31.2]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.2
|
149
169
|
[0.32.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.32.0
|
170
|
+
[0.33.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.33.0
|
171
|
+
[0.34.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.34.0
|
172
|
+
[0.35.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.35.0
|
173
|
+
[0.36.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.0
|
174
|
+
[0.36.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.1
|
150
175
|
|
151
176
|
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
|
152
177
|
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
|
@@ -183,3 +208,8 @@
|
|
183
208
|
[#69]: https://github.com/cronofy/cronofy-ruby/pull/69
|
184
209
|
[#72]: https://github.com/cronofy/cronofy-ruby/pull/72
|
185
210
|
[#73]: https://github.com/cronofy/cronofy-ruby/pull/73
|
211
|
+
[#74]: https://github.com/cronofy/cronofy-ruby/pull/74
|
212
|
+
[#75]: https://github.com/cronofy/cronofy-ruby/pull/75
|
213
|
+
[#77]: https://github.com/cronofy/cronofy-ruby/pull/77
|
214
|
+
[#81]: https://github.com/cronofy/cronofy-ruby/pull/81
|
215
|
+
[#85]: https://github.com/cronofy/cronofy-ruby/pull/85
|
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/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
|
@@ -1323,6 +1325,32 @@ module Cronofy
|
|
1323
1325
|
parse_json(SmartInviteResponse, nil, response)
|
1324
1326
|
end
|
1325
1327
|
|
1328
|
+
# Public: Removes an individual recipient from a multiple recipient smart invite
|
1329
|
+
#
|
1330
|
+
# smart_invite_id - A String uniquely identifying the event for your
|
1331
|
+
# application (note: this is NOT an ID generated
|
1332
|
+
# by Cronofy).
|
1333
|
+
#
|
1334
|
+
# recipient - A Hash containing the recipient to be removed
|
1335
|
+
# :email - A String for the email address of
|
1336
|
+
# the recipient to remove.
|
1337
|
+
#
|
1338
|
+
# See https://docs.cronofy.com/developers/api-alpha/smart-invites/multiple-recipients/#remove-invite-recipient
|
1339
|
+
# for reference.
|
1340
|
+
#
|
1341
|
+
# Returns a SmartInviteResponse
|
1342
|
+
#
|
1343
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1344
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1345
|
+
# parameters.
|
1346
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1347
|
+
# limits for the application.
|
1348
|
+
def remove_recipient_smart_invite(body={})
|
1349
|
+
body[:method] = 'remove'
|
1350
|
+
response = wrapped_request { api_key!.post("/v1/smart_invites", json_request_args(body)) }
|
1351
|
+
parse_json(SmartInviteResponse, nil, response)
|
1352
|
+
end
|
1353
|
+
|
1326
1354
|
# Public: Gets the details for a smart invite.
|
1327
1355
|
#
|
1328
1356
|
# smart_invite_id - A String uniquely identifying the event for your
|
@@ -1435,6 +1463,20 @@ module Cronofy
|
|
1435
1463
|
parse_json(AvailabilityRule, 'availability_rule', response)
|
1436
1464
|
end
|
1437
1465
|
|
1466
|
+
# Public: Gets all AvailabilityRules for an account.
|
1467
|
+
#
|
1468
|
+
# Returns an array of AvailabilityRules.
|
1469
|
+
#
|
1470
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1471
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1472
|
+
# parameters.
|
1473
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1474
|
+
# limits for the application.
|
1475
|
+
def get_availability_rules
|
1476
|
+
response = wrapped_request { get("/v1/availability_rules") }
|
1477
|
+
parse_collection(AvailabilityRule, 'availability_rules', response)
|
1478
|
+
end
|
1479
|
+
|
1438
1480
|
# Public: Deletes an AvailabilityRule.
|
1439
1481
|
#
|
1440
1482
|
# availability_rule_id - A String uniquely identifying the availability rule
|
@@ -1452,6 +1494,84 @@ module Cronofy
|
|
1452
1494
|
nil
|
1453
1495
|
end
|
1454
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
|
+
|
1455
1575
|
# Public: Creates a scheduling conversation
|
1456
1576
|
#
|
1457
1577
|
# 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
@@ -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'}
|
@@ -3029,6 +3090,56 @@ describe Cronofy::Client do
|
|
3029
3090
|
it_behaves_like 'a Cronofy request with mapped return value'
|
3030
3091
|
end
|
3031
3092
|
|
3093
|
+
describe "#get_availability_rules" do
|
3094
|
+
let(:request_url) { "https://api.cronofy.com/v1/availability_rules" }
|
3095
|
+
let(:method) { :get }
|
3096
|
+
|
3097
|
+
let(:correct_response_code) { 200 }
|
3098
|
+
let(:correct_response_body) do
|
3099
|
+
{
|
3100
|
+
"availability_rules" => [
|
3101
|
+
{
|
3102
|
+
"availability_rule_id" => "default",
|
3103
|
+
"tzid" => "America/Chicago",
|
3104
|
+
"calendar_ids" => [
|
3105
|
+
"cal_n23kjnwrw2_jsdfjksn234"
|
3106
|
+
],
|
3107
|
+
"weekly_periods" => [
|
3108
|
+
{
|
3109
|
+
"day" => "monday",
|
3110
|
+
"start_time" => "09:30",
|
3111
|
+
"end_time" => "16:30"
|
3112
|
+
},
|
3113
|
+
{
|
3114
|
+
"day" => "wednesday",
|
3115
|
+
"start_time" => "09:30",
|
3116
|
+
"end_time" => "16:30"
|
3117
|
+
}
|
3118
|
+
]
|
3119
|
+
}
|
3120
|
+
]
|
3121
|
+
}
|
3122
|
+
end
|
3123
|
+
|
3124
|
+
let(:correct_mapped_result) do
|
3125
|
+
rule = correct_response_body['availability_rules'][0]
|
3126
|
+
|
3127
|
+
[
|
3128
|
+
Cronofy::AvailabilityRule.new(
|
3129
|
+
availability_rule_id: rule['availability_rule_id'],
|
3130
|
+
tzid: rule['tzid'],
|
3131
|
+
calendar_ids: rule['calendar_ids'],
|
3132
|
+
weekly_periods: rule['weekly_periods'].map { |wp| Cronofy::WeeklyPeriod.new(wp) },
|
3133
|
+
)
|
3134
|
+
]
|
3135
|
+
end
|
3136
|
+
|
3137
|
+
subject { client.get_availability_rules }
|
3138
|
+
|
3139
|
+
it_behaves_like 'a Cronofy request'
|
3140
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3141
|
+
end
|
3142
|
+
|
3032
3143
|
describe '#delete_availability_rule' do
|
3033
3144
|
let(:availability_rule_id) { 'default'}
|
3034
3145
|
let(:request_url) { "https://api.cronofy.com/v1/availability_rules/#{availability_rule_id}" }
|
@@ -3041,4 +3152,160 @@ describe Cronofy::Client do
|
|
3041
3152
|
|
3042
3153
|
it_behaves_like 'a Cronofy request'
|
3043
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
|
3044
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.36.1
|
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: 2020-10-20 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.1.2
|
160
|
+
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Cronofy - one API for all the calendars
|
163
163
|
test_files:
|