cronofy 0.37.7 → 0.40.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: 0407eb888cfab38dd60d84ad456d367da62d5021947bc9d7ccc1d66e8da8e3df
4
+ data.tar.gz: 24b3171b4e992004138871f4f30f92e840b22a6ef76bab5c7ec4f59574794ac1
5
5
  SHA512:
6
- metadata.gz: c00a81c85732364c3b6cc384c9bbdc1f10fbacfa756c09959734abbefbe65f58f9de764a8e019f40ba0ec17f4355fb4900c4a457e0cac2d98a0a8dfc653886fd
7
- data.tar.gz: 6529d3936e84d1721b458bfdfd2acb91585ba7b425d49c7b839f2cdce621d7ae1ba9d1896c471aaecdc6e16474c6f7b0002aa09a64b1390684e5601fa64f35c7
6
+ metadata.gz: e3e3d97475b91569ff5247604a4cdfc0b975d6a9aa1199e20b2e86e85d3b5e3060bfe193d12fe694a27432f79dba2d417580a25e46de3129cf7bd83d8c621f9d
7
+ data.tar.gz: db4b9e733ae6acee75880ff0fe72e5e6d42713d9c725d8211552647d1c2ec421628b5211222d2f3070ecbce2e6bd0682c1b74dfd2186c6f9d40a7996e9a4dc18
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.40.0]
2
+
3
+ * Update version of [OAuth2](https://rubygems.org/gems/oauth2) required [#102]
4
+
5
+ ## [0.39.0]
6
+
7
+ * Add conferencing services authorization
8
+
9
+ ## [0.38.0]
10
+
11
+ * Add state parameter to Service Account authorizations [#104]
12
+
1
13
  ## [0.37.7]
2
14
 
3
15
  * Update Gem description
@@ -212,6 +224,9 @@
212
224
  [0.37.5]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.5
213
225
  [0.37.6]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.6
214
226
  [0.37.7]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.7
227
+ [0.38.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/0.38.0
228
+ [0.39.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/0.39.0
229
+ [0.40.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.40.0
215
230
 
216
231
  [#13]: https://github.com/cronofy/cronofy-ruby/pull/13
217
232
  [#16]: https://github.com/cronofy/cronofy-ruby/pull/16
@@ -260,3 +275,6 @@
260
275
  [#97]: https://github.com/cronofy/cronofy-ruby/pull/97
261
276
  [#99]: https://github.com/cronofy/cronofy-ruby/pull/99
262
277
  [#100]: https://github.com/cronofy/cronofy-ruby/pull/100
278
+ [#102]: https://github.com/cronofy/cronofy-ruby/pull/102
279
+ [#104]: https://github.com/cronofy/cronofy-ruby/pull/104
280
+ [#108]: https://github.com/cronofy/cronofy-ruby/pull/108
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
@@ -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
 
@@ -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
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.40.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
@@ -3709,4 +3710,31 @@ describe Cronofy::Client do
3709
3710
  it_behaves_like 'a Cronofy request'
3710
3711
  it_behaves_like 'a Cronofy request with mapped return value'
3711
3712
  end
3713
+
3714
+ describe 'Conferencing Services' do
3715
+ describe '#get_conferencing_service_authorizations' do
3716
+ let(:redirect_uri) { "http://example.com/not_found" }
3717
+ let(:request_url) { "https://api.cronofy.com/v1/conferencing_service_authorizations" }
3718
+ let(:method) { :post }
3719
+ let(:request_body) {
3720
+ { redirect_uri: redirect_uri }
3721
+ }
3722
+ let(:correct_response_code) { 200 }
3723
+ let(:correct_response_body) do
3724
+ {
3725
+ "authorization_request" => {
3726
+ "url": "https://app.cronofy.com/conferencing_services/foo"
3727
+ }
3728
+ }
3729
+ end
3730
+ let(:correct_mapped_result) do
3731
+ Cronofy::ConferencingServiceAuthorizationResponse.new(correct_response_body['authorization_request'])
3732
+ end
3733
+
3734
+ subject { client.get_conferencing_service_authorizations(redirect_uri) }
3735
+
3736
+ it_behaves_like 'a Cronofy request'
3737
+ it_behaves_like 'a Cronofy request with mapped return value'
3738
+ end
3739
+ end
3712
3740
  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.40.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-05-19 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.1.4
160
+ signing_key:
161
161
  specification_version: 4
162
162
  summary: Cronofy - the scheduling platform for business
163
163
  test_files: