cronofy 0.16.0 → 0.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12dca20c7955f97eac5e93f6f793e38a0363e0f1
4
- data.tar.gz: a9017b0ee2708bb4cbb792507959658fd9f9a138
3
+ metadata.gz: 1a517f51f9e209fd7b2f27d26c97daf641a45b90
4
+ data.tar.gz: d701d1ca79903ab281ffe138c2d53bb22d81d723
5
5
  SHA512:
6
- metadata.gz: c627b9fc733638bd60bf6248919a6fa6ccbfc27f3c0836d487ca9712867cb328b0d0dd5f80c7c1f97f001b1304646f0791cda7a632583da7132e034549b81690
7
- data.tar.gz: 804e5ac5f5353050105435fda63a03bbbe2577b4e214464dd8c221782719c4c2f96530bbc45f081d38650d2e6dee6eb99510f80f961781e1e38f60461eeb5dbc
6
+ metadata.gz: 8aa4f73c917c397d1a2306b40a6f76d4d198186b527c4cbaa974879772551b8140b1cdbe986dcc28f103c476da92f3dae75dc56f1535d5cb87194d62a51dc152
7
+ data.tar.gz: f132c20db5a57edd377b3b71d8746bc96900d0bea0c642df78255cb55af36f729ffb66929517685494c1fd8f40557e50ddeb600a3d6468e142b4c9d63545a508
data/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+ ## [0.17.0]
2
+
3
+ * Support member-specific available periods for Availability API [#27]
4
+
5
+ ## [0.16.0]
6
+
7
+ * Support Availability API [#26]
8
+
9
+ ## [0.15.0]
10
+
11
+ * Support for upcoming geo location feature [#24]
12
+
13
+ ## [0.14.0]
14
+
15
+ * Support for setting participant status [#20]
16
+
17
+ ## [0.13.0]
18
+
19
+ * Support for listing resources [#18]
20
+
21
+ ## [0.12.0]
22
+
23
+ * Support for deleting external events [#17]
24
+
25
+ ## [0.11.0]
26
+
27
+ * Support for Enterprise Connect [#13]
28
+ * Support for elevating permissions [#16]
29
+
30
+
31
+ [0.11.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.11.0
32
+ [0.12.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.12.0
33
+ [0.13.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.13.0
34
+ [0.14.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.14.0
35
+ [0.15.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.15.0
36
+ [0.16.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.16.0
37
+ [0.17.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.17.0
38
+
39
+ [#13]: https://github.com/cronofy/cronofy-ruby/pull/13
40
+ [#16]: https://github.com/cronofy/cronofy-ruby/pull/16
41
+ [#17]: https://github.com/cronofy/cronofy-ruby/pull/17
42
+ [#18]: https://github.com/cronofy/cronofy-ruby/pull/18
43
+ [#20]: https://github.com/cronofy/cronofy-ruby/pull/20
44
+ [#24]: https://github.com/cronofy/cronofy-ruby/pull/24
45
+ [#26]: https://github.com/cronofy/cronofy-ruby/pull/26
46
+ [#27]: https://github.com/cronofy/cronofy-ruby/pull/27
data/cronofy.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.require_paths = ["lib"]
14
14
 
15
- spec.files = %w{Gemfile LICENSE.txt README.md Rakefile cronofy.gemspec}
15
+ spec.files = %w{CHANGELOG.md Gemfile LICENSE.txt README.md Rakefile cronofy.gemspec}
16
16
  spec.files += Dir['lib/**/*.rb']
17
17
  spec.files += Dir['spec/**/*.rb']
18
18
  spec.test_files = Dir['spec/**/*.rb']
@@ -652,8 +652,8 @@ module Cronofy
652
652
  # Public: Performs an availability query.
653
653
  #
654
654
  # options - The Hash options used to refine the selection (default: {}):
655
- # :participants - An Array of participant groups (or required
656
- # particpants for the simple case).
655
+ # :participants - An Array of participant groups or a Hash
656
+ # for a single participant group.
657
657
  # :required_duration - An Integer representing the minimum number
658
658
  # of minutes of availability required.
659
659
  # :available_periods - An Array of available time periods Hashes,
@@ -674,11 +674,7 @@ module Cronofy
674
674
  options[:participants] = map_availability_participants(options[:participants])
675
675
  options[:required_duration] = map_availability_required_duration(options[:required_duration])
676
676
 
677
- options[:available_periods].each do |params|
678
- AVAILABLE_PERIODS_TIME_PARAMS.select { |tp| params.key?(tp) }.each do |tp|
679
- params[tp] = to_iso8601(params[tp])
680
- end
681
- end
677
+ translate_available_periods(options[:available_periods])
682
678
 
683
679
  response = post("/v1/availability", options)
684
680
  parse_collection(AvailablePeriod, "available_periods", response)
@@ -686,7 +682,29 @@ module Cronofy
686
682
 
687
683
  private
688
684
 
685
+ def translate_available_periods(periods)
686
+ periods.each do |params|
687
+ AVAILABLE_PERIODS_TIME_PARAMS.select { |tp| params.key?(tp) }.each do |tp|
688
+ params[tp] = to_iso8601(params[tp])
689
+ end
690
+ end
691
+ end
692
+
689
693
  def map_availability_participants(participants)
694
+ case participants
695
+ when Hash
696
+ # Allow one group to be specified without being nested
697
+ [map_availability_participants_group(participants)]
698
+ when Enumerable
699
+ participants.map do |group|
700
+ map_availability_participants_group(group)
701
+ end
702
+ else
703
+ participants
704
+ end
705
+ end
706
+
707
+ def map_availability_participants_group(participants)
690
708
  case participants
691
709
  when Hash
692
710
  participants[:members].map! do |member|
@@ -697,7 +715,11 @@ module Cronofy
697
715
  participants[:required] = :all
698
716
  end
699
717
 
700
- [participants]
718
+ participants
719
+ when Array
720
+ participants.map do |group|
721
+ map_availability_participants(group)
722
+ end
701
723
  else
702
724
  participants
703
725
  end
@@ -707,6 +729,11 @@ module Cronofy
707
729
  case member
708
730
  when String
709
731
  { sub: member }
732
+ when Hash
733
+ if member[:available_periods]
734
+ translate_available_periods(member[:available_periods])
735
+ end
736
+ member
710
737
  else
711
738
  member
712
739
  end
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.16.0".freeze
2
+ VERSION = "0.17.0".freeze
3
3
  end
@@ -1096,7 +1096,7 @@ describe Cronofy::Client do
1096
1096
  end
1097
1097
  end
1098
1098
 
1099
- describe 'Availability', focus: true do
1099
+ describe 'Availability' do
1100
1100
  describe '#availability' do
1101
1101
  let(:method) { :post }
1102
1102
  let(:request_url) { 'https://api.cronofy.com/v1/availability' }
@@ -1193,6 +1193,77 @@ describe Cronofy::Client do
1193
1193
  it_behaves_like 'a Cronofy request with mapped return value'
1194
1194
  end
1195
1195
 
1196
+ context "member-specific available periods" do
1197
+ let(:request_body) do
1198
+ {
1199
+ "participants" => [
1200
+ {
1201
+ "members" => [
1202
+ { "sub" => "acc_567236000909002" },
1203
+ {
1204
+ "sub" => "acc_678347111010113",
1205
+ "available_periods" => [
1206
+ {
1207
+ "start" => "2017-01-03T09:00:00Z",
1208
+ "end" => "2017-01-03T12:00:00Z"
1209
+ },
1210
+ {
1211
+ "start" => "2017-01-04T10:00:00Z",
1212
+ "end" => "2017-01-04T20:00:00Z"
1213
+ }
1214
+ ]
1215
+ }
1216
+ ],
1217
+ "required" => "all"
1218
+ }
1219
+ ],
1220
+ "required_duration" => { "minutes" => 60 },
1221
+ "available_periods" => [
1222
+ {
1223
+ "start" => "2017-01-03T09:00:00Z",
1224
+ "end" => "2017-01-03T18:00:00Z"
1225
+ },
1226
+ {
1227
+ "start" => "2017-01-04T09:00:00Z",
1228
+ "end" => "2017-01-04T18:00:00Z"
1229
+ }
1230
+ ]
1231
+ }
1232
+ end
1233
+
1234
+ let(:participants) do
1235
+ [
1236
+ {
1237
+ members: [
1238
+ { sub: "acc_567236000909002" },
1239
+ {
1240
+ sub: "acc_678347111010113",
1241
+ available_periods: [
1242
+ { start: Time.parse("2017-01-03T09:00:00Z"), end: Time.parse("2017-01-03T12:00:00Z") },
1243
+ { start: Time.parse("2017-01-04T10:00:00Z"), end: Time.parse("2017-01-04T20:00:00Z") },
1244
+ ],
1245
+ },
1246
+ ],
1247
+ required: :all,
1248
+ }
1249
+ ]
1250
+ end
1251
+
1252
+ let(:required_duration) do
1253
+ { minutes: 60 }
1254
+ end
1255
+
1256
+ let(:available_periods) do
1257
+ [
1258
+ { start: Time.parse("2017-01-03T09:00:00Z"), end: Time.parse("2017-01-03T18:00:00Z") },
1259
+ { start: Time.parse("2017-01-04T09:00:00Z"), end: Time.parse("2017-01-04T18:00:00Z") },
1260
+ ]
1261
+ end
1262
+
1263
+ it_behaves_like 'a Cronofy request'
1264
+ it_behaves_like 'a Cronofy request with mapped return value'
1265
+ end
1266
+
1196
1267
  context "simple values to defaults" do
1197
1268
  let(:participants) do
1198
1269
  { members: %w{acc_567236000909002 acc_678347111010113} }
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.16.0
4
+ version: 0.17.0
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: 2017-01-30 00:00:00.000000000 Z
12
+ date: 2017-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2
@@ -109,6 +109,7 @@ executables: []
109
109
  extensions: []
110
110
  extra_rdoc_files: []
111
111
  files:
112
+ - CHANGELOG.md
112
113
  - Gemfile
113
114
  - LICENSE.txt
114
115
  - README.md