cronofy 0.31.1 → 0.31.2

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: 57b29b7a7d74bfeb8effadc79dc1b7db32c55666189bf3cd6a752ee472cf2fef
4
- data.tar.gz: 944c20303ab4e950dd6a9fc69e087dff461f50be68a68a2ca97556821529113f
3
+ metadata.gz: 2ac0a6d45f99b6fc43669a1c8bfae0ae9c040d05ca200c9638cf535fcff3ee71
4
+ data.tar.gz: 44ce008bc883118eda39dc75a486834083e71bfb37ff2716629db2d9019578ed
5
5
  SHA512:
6
- metadata.gz: bd2f6482085df5c981a1a31ba9a816ec8cf36a7273c93eb27616a2613f16b9fd00b3803368d6aa9e8373b38eff1686429ce7274f5d30ebc306610f0a9d6ddfee
7
- data.tar.gz: 452f25bfe0a6009428fd0ff7f52bd9191391349db2baee1ac325b9fbc76368619ad5f4c944d0cd20ceae7b7c4349441d6b04a67ecfb61a398a0be5a26afedf45
6
+ metadata.gz: e9e8ff68fbfa8a4fe9582a259dd885f3d8cd155ec455fccbdab736acc3fdfae655ce2ec17eeb81a954774a6c311172c28d0be24721179ef408b08bb060b3fe9d
7
+ data.tar.gz: 3f0632f1a75377bcbcca43fbe03557c91dff7492ed1122688bd160e7c5227c0620c0b8765f46cbac54fe53aafb8fd6d2b224fbb07beee41d7d67d3358e7a3b73
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.31.2]
2
+
3
+ * Support parsing new Availability response formats [#73]
4
+
1
5
  ## [0.31.1]
2
6
 
3
7
  * No Authorization header for Real-Time Scheduling and Real-Time Sequencing [#72]
@@ -137,6 +141,7 @@
137
141
  [0.30.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.30.0
138
142
  [0.31.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.0
139
143
  [0.31.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.1
144
+ [0.31.2]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.2
140
145
 
141
146
  [#13]: https://github.com/cronofy/cronofy-ruby/pull/13
142
147
  [#16]: https://github.com/cronofy/cronofy-ruby/pull/16
@@ -171,3 +176,4 @@
171
176
  [#62]: https://github.com/cronofy/cronofy-ruby/pull/62
172
177
  [#69]: https://github.com/cronofy/cronofy-ruby/pull/69
173
178
  [#72]: https://github.com/cronofy/cronofy-ruby/pull/72
179
+ [#73]: https://github.com/cronofy/cronofy-ruby/pull/73
@@ -826,7 +826,12 @@ module Cronofy
826
826
  translate_available_periods(options[:available_periods])
827
827
 
828
828
  response = post("/v1/availability", options)
829
- parse_collection(AvailablePeriod, "available_periods", response)
829
+
830
+ parse_collections(
831
+ response,
832
+ available_periods: AvailablePeriod,
833
+ available_slots: AvailableSlot,
834
+ )
830
835
  end
831
836
 
832
837
  # Public: Performs an sequenced availability query.
@@ -1553,6 +1558,10 @@ module Cronofy
1553
1558
  ResponseParser.new(response).parse_collection(type, attr)
1554
1559
  end
1555
1560
 
1561
+ def parse_collections(response, mappings)
1562
+ ResponseParser.new(response).parse_collections(mappings)
1563
+ end
1564
+
1556
1565
  def parse_json(type, attr = nil, response)
1557
1566
  ResponseParser.new(response).parse_json(type, attr)
1558
1567
  end
@@ -7,6 +7,14 @@ module Cronofy
7
7
  @response = response
8
8
  end
9
9
 
10
+ def parse_collections(attribute_collection_types)
11
+ attribute_collection_types.each do |attribute, type|
12
+ return parse_collection(type, attribute.to_s) if json_hash[attribute.to_s]
13
+ end
14
+
15
+ raise "No mapped attributes for response - #{json_hash.keys}"
16
+ end
17
+
10
18
  def parse_collection(type, attribute = nil)
11
19
  target = parsing_target(attribute)
12
20
  target.map { |item| type.new(item) }
data/lib/cronofy/types.rb CHANGED
@@ -378,6 +378,13 @@ module Cronofy
378
378
  coerce_key :participants, ParticipantEnumerable
379
379
  end
380
380
 
381
+ class AvailableSlot < CronofyMash
382
+ coerce_key :start, EventTime
383
+ coerce_key :end, EventTime
384
+
385
+ coerce_key :participants, ParticipantEnumerable
386
+ end
387
+
381
388
  class ElementToken < CronofyMash
382
389
  end
383
390
  end
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.31.1".freeze
2
+ VERSION = "0.31.2".freeze
3
3
  end
@@ -1281,10 +1281,13 @@ describe Cronofy::Client do
1281
1281
  }
1282
1282
  end
1283
1283
 
1284
+ let(:availability_response_attribute) { "available_periods" }
1285
+ let(:availability_response_class) { Cronofy::AvailablePeriod }
1286
+
1284
1287
  let(:correct_response_code) { 200 }
1285
1288
  let(:correct_response_body) do
1286
1289
  {
1287
- "available_periods" => [
1290
+ availability_response_attribute => [
1288
1291
  {
1289
1292
  "start" => "2017-01-03T09:00:00Z",
1290
1293
  "end" => "2017-01-03T11:00:00Z",
@@ -1314,11 +1317,85 @@ describe Cronofy::Client do
1314
1317
  end
1315
1318
 
1316
1319
  let(:correct_mapped_result) do
1317
- correct_response_body['available_periods'].map { |ap| Cronofy::AvailablePeriod.new(ap) }
1320
+ correct_response_body[availability_response_attribute].map { |ap| availability_response_class.new(ap) }
1318
1321
  end
1319
1322
 
1320
1323
  subject { client.availability(participants: participants, required_duration: required_duration, available_periods: available_periods) }
1321
1324
 
1325
+ context "response_format" do
1326
+ %i{
1327
+ slots
1328
+ overlapping_slots
1329
+ }.each do |slot_format|
1330
+ context slot_format do
1331
+ let(:response_format) { slot_format.to_s }
1332
+ let(:availability_response_attribute) { "available_slots" }
1333
+ let(:availability_response_class) { Cronofy::AvailableSlot }
1334
+
1335
+ let(:required_duration) do
1336
+ { minutes: 60 }
1337
+ end
1338
+
1339
+ let(:available_periods) do
1340
+ [
1341
+ { start: Time.parse("2017-01-03T09:00:00Z"), end: Time.parse("2017-01-03T18:00:00Z") },
1342
+ { start: Time.parse("2017-01-04T09:00:00Z"), end: Time.parse("2017-01-04T18:00:00Z") },
1343
+ ]
1344
+ end
1345
+
1346
+ let(:participants) do
1347
+ [
1348
+ {
1349
+ members: [
1350
+ { sub: "acc_567236000909002" },
1351
+ { sub: "acc_678347111010113" },
1352
+ ],
1353
+ required: :all,
1354
+ }
1355
+ ]
1356
+ end
1357
+
1358
+ let(:request_body) do
1359
+ {
1360
+ "participants" => [
1361
+ {
1362
+ "members" => [
1363
+ { "sub" => "acc_567236000909002" },
1364
+ { "sub" => "acc_678347111010113" }
1365
+ ],
1366
+ "required" => "all"
1367
+ }
1368
+ ],
1369
+ "required_duration" => { "minutes" => 60 },
1370
+ "available_periods" => [
1371
+ {
1372
+ "start" => "2017-01-03T09:00:00Z",
1373
+ "end" => "2017-01-03T18:00:00Z"
1374
+ },
1375
+ {
1376
+ "start" => "2017-01-04T09:00:00Z",
1377
+ "end" => "2017-01-04T18:00:00Z"
1378
+ }
1379
+ ],
1380
+ "response_format" => response_format,
1381
+ }
1382
+ end
1383
+
1384
+ subject do
1385
+ client.availability(
1386
+ participants: participants,
1387
+ required_duration: required_duration,
1388
+ available_periods: available_periods,
1389
+ response_format: slot_format,
1390
+ )
1391
+ end
1392
+
1393
+ it_behaves_like 'a Cronofy request'
1394
+ it_behaves_like 'a Cronofy request with mapped return value'
1395
+ end
1396
+ end
1397
+ end
1398
+
1322
1399
  context "fully specified" do
1323
1400
  let(:participants) do
1324
1401
  [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cronofy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.1
4
+ version: 0.31.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergii Paryzhskyi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-09 00:00:00.000000000 Z
12
+ date: 2019-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2