cronofy 0.37.7 → 0.41.0

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: 72f9a743962bf3c47bdef28e93c0fd4d7cf5fd66101eec219f028ea90fe6291c
4
- data.tar.gz: ec455881ea2d6df1e86896508453dbcc6d89173275d23a1fe92b565ee01e1144
3
+ metadata.gz: 70859d7df67d1abfb03702825b4a304a8e2426f7073d9055343559cb9e41e469
4
+ data.tar.gz: 0f778ceec16c9a4fd9f25a9cc50f6f7957f643aa8e1980e35d7690483f8cdea5
5
5
  SHA512:
6
- metadata.gz: c00a81c85732364c3b6cc384c9bbdc1f10fbacfa756c09959734abbefbe65f58f9de764a8e019f40ba0ec17f4355fb4900c4a457e0cac2d98a0a8dfc653886fd
7
- data.tar.gz: 6529d3936e84d1721b458bfdfd2acb91585ba7b425d49c7b839f2cdce621d7ae1ba9d1896c471aaecdc6e16474c6f7b0002aa09a64b1390684e5601fa64f35c7
6
+ metadata.gz: 0b15136e06190b874efc0d32c1cb4efa16bf093c0473faf1ad2fb59f66511ef44069cad5199f1f63e9d05e25e74c6376cd4534c380073ec59b55ddc8ef7f6b7c
7
+ data.tar.gz: 65256a5f09863beb7d620746e6d5fb9d79242c9d374adba3161c1439a9bb93ebf96cbde2b65c72a81876d03a7abec218ea60cb43e50506a47f9a98a112da39c1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [0.41.0]
2
+
3
+ * Adds support for the query_slots parameter [#111]
4
+
5
+ ## [0.40.0]
6
+
7
+ * Update version of [OAuth2](https://rubygems.org/gems/oauth2) required [#102]
8
+
9
+ ## [0.39.0]
10
+
11
+ * Add conferencing services authorization
12
+
13
+ ## [0.38.0]
14
+
15
+ * Add state parameter to Service Account authorizations [#104]
16
+
1
17
  ## [0.37.7]
2
18
 
3
19
  * Update Gem description
@@ -212,6 +228,10 @@
212
228
  [0.37.5]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.5
213
229
  [0.37.6]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.6
214
230
  [0.37.7]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.7
231
+ [0.38.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/0.38.0
232
+ [0.39.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/0.39.0
233
+ [0.40.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.40.0
234
+ [0.41.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.41.0
215
235
 
216
236
  [#13]: https://github.com/cronofy/cronofy-ruby/pull/13
217
237
  [#16]: https://github.com/cronofy/cronofy-ruby/pull/16
@@ -260,3 +280,7 @@
260
280
  [#97]: https://github.com/cronofy/cronofy-ruby/pull/97
261
281
  [#99]: https://github.com/cronofy/cronofy-ruby/pull/99
262
282
  [#100]: https://github.com/cronofy/cronofy-ruby/pull/100
283
+ [#102]: https://github.com/cronofy/cronofy-ruby/pull/102
284
+ [#104]: https://github.com/cronofy/cronofy-ruby/pull/104
285
+ [#108]: https://github.com/cronofy/cronofy-ruby/pull/108
286
+ [#111]: https://github.com/cronofy/cronofy-ruby/pull/111
data/README.md CHANGED
@@ -45,8 +45,8 @@ When using a [personal access token](https://app.cronofy.com/oauth/applications/
45
45
  you only need to provide the `access_token` argument.
46
46
 
47
47
  When working against your own OAuth application you will need to provide the
48
- `client_id` and `client_secret` when [going through the authorization process](https://www.cronofy.com/developers/api/#authorization)
49
- for a user, and when [refreshing an access token](https://www.cronofy.com/developers/api/#token-refresh).
48
+ `client_id` and `client_secret` when [going through the authorization process](https://docs.cronofy.com/developers/api/authorization/request-authorization/)
49
+ for a user, and when [refreshing an access token](https://docs.cronofy.com/developers/api/authorization/refresh-token/).
50
50
 
51
51
  If `client_id` and `client_secret` are not specified explicitly the values from
52
52
  the environment variables `CRONOFY_CLIENT_ID` and `CRONOFY_CLIENT_SECRET` will
@@ -56,7 +56,7 @@ be used if present.
56
56
 
57
57
  ## Authorization
58
58
 
59
- [API documentation](https://www.cronofy.com/developers/api/#authorization)
59
+ [API documentation](https://docs.cronofy.com/developers/api/authorization/request-authorization/)
60
60
 
61
61
  Generate a link for a user to grant access to their calendars:
62
62
 
@@ -83,7 +83,7 @@ to perform this process.
83
83
 
84
84
  ## List calendars
85
85
 
86
- [API documentation](https://www.cronofy.com/developers/api/#calendars)
86
+ [API documentation](https://docs.cronofy.com/developers/api/calendars/list-calendars/)
87
87
 
88
88
  Get a list of all the user's calendars:
89
89
 
@@ -93,7 +93,7 @@ calendars = cronofy.list_calendars
93
93
 
94
94
  ## Read events
95
95
 
96
- [API documentation](https://www.cronofy.com/developers/api/#read-events)
96
+ [API documentation](https://docs.cronofy.com/developers/api/events/read-events/)
97
97
 
98
98
  Get a list of events from the user's calendars:
99
99
 
@@ -105,7 +105,7 @@ Note that the gem handles iterating through the pages on your behalf.
105
105
 
106
106
  ## Create or update events
107
107
 
108
- [API documentation](https://www.cronofy.com/developers/api/#upsert-event)
108
+ [API documentation](https://docs.cronofy.com/developers/api/events/upsert-event/)
109
109
 
110
110
  To create/update an event in the user's calendar:
111
111
 
@@ -126,7 +126,7 @@ cronofy.upsert_event(calendar_id, event_data)
126
126
 
127
127
  ## Delete events
128
128
 
129
- [API documentation](https://www.cronofy.com/developers/api/#delete-event)
129
+ [API documentation](https://docs.cronofy.com/developers/api/events/delete-event/)
130
130
 
131
131
  To delete an event from user's calendar:
132
132
 
@@ -145,6 +145,6 @@ If you would like to request a feature is added by our team then please let us k
145
145
 
146
146
  ## Links
147
147
 
148
- * [API documentation](https://www.cronofy.com/developers/api)
148
+ * [API documentation](https://docs.cronofy.com/developers/api/)
149
149
  * [API mailing list](https://groups.google.com/d/forum/cronofy-api)
150
150
 
data/cronofy.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = Dir['spec/**/*.rb']
19
19
 
20
20
  spec.add_runtime_dependency "hashie", ">= 2.1", "< 5"
21
- spec.add_runtime_dependency "oauth2", "~> 1.0"
21
+ spec.add_runtime_dependency "oauth2", ">= 2.0.4"
22
22
 
23
23
  spec.add_development_dependency "bundler", ">= 1.6", "< 3"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
@@ -15,6 +15,7 @@ module Cronofy
15
15
  # @see Client#request
16
16
  def request(verb, path, opts = {}, &block)
17
17
  configure_authentication!(opts)
18
+ opts = { snaky: false }.merge(opts)
18
19
  do_request { @client.request(verb, path, opts, &block) }
19
20
  end
20
21
 
data/lib/cronofy/auth.rb CHANGED
@@ -16,8 +16,8 @@ module Cronofy
16
16
 
17
17
  @client_credentials_missing = blank?(client_id) || blank?(client_secret)
18
18
 
19
- @auth_client = OAuth2::Client.new(client_id, client_secret, site: ::Cronofy.app_url(data_center), connection_opts: { headers: { "User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}" } })
20
- @api_client = OAuth2::Client.new(client_id, client_secret, site: ::Cronofy.api_url(data_center), connection_opts: { headers: { "User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}" } })
19
+ @auth_client = OAuth2::Client.new(client_id, client_secret, site: ::Cronofy.app_url(data_center), auth_scheme: :request_body, connection_opts: { headers: { "User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}" } })
20
+ @api_client = OAuth2::Client.new(client_id, client_secret, site: ::Cronofy.api_url(data_center), auth_scheme: :request_body, connection_opts: { headers: { "User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}" } })
21
21
 
22
22
  set_access_token(access_token, refresh_token) if access_token || refresh_token
23
23
  set_api_key(client_secret) if client_secret
@@ -35,7 +35,7 @@ module Cronofy
35
35
  # :state - Array of states to retain during the OAuth
36
36
  # authorization process (optional).
37
37
  #
38
- # See http://www.cronofy.com/developers/api#authorization for reference.
38
+ # See https://docs.cronofy.com/developers/api/authorization/request-authorization/ for reference.
39
39
  #
40
40
  # Returns the URL as a String.
41
41
  def user_auth_link(redirect_uri, options = {})
@@ -54,7 +54,7 @@ module Cronofy
54
54
  # (default: {}):
55
55
  # :color - The color to make the calendar (optional).
56
56
  #
57
- # See https://www.cronofy.com/developers/api/#create-calendar for reference.
57
+ # See https://docs.cronofy.com/developers/api/calendars/create-calendar/ for reference.
58
58
  #
59
59
  # Returns the created Calendar
60
60
  #
@@ -77,7 +77,7 @@ module Cronofy
77
77
 
78
78
  # Public: Lists all the calendars for the account.
79
79
  #
80
- # See http://www.cronofy.com/developers/api#calendars for reference.
80
+ # See https://docs.cronofy.com/developers/api/calendars/list-calendars/ for reference.
81
81
  #
82
82
  # Returns an Array of Calendars
83
83
  #
@@ -148,7 +148,7 @@ module Cronofy
148
148
  # long: "0.1234"
149
149
  # })
150
150
  #
151
- # See http://www.cronofy.com/developers/api#upsert-event for reference.
151
+ # See https://docs.cronofy.com/developers/api/events/upsert-event/ for reference.
152
152
  #
153
153
  # Returns nothing.
154
154
  #
@@ -214,7 +214,7 @@ module Cronofy
214
214
  # The first page will be retrieved eagerly so that common errors will happen
215
215
  # inline. However, subsequent pages (if any) will be requested lazily.
216
216
  #
217
- # See http://www.cronofy.com/developers/api#read-events for reference.
217
+ # See https://docs.cronofy.com/developers/api/events/read-events/ for reference.
218
218
  #
219
219
  # Returns a lazily-evaluated Enumerable of Events
220
220
  #
@@ -262,7 +262,7 @@ module Cronofy
262
262
  # The first page will be retrieved eagerly so that common errors will happen
263
263
  # inline. However, subsequent pages (if any) will be requested lazily.
264
264
  #
265
- # See http://www.cronofy.com/developers/api/#free-busy for reference.
265
+ # See https://docs.cronofy.com/developers/api/events/free-busy/ for reference.
266
266
  #
267
267
  # Returns a lazily-evaluated Enumerable of FreeBusy
268
268
  #
@@ -293,7 +293,7 @@ module Cronofy
293
293
  # event_id - A String uniquely identifying the event for your application
294
294
  # (note: this is NOT an ID generated by Cronofy).
295
295
  #
296
- # See http://www.cronofy.com/developers/api#delete-event for reference.
296
+ # See https://docs.cronofy.com/developers/api/events/delete-event/ for reference.
297
297
  #
298
298
  # Returns nothing.
299
299
  #
@@ -312,6 +312,24 @@ module Cronofy
312
312
  nil
313
313
  end
314
314
 
315
+ # Public: Returns an URL where users can authorize access to their conferencing services.
316
+ #
317
+ # See https://docs.cronofy.com/developers/api/conferencing-services/authorization/ for reference.
318
+ #
319
+ # Returns Cronofy::ConferencingServiceAuthorizationResponse with the generated URL
320
+ #
321
+ # Raises Cronofy::BadRequestError if refresh token code is unknown or has
322
+ # been revoked.
323
+ # Raises Cronofy::AuthenticationFailureError if the client ID and secret are
324
+ # not valid.
325
+ # Raises Cronofy::CredentialsMissingError if no credentials available.
326
+ def get_conferencing_service_authorizations(redirect_uri)
327
+ data = { redirect_uri: redirect_uri }
328
+
329
+ response = post "/v1/conferencing_service_authorizations", data
330
+ parse_json(ConferencingServiceAuthorizationResponse, "authorization_request", response)
331
+ end
332
+
315
333
  class BatchBuilder
316
334
  include TimeEncoding
317
335
 
@@ -407,7 +425,7 @@ module Cronofy
407
425
 
408
426
  # Public: Deletes all events you are managing for the account.
409
427
  #
410
- # See https://www.cronofy.com/developers/api/#bulk-delete-events for
428
+ # See https://docs.cronofy.com/developers/api/events/bulk-delete-events/ for
411
429
  # reference.
412
430
  #
413
431
  # options - The Hash options used to refine the selection (optional):
@@ -451,7 +469,7 @@ module Cronofy
451
469
  # trigger notifications
452
470
  # (optional).
453
471
  #
454
- # See http://www.cronofy.com/developers/api#create-channel for reference.
472
+ # See https://docs.cronofy.com/developers/api/push-notifications/create-channel/ for reference.
455
473
  #
456
474
  # Returns a Channel.
457
475
  #
@@ -502,7 +520,7 @@ module Cronofy
502
520
 
503
521
  # Public: Lists all the notification channels for the account.
504
522
  #
505
- # See http://www.cronofy.com/developers/api#list-channels for reference.
523
+ # See https://docs.cronofy.com/developers/api/push-notifications/list-channels/ for reference.
506
524
  #
507
525
  # Returns an Array of Channels.
508
526
  #
@@ -522,7 +540,7 @@ module Cronofy
522
540
  #
523
541
  # channel_id - The String Cronofy ID for the channel to close.
524
542
  #
525
- # See http://www.cronofy.com/developers/api#close-channel for reference.
543
+ # See https://docs.cronofy.com/developers/api/push-notifications/close-channel/ for reference.
526
544
  #
527
545
  # Returns nothing.
528
546
  #
@@ -541,7 +559,7 @@ module Cronofy
541
559
 
542
560
  # Public: Retrieves the details of the account.
543
561
  #
544
- # See http://www.cronofy.com/developers/api#account for reference.
562
+ # See https://docs.cronofy.com/developers/api/identity/account/ for reference.
545
563
  #
546
564
  # Returns an Account.
547
565
  #
@@ -559,7 +577,7 @@ module Cronofy
559
577
 
560
578
  # Public: Lists all the profiles for the account.
561
579
  #
562
- # See https://www.cronofy.com/developers/api/#profiles for reference.
580
+ # See https://docs.cronofy.com/developers/api/identity/profile/ for reference.
563
581
  #
564
582
  # Returns an Array of Profiles
565
583
  #
@@ -575,7 +593,7 @@ module Cronofy
575
593
 
576
594
  # Public: Retrieves the userinfo for the account
577
595
  #
578
- # See http://openid.net/specs/openid-connect-core-1_0.html#UserInfo for
596
+ # See https://docs.cronofy.com/developers/api/identity/userinfo/ for
579
597
  # reference.
580
598
  #
581
599
  # Returns an UserInfo.
@@ -603,7 +621,7 @@ module Cronofy
603
621
  # invite to
604
622
  #
605
623
  #
606
- # See http://www.cronofy.com/developers/api#delete-event for reference.
624
+ # See https://docs.cronofy.com/developers/api/events/delete-event/ for reference.
607
625
  #
608
626
  # Returns nothing.
609
627
  #
@@ -641,7 +659,7 @@ module Cronofy
641
659
  # longer valid.
642
660
  # Raises Cronofy::TooManyRequestsError if the request exceeds the rate
643
661
  # limits for the application.
644
- def authorize_with_service_account(email, scope, callback_url)
662
+ def authorize_with_service_account(email, scope, callback_url, state)
645
663
  if scope.respond_to?(:join)
646
664
  scope = scope.join(' ')
647
665
  end
@@ -649,7 +667,8 @@ module Cronofy
649
667
  params = {
650
668
  email: email,
651
669
  scope: scope,
652
- callback_url: callback_url
670
+ callback_url: callback_url,
671
+ state: state
653
672
  }
654
673
  post("/v1/service_account_authorizations", params)
655
674
  nil
@@ -668,7 +687,7 @@ module Cronofy
668
687
  # :state - Array of states to retain during the OAuth
669
688
  # authorization process (optional).
670
689
  #
671
- # See http://www.cronofy.com/developers/api#authorization for reference.
690
+ # See https://docs.cronofy.com/developers/api/authorization/request-authorization/ for reference.
672
691
  #
673
692
  # Returns the URL as a String.
674
693
  def user_auth_link(redirect_url, options = {})
@@ -683,7 +702,7 @@ module Cronofy
683
702
  # redirect_url - A String specifing the URL the user returned to once they
684
703
  # had completed the authorization steps.
685
704
  #
686
- # See http://www.cronofy.com/developers/api#token-issue for reference.
705
+ # See https://docs.cronofy.com/developers/api/authorization/request-token/ for reference.
687
706
  #
688
707
  # Returns a set of Cronofy::Credentials for the account.
689
708
  #
@@ -701,7 +720,7 @@ module Cronofy
701
720
  # these usually occur when the access token has expired and needs
702
721
  # refreshing.
703
722
  #
704
- # See http://www.cronofy.com/developers/api#token-refresh for reference.
723
+ # See https://docs.cronofy.com/developers/api/authorization/refresh-token/ for reference.
705
724
  #
706
725
  # Returns a set of Cronofy::Credentials for the account.
707
726
  #
@@ -716,7 +735,7 @@ module Cronofy
716
735
 
717
736
  # Public: Obtains access to an application calendar
718
737
  #
719
- # See http://www.cronofy.com/developers/alpha/api#application-calendar for reference.
738
+ # See https://docs.cronofy.com/developers/api/calendars/application-calendars/ for reference.
720
739
  #
721
740
  # Returns a set of Cronofy::Credentials for the account.
722
741
  #
@@ -734,7 +753,7 @@ module Cronofy
734
753
  # After making this call the Client will become unusable. You should also
735
754
  # delete the stored credentials used to create this instance.
736
755
  #
737
- # See http://www.cronofy.com/developers/api#revoke-authorization for
756
+ # See https://docs.cronofy.com/developers/api/authorization/revoke/ for
738
757
  # reference.
739
758
  #
740
759
  # Returns nothing.
@@ -816,8 +835,10 @@ module Cronofy
816
835
  # each must specify a start and end Time.
817
836
  # :start_interval - An Integer representing the start interval
818
837
  # of minutes for the availability query.
819
- # :buffer - An Hash containing the buffer to apply to
838
+ # :buffer - A Hash containing the buffer to apply to
820
839
  # the availability query.
840
+ # :query_slots - A Hash containing the query slots to be
841
+ # used in the availability query.
821
842
  #
822
843
  # Returns an Array of AvailablePeriods.
823
844
  #
@@ -842,7 +863,13 @@ module Cronofy
842
863
  options[:buffer] = map_availability_buffer(buffer)
843
864
  end
844
865
 
845
- translate_available_periods(options[:query_periods] || options[:available_periods])
866
+ if query_periods = options[:query_periods] || options[:available_periods]
867
+ translate_available_periods(query_periods)
868
+ end
869
+
870
+ if query_slots = options[:query_slots]
871
+ translate_query_slots(query_slots)
872
+ end
846
873
 
847
874
  response = availability_post("/v1/availability", options)
848
875
 
@@ -960,7 +987,7 @@ module Cronofy
960
987
  # long: "0.1234"
961
988
  # })
962
989
  #
963
- # See http://www.cronofy.com/developers/api#upsert-event for reference.
990
+ # See https://docs.cronofy.com/developers/api/events/upsert-event/ for reference.
964
991
  #
965
992
  # Returns a AddToCalendarResponse.
966
993
  #
@@ -1033,7 +1060,9 @@ module Cronofy
1033
1060
  # call
1034
1061
  # :required_duration - A hash stating the length of time the event will
1035
1062
  # last for
1036
- # :query_periods - A hash stating the available periods for the event
1063
+ # :query_periods - A Hash stating the available periods for the event
1064
+ # :query_slots - A Hash containing the query slots to be
1065
+ # used in the availability query.
1037
1066
  # :start_interval - An Integer representing the start interval
1038
1067
  # of minutes for the availability query.
1039
1068
  # :buffer - An Hash containing the buffer to apply to
@@ -1080,7 +1109,7 @@ module Cronofy
1080
1109
  # }]
1081
1110
  # )
1082
1111
  #
1083
- # See http://www.cronofy.com/developers/api#real-time-scheduling for reference.
1112
+ # See https://docs.cronofy.com/developers/api/scheduling/real-time-scheduling/ for reference.
1084
1113
  #
1085
1114
  # Returns a AddToCalendarResponse.
1086
1115
  #
@@ -1110,7 +1139,14 @@ module Cronofy
1110
1139
  end
1111
1140
  end
1112
1141
 
1113
- translate_available_periods(availability[:query_periods] || availability[:available_periods])
1142
+ if query_periods = availability[:query_periods] || availability[:available_periods]
1143
+ translate_available_periods(query_periods)
1144
+ end
1145
+
1146
+ if query_slots = availability[:query_slots]
1147
+ translate_query_slots(query_slots)
1148
+ end
1149
+
1114
1150
  body[:availability] = availability
1115
1151
 
1116
1152
  response = raw_post("/v1/real_time_scheduling", body)
@@ -1259,7 +1295,7 @@ module Cronofy
1259
1295
 
1260
1296
  # Public: Creates a link_token to allow explicitly linking of an account
1261
1297
  #
1262
- # See https://www.cronofy.com/developers/api/alpha/#auth-explicit-linking for
1298
+ # See https://docs.cronofy.com/developers/api-alpha/explicit-linking/ for
1263
1299
  # reference.
1264
1300
  #
1265
1301
  # Returns a link token
@@ -1276,7 +1312,7 @@ module Cronofy
1276
1312
 
1277
1313
  # Public: Revokes the authorization to the given profile.
1278
1314
  #
1279
- # See https://www.cronofy.com/developers/api/alpha/#revoke-profile for
1315
+ # See https://docs.cronofy.com/developers/api/authorization/revoke-profile/ for
1280
1316
  # reference.
1281
1317
  #
1282
1318
  # Returns nothing.
@@ -1354,7 +1390,7 @@ module Cronofy
1354
1390
  # }
1355
1391
  # )
1356
1392
  #
1357
- # See http://www.cronofy.com/developers/alpha/api#smart-invite for reference.
1393
+ # See https://docs.cronofy.com/developers/api/smart-invites/create-smart-invite/ for reference.
1358
1394
  #
1359
1395
  # Returns a SmartInviteResponse.
1360
1396
  #
@@ -1381,7 +1417,7 @@ module Cronofy
1381
1417
  # :email - A String for thee email address you are
1382
1418
  # going to send the Smart Invite to.
1383
1419
  #
1384
- # See http://www.cronofy.com/developers/alpha/api#smart-invite for reference.
1420
+ # See https://docs.cronofy.com/developers/api/smart-invites/cancel-invite/ for reference.
1385
1421
  #
1386
1422
  # Returns a SmartInviteResponse.
1387
1423
  #
@@ -1429,7 +1465,7 @@ module Cronofy
1429
1465
  # by Cronofy).
1430
1466
  # recipient_email - The email address for the recipient to get details for.
1431
1467
  #
1432
- # See http://www.cronofy.com/developers/alpha/api#smart-invite for reference.
1468
+ # See https://docs.cronofy.com/developers/api/smart-invites/invite-status/ for reference.
1433
1469
  #
1434
1470
  # Returns a SmartInviteResponse.
1435
1471
  #
@@ -1503,7 +1539,7 @@ module Cronofy
1503
1539
  # ]
1504
1540
  # )
1505
1541
  #
1506
- # See http://www.cronofy.com/developers/alpha/api#availability_rules for reference.
1542
+ # See https://docs.cronofy.com/developers/api/scheduling/availability-rules/ for reference.
1507
1543
  #
1508
1544
  # Returns an AvailabilityRuleResponse.
1509
1545
  #
@@ -1698,6 +1734,14 @@ module Cronofy
1698
1734
  end
1699
1735
  end
1700
1736
 
1737
+ def translate_query_slots(query_slots)
1738
+ query_slots.each do |params|
1739
+ QUERY_SLOTS_TIME_PARAMS.select { |tp| params.key?(tp) }.each do |tp|
1740
+ params[tp] = to_iso8601(params[tp])
1741
+ end
1742
+ end
1743
+ end
1744
+
1701
1745
  def map_availability_participants(participants)
1702
1746
  case participants
1703
1747
  when Hash
@@ -1828,6 +1872,10 @@ module Cronofy
1828
1872
  end
1829
1873
  }.freeze
1830
1874
 
1875
+ QUERY_SLOTS_TIME_PARAMS = %i{
1876
+ start
1877
+ }.freeze
1878
+
1831
1879
  FREE_BUSY_DEFAULT_PARAMS = { tzid: "Etc/UTC" }.freeze
1832
1880
  FREE_BUSY_TIME_PARAMS = %i{
1833
1881
  from
data/lib/cronofy/types.rb CHANGED
@@ -417,4 +417,7 @@ module Cronofy
417
417
  class RealTimeSchedulingStatus < CronofyMash
418
418
  coerce_key :event, Event
419
419
  end
420
+
421
+ class ConferencingServiceAuthorizationResponse < CronofyMash
422
+ end
420
423
  end
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.37.7".freeze
2
+ VERSION = "0.41.0".freeze
3
3
  end
@@ -658,14 +658,15 @@ describe Cronofy::Client do
658
658
  let(:request_url) { "https://api.cronofy.com/v1/service_account_authorizations" }
659
659
  let(:method) { :post }
660
660
  let(:request_headers) { json_request_headers }
661
- let(:request_body) { { email: email, scope: scope.join(' '), callback_url: callback_url } }
661
+ let(:request_body) { { email: email, scope: scope.join(' '), callback_url: callback_url, state: state } }
662
662
  let(:correct_response_code) { 202 }
663
663
  let(:correct_response_body) { nil }
664
664
  let(:email) { "foo@example.com" }
665
665
  let(:scope) { ['foo', 'bar'] }
666
- let(:callback_url) { "http://example.com/not_found" }
666
+ let(:callback_url) { "https://example.com/callback" }
667
+ let(:state) { 'state' }
667
668
 
668
- subject { client.authorize_with_service_account(email, scope, callback_url) }
669
+ subject { client.authorize_with_service_account(email, scope, callback_url, state) }
669
670
 
670
671
  it_behaves_like 'a Cronofy request'
671
672
  end
@@ -1782,6 +1783,51 @@ describe Cronofy::Client do
1782
1783
  it_behaves_like 'a Cronofy request with mapped return value'
1783
1784
  end
1784
1785
 
1786
+ context 'when given query_slots instead of available_periods with start interval' do
1787
+ let(:participants) do
1788
+ { members: %w{acc_567236000909002 acc_678347111010113} }
1789
+ end
1790
+
1791
+ let(:required_duration) { 60 }
1792
+
1793
+ let(:query_slots) do
1794
+ [
1795
+ { start: Time.parse("2017-01-03T09:00:00Z")},
1796
+ { start: Time.parse("2017-01-04T09:00:00Z") },
1797
+ ]
1798
+ end
1799
+
1800
+ let(:request_body) do
1801
+ {
1802
+ "participants" => [
1803
+ {
1804
+ "members" => [
1805
+ { "sub" => "acc_567236000909002" },
1806
+ { "sub" => "acc_678347111010113" }
1807
+ ],
1808
+ "required" => "all"
1809
+ }
1810
+ ],
1811
+ "query_slots" => [
1812
+ { "start" => "2017-01-03T09:00:00Z" },
1813
+ { "start" => "2017-01-04T09:00:00Z" }
1814
+ ],
1815
+ "required_duration" => { "minutes" => 60 },
1816
+ }
1817
+ end
1818
+
1819
+ subject do
1820
+ client.availability(
1821
+ participants: participants,
1822
+ required_duration: required_duration,
1823
+ query_slots: query_slots
1824
+ )
1825
+ end
1826
+
1827
+ it_behaves_like 'a Cronofy request'
1828
+ it_behaves_like 'a Cronofy request with mapped return value'
1829
+ end
1830
+
1785
1831
  context "when trying to auth with only an access_token, as originally implemented" do
1786
1832
  let(:access_token) { "access_token_123"}
1787
1833
  let(:client) { Cronofy::Client.new(access_token: access_token) }
@@ -2362,6 +2408,56 @@ describe Cronofy::Client do
2362
2408
  mapped_availability[:query_periods] = mapped_availability.delete(:available_periods)
2363
2409
  end
2364
2410
  end
2411
+
2412
+ context 'when passing query slots' do
2413
+ let(:availability) do
2414
+ {
2415
+ participants: [
2416
+ {
2417
+ members: [{
2418
+ sub: "acc_567236000909002",
2419
+ calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
2420
+ }],
2421
+ required: 'all'
2422
+ }
2423
+ ],
2424
+ required_duration: { minutes: 60 },
2425
+ query_slots: [
2426
+ { start: Time.utc(2017, 1, 1, 9, 00) },
2427
+ { start: Time.utc(2017, 1, 1, 17, 00) }
2428
+ ],
2429
+ buffer: {
2430
+ before: { minutes: 30 },
2431
+ after: { minutes: 45 },
2432
+ }
2433
+ }
2434
+ end
2435
+
2436
+ let(:mapped_availability) do
2437
+ {
2438
+ participants: [
2439
+ {
2440
+ members: [{
2441
+ sub: "acc_567236000909002",
2442
+ calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
2443
+ }],
2444
+ required: 'all'
2445
+ }
2446
+ ],
2447
+ required_duration: { minutes: 60 },
2448
+ buffer: {
2449
+ before: { minutes: 30 },
2450
+ after: { minutes: 45 },
2451
+ },
2452
+ query_slots: [
2453
+ { start: Time.utc(2017, 1, 1, 9, 00) },
2454
+ { start: Time.utc(2017, 1, 1, 17, 00) }
2455
+ ],
2456
+ }
2457
+ it_behaves_like 'a Cronofy request'
2458
+ it_behaves_like 'a Cronofy request with mapped return value'
2459
+ end
2460
+ end
2365
2461
  end
2366
2462
 
2367
2463
  describe "#get_real_time_scheduling_status" do
@@ -3709,4 +3805,31 @@ describe Cronofy::Client do
3709
3805
  it_behaves_like 'a Cronofy request'
3710
3806
  it_behaves_like 'a Cronofy request with mapped return value'
3711
3807
  end
3808
+
3809
+ describe 'Conferencing Services' do
3810
+ describe '#get_conferencing_service_authorizations' do
3811
+ let(:redirect_uri) { "http://example.com/not_found" }
3812
+ let(:request_url) { "https://api.cronofy.com/v1/conferencing_service_authorizations" }
3813
+ let(:method) { :post }
3814
+ let(:request_body) {
3815
+ { redirect_uri: redirect_uri }
3816
+ }
3817
+ let(:correct_response_code) { 200 }
3818
+ let(:correct_response_body) do
3819
+ {
3820
+ "authorization_request" => {
3821
+ "url": "https://app.cronofy.com/conferencing_services/foo"
3822
+ }
3823
+ }
3824
+ end
3825
+ let(:correct_mapped_result) do
3826
+ Cronofy::ConferencingServiceAuthorizationResponse.new(correct_response_body['authorization_request'])
3827
+ end
3828
+
3829
+ subject { client.get_conferencing_service_authorizations(redirect_uri) }
3830
+
3831
+ it_behaves_like 'a Cronofy request'
3832
+ it_behaves_like 'a Cronofy request with mapped return value'
3833
+ end
3834
+ end
3712
3835
  end
data/spec/spec_helper.rb CHANGED
@@ -2,3 +2,4 @@ require 'ostruct'
2
2
  require 'cronofy'
3
3
 
4
4
  require 'webmock/rspec'
5
+ require 'securerandom'
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.37.7
4
+ version: 0.41.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: 2022-05-27 00:00:00.000000000 Z
12
+ date: 2023-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie
@@ -35,16 +35,16 @@ dependencies:
35
35
  name: oauth2
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: 2.0.4
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: 2.0.4
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -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.3.11
160
- signing_key:
159
+ rubygems_version: 3.2.33
160
+ signing_key:
161
161
  specification_version: 4
162
162
  summary: Cronofy - the scheduling platform for business
163
163
  test_files: