cronofy 0.37.0 → 0.37.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 308d390e34e9ed071119e343cc32f18121ddcff2328fbc945b3a785e64550676
4
- data.tar.gz: 2ab98066dd1c8eeef0d44a4ddef32f49945edd2d4b84c16d7f5607bbbb54220a
3
+ metadata.gz: a805a11bb064f04901d8cb57e9941bb71db91224c3c61f351b827c75074d1db5
4
+ data.tar.gz: ec146b1c4c31ced2d208bca1f066b15a4b162edacaac0bc0f7cf1da079f0d1d2
5
5
  SHA512:
6
- metadata.gz: c61c10c546d52fee5d4af2ed2030f33a477d0b79cce98c89eb977e76cb9a1918250a00cf4fa1d74b2a35eb044da6ba338f504d6427b07173386c542dae48af97
7
- data.tar.gz: 844a546be5ef240ebb964e72926363eedf023bc05ce05bfa95e5af7b1adc8bfbef18a53b1415cec348b370367ec322e5513b7330622753b29b350c1ec046fa67
6
+ metadata.gz: 38b1b55c2f736c9692c0e11ebd03d803709e485b7d51ce2522c0a32b2333b75faa2ca56658315f9390b44b7f6a0a1b3b2abfdeca98f22a94d8e4dddf6cada60c
7
+ data.tar.gz: 22645a8c38f429465ec6bcbacc2f8a9463a1895597d68b21f853a4c57c2630cb4db0adcbd1204d9a2187a33e598df0de9c94e20dd63794b9e807b621648df110
@@ -1,3 +1,7 @@
1
+ ## [0.37.1]
2
+
3
+ * Rename `data_centre` to `data_centre` (with aliases for backwards compatibility) [#90]
4
+
1
5
  ## [0.37.0]
2
6
 
3
7
  * Add `revoke_by_token` and `revoke_by_sub` to the Client [#86]
@@ -177,6 +181,7 @@
177
181
  [0.36.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.0
178
182
  [0.36.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.1
179
183
  [0.37.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.0
184
+ [0.37.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.1
180
185
 
181
186
  [#13]: https://github.com/cronofy/cronofy-ruby/pull/13
182
187
  [#16]: https://github.com/cronofy/cronofy-ruby/pull/16
@@ -219,3 +224,4 @@
219
224
  [#81]: https://github.com/cronofy/cronofy-ruby/pull/81
220
225
  [#85]: https://github.com/cronofy/cronofy-ruby/pull/85
221
226
  [#86]: https://github.com/cronofy/cronofy-ruby/pull/86
227
+ [#90]: https://github.com/cronofy/cronofy-ruby/pull/90
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/cronofy/cronofy-ruby.svg?branch=master)](https://travis-ci.org/cronofy/cronofy-ruby)
4
4
  [![Gem Version](https://badge.fury.io/rb/cronofy.svg)](http://badge.fury.io/rb/cronofy)
5
5
 
6
- [Cronofy](https://www.cronofy.com) - one API for all the calendars (Google, iCloud, Exchange, Office 365, Outlook.com)
6
+ [Cronofy](https://www.cronofy.com) - the scheduling platform for business
7
7
 
8
8
  ## Installation
9
9
 
@@ -29,14 +29,15 @@ to obtain an OAuth `client_id` and `client_secret` to be able to use the full AP
29
29
  ## Creating a client
30
30
 
31
31
  To make calls to the Cronofy API you must create a `Cronofy::Client`. This takes
32
- four keyword arguments, all of which are optional:
32
+ five keyword arguments, all of which are optional:
33
33
 
34
34
  ```ruby
35
35
  cronofy = Cronofy::Client.new(
36
36
  client_id: 'CLIENT_ID',
37
37
  client_secret: 'CLIENT_SECRET',
38
38
  access_token: 'ACCESS_TOKEN',
39
- refresh_token: 'REFRESH_TOKEN'
39
+ refresh_token: 'REFRESH_TOKEN',
40
+ data_center: :de
40
41
  )
41
42
  ```
42
43
 
@@ -51,6 +52,8 @@ If `client_id` and `client_secret` are not specified explicitly the values from
51
52
  the environment variables `CRONOFY_CLIENT_ID` and `CRONOFY_CLIENT_SECRET` will
52
53
  be used if present.
53
54
 
55
+ `data_center` is the two-letter designation for the data center you want to operate against - for example `:de` for Germany, or `:au` for Australia. When omitted, this defaults to the US data center.
56
+
54
57
  ## Authorization
55
58
 
56
59
  [API documentation](https://www.cronofy.com/developers/api/#authorization)
@@ -5,7 +5,7 @@ Gem::Specification.new do |spec|
5
5
  spec.version = Cronofy::VERSION
6
6
  spec.authors = ["Sergii Paryzhskyi", "Garry Shutler"]
7
7
  spec.email = ["parizhskiy@gmail.com", "garry@cronofy.com"]
8
- spec.summary = %q{Cronofy - one API for all the calendars}
8
+ spec.summary = %q{Cronofy - the scheduling platform for business}
9
9
  spec.description = %q{Ruby wrapper for Cronofy's unified calendar API}
10
10
  spec.homepage = "https://github.com/cronofy/cronofy-ruby"
11
11
  spec.license = "MIT"
@@ -13,18 +13,26 @@ require 'openssl'
13
13
 
14
14
  module Cronofy
15
15
  def self.default_data_centre
16
- @default_data_centre || ENV['CRONOFY_DATA_CENTRE']
16
+ default_data_center
17
17
  end
18
18
 
19
19
  def self.default_data_centre=(value)
20
- @default_data_centre = value
20
+ default_data_center= value
21
21
  end
22
22
 
23
- def self.api_url(data_centre_override)
24
- if data_centre_override
25
- api_url_for_data_centre(data_centre_override)
23
+ def self.default_data_center
24
+ @default_data_center || ENV['CRONOFY_DATA_CENTER'] || ENV['CRONOFY_DATA_CENTRE']
25
+ end
26
+
27
+ def self.default_data_center=(value)
28
+ @default_data_center = value
29
+ end
30
+
31
+ def self.api_url(data_center_override)
32
+ if data_center_override
33
+ api_url_for_data_center(data_center_override)
26
34
  else
27
- ENV['CRONOFY_API_URL'] || api_url_for_data_centre(default_data_centre)
35
+ ENV['CRONOFY_API_URL'] || api_url_for_data_center(default_data_center)
28
36
  end
29
37
  end
30
38
 
@@ -32,7 +40,11 @@ module Cronofy
32
40
  @api_url = value
33
41
  end
34
42
 
35
- def self.api_url_for_data_centre(dc)
43
+ def self.api_url_for_data_centre
44
+ api_url_for_data_center
45
+ end
46
+
47
+ def self.api_url_for_data_center(dc)
36
48
  @api_urls ||= Hash.new do |hash, key|
37
49
  if key.nil? || key.to_sym == :us
38
50
  url = "https://api.cronofy.com"
@@ -46,11 +58,11 @@ module Cronofy
46
58
  @api_urls[dc]
47
59
  end
48
60
 
49
- def self.app_url(data_centre_override)
50
- if data_centre_override
51
- app_url_for_data_centre(data_centre_override)
61
+ def self.app_url(data_center_override)
62
+ if data_center_override
63
+ app_url_for_data_center(data_center_override)
52
64
  else
53
- ENV['CRONOFY_APP_URL'] || app_url_for_data_centre(default_data_centre)
65
+ ENV['CRONOFY_APP_URL'] || app_url_for_data_center(default_data_center)
54
66
  end
55
67
  end
56
68
 
@@ -59,6 +71,10 @@ module Cronofy
59
71
  end
60
72
 
61
73
  def self.app_url_for_data_centre(dc)
74
+ app_url_for_data_center(dc)
75
+ end
76
+
77
+ def self.app_url_for_data_center(dc)
62
78
  @app_urls ||= Hash.new do |hash, key|
63
79
  if key.nil? || key.to_sym == :us
64
80
  url = "https://app.cronofy.com"
@@ -11,13 +11,13 @@ module Cronofy
11
11
  access_token = options[:access_token]
12
12
  client_id = options[:client_id]
13
13
  client_secret = options[:client_secret]
14
- data_centre = options[:data_centre]
14
+ data_center = options[:data_center]
15
15
  refresh_token = options[:refresh_token]
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_centre), connection_opts: { headers: { "User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}" } })
20
- @api_client = OAuth2::Client.new(client_id, client_secret, site: ::Cronofy.api_url(data_centre), 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), 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}" } })
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
@@ -27,22 +27,22 @@ module Cronofy
27
27
  # ENV["CRONOFY_CLIENT_SECRET"]).
28
28
  # :refresh_token - An existing refresh token String for the user's
29
29
  # account (optional).
30
- # :data_centre - An identifier to override the default data
31
- # centre (optional).
30
+ # :data_center - An identifier to override the default data
31
+ # center (optional).
32
32
  def initialize(options = {})
33
33
  access_token = options[:access_token]
34
34
  refresh_token = options[:refresh_token]
35
35
 
36
36
  @client_id = options.fetch(:client_id, ENV["CRONOFY_CLIENT_ID"])
37
37
  @client_secret = options.fetch(:client_secret, ENV["CRONOFY_CLIENT_SECRET"])
38
- @data_centre = options[:data_centre]
38
+ @data_center = options[:data_center] || options[:data_centre]
39
39
 
40
40
  @auth = Auth.new(
41
41
  client_id: @client_id,
42
42
  client_secret: @client_secret,
43
43
  access_token: access_token,
44
44
  refresh_token: refresh_token,
45
- data_centre: @data_centre,
45
+ data_center: @data_center
46
46
  )
47
47
  end
48
48
 
@@ -1889,7 +1889,7 @@ module Cronofy
1889
1889
  end
1890
1890
 
1891
1891
  def api_url
1892
- ::Cronofy.api_url(@data_centre)
1892
+ ::Cronofy.api_url(@data_center)
1893
1893
  end
1894
1894
  end
1895
1895
 
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.37.0".freeze
2
+ VERSION = "0.37.1".freeze
3
3
  end
@@ -92,7 +92,7 @@ describe Cronofy::Auth do
92
92
  let(:scheme) { 'https' }
93
93
  let(:host) { 'app.cronofy.com' }
94
94
  let(:path) { '/oauth/authorize' }
95
- let(:data_centre_override) { nil }
95
+ let(:data_center_override) { nil }
96
96
  let(:default_params) do
97
97
  {
98
98
  'client_id' => client_id,
@@ -106,7 +106,7 @@ describe Cronofy::Auth do
106
106
  Cronofy::Auth.new(
107
107
  client_id: client_id,
108
108
  client_secret: client_secret,
109
- data_centre: data_centre_override,
109
+ data_center: data_center_override,
110
110
  )
111
111
  end
112
112
 
@@ -156,8 +156,8 @@ describe Cronofy::Auth do
156
156
  it_behaves_like 'a user auth link provider'
157
157
  end
158
158
 
159
- context 'when data centre overridden' do
160
- let(:data_centre_override) { :de }
159
+ context 'when data center overridden' do
160
+ let(:data_center_override) { :de }
161
161
  let(:host) { 'app-de.cronofy.com' }
162
162
  let(:params) { default_params }
163
163
 
@@ -204,13 +204,13 @@ describe Cronofy::Auth do
204
204
  end
205
205
 
206
206
  describe '#get_token_from_code' do
207
- let(:data_centre_override) { nil }
207
+ let(:data_center_override) { nil }
208
208
 
209
209
  subject do
210
210
  Cronofy::Auth.new(
211
211
  client_id: client_id,
212
212
  client_secret: client_secret,
213
- data_centre: data_centre_override,
213
+ data_center: data_center_override,
214
214
  ).get_token_from_code(code, redirect_uri)
215
215
  end
216
216
 
@@ -236,7 +236,7 @@ describe Cronofy::Auth do
236
236
  end
237
237
 
238
238
  describe '#application_calendar' do
239
- let(:data_centre_override) { nil }
239
+ let(:data_center_override) { nil }
240
240
 
241
241
  let(:application_calendar_id) { "my-application-calendar" }
242
242
  let(:cronofy_application_calendar_id) { "apc_54475485743" }
@@ -273,7 +273,7 @@ describe Cronofy::Auth do
273
273
  Cronofy::Auth.new(
274
274
  client_id: client_id,
275
275
  client_secret: client_secret,
276
- data_centre: data_centre_override,
276
+ data_center: data_center_override,
277
277
  ).application_calendar(application_calendar_id)
278
278
  end
279
279
 
@@ -308,8 +308,8 @@ describe Cronofy::Auth do
308
308
  end
309
309
  end
310
310
 
311
- context "with data centre overridden" do
312
- let(:data_centre_override) { :de }
311
+ context "with data center overridden" do
312
+ let(:data_center_override) { :de }
313
313
  let(:api_token_url) { "https://api-de.cronofy.com/oauth/token" }
314
314
  let(:app_token_url) { "https://app-de.cronofy.com/oauth/token" }
315
315
 
@@ -372,14 +372,14 @@ describe Cronofy::Auth do
372
372
  it_behaves_like 'an authorization request'
373
373
  end
374
374
 
375
- context "with data centre overridden" do
375
+ context "with data center overridden" do
376
376
  subject do
377
377
  Cronofy::Auth.new(
378
378
  client_id: client_id,
379
379
  client_secret: client_secret,
380
380
  access_token: access_token,
381
381
  refresh_token: refresh_token,
382
- data_centre: :de,
382
+ data_center: :de,
383
383
  ).refresh!
384
384
  end
385
385
 
@@ -2325,8 +2325,8 @@ describe Cronofy::Client do
2325
2325
 
2326
2326
  end
2327
2327
 
2328
- describe "Specified data centre" do
2329
- let(:data_centre) { :de }
2328
+ describe "specifying data_centre" do
2329
+ let(:data_center) { :de }
2330
2330
 
2331
2331
  let(:client) do
2332
2332
  Cronofy::Client.new(
@@ -2334,12 +2334,52 @@ describe Cronofy::Client do
2334
2334
  client_secret: 'client_secret_456',
2335
2335
  access_token: token,
2336
2336
  refresh_token: 'refresh_token_456',
2337
- data_centre: data_centre,
2337
+ data_centre: data_center,
2338
2338
  )
2339
2339
  end
2340
2340
 
2341
2341
  describe "Userinfo" do
2342
- let(:request_url) { "https://api-#{data_centre}.cronofy.com/v1/userinfo" }
2342
+ let(:request_url) { "https://api-#{data_center}.cronofy.com/v1/userinfo" }
2343
+
2344
+ describe "#userinfo" do
2345
+ let(:method) { :get }
2346
+
2347
+ let(:correct_response_code) { 200 }
2348
+ let(:correct_response_body) do
2349
+ {
2350
+ "sub" => "ser_5700a00eb0ccd07000000000",
2351
+ "cronofy.type" => "service_account",
2352
+ "cronofy.service_account.domain" => "example.com"
2353
+ }
2354
+ end
2355
+
2356
+ let(:correct_mapped_result) do
2357
+ Cronofy::UserInfo.new(correct_response_body)
2358
+ end
2359
+
2360
+ subject { client.userinfo }
2361
+
2362
+ it_behaves_like "a Cronofy request"
2363
+ it_behaves_like "a Cronofy request with mapped return value"
2364
+ end
2365
+ end
2366
+ end
2367
+
2368
+ describe "specifying data_center" do
2369
+ let(:data_center) { :au }
2370
+
2371
+ let(:client) do
2372
+ Cronofy::Client.new(
2373
+ client_id: 'client_id_123',
2374
+ client_secret: 'client_secret_456',
2375
+ access_token: token,
2376
+ refresh_token: 'refresh_token_456',
2377
+ data_center: data_center,
2378
+ )
2379
+ end
2380
+
2381
+ describe "Userinfo" do
2382
+ let(:request_url) { "https://api-#{data_center}.cronofy.com/v1/userinfo" }
2343
2383
 
2344
2384
  describe "#userinfo" do
2345
2385
  let(:method) { :get }
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.37.0
4
+ version: 0.37.1
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: 2021-01-12 00:00:00.000000000 Z
12
+ date: 2021-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie
@@ -159,7 +159,7 @@ requirements: []
159
159
  rubygems_version: 3.2.4
160
160
  signing_key:
161
161
  specification_version: 4
162
- summary: Cronofy - one API for all the calendars
162
+ summary: Cronofy - the scheduling platform for business
163
163
  test_files:
164
164
  - spec/spec_helper.rb
165
165
  - spec/response_parser_spec.rb