cronofy 0.26.1 → 0.27.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: f0dd00c2dd16b92ad0a313095376dedd6f494fcf
4
- data.tar.gz: c47a49f17ddbc639850ab6604403c754e2795e3d
3
+ metadata.gz: c4e2e097925e5ee3b1dce3ec0ac5dd539df7640b
4
+ data.tar.gz: 91614467858b2955a9658a23beb6c0cd9de44712
5
5
  SHA512:
6
- metadata.gz: c93e212ce2c24ad2959399bff8cba89b9cbc8806dfd13800919a7df58fff1a6bd9dde6a0c9f9113d43b6a8622d6f948a2002780d101124e9681f8588fc606612
7
- data.tar.gz: 517d264a9b1aca9aff01dfb9a57fdb3a48a7088eaca924caacc9e95d68ff999d68678711f7fe5dfe8f028581598b5a5284a349e3e0d364086ef606035ab00843
6
+ metadata.gz: 893a65940415df45c8e5b7c6c49c0cda2ae3302196078c20b420a29166a2a060704192b8ffbfe5926e2de9c1aafd089a698304548a09181c46124c874ea5ec74
7
+ data.tar.gz: bcfa6bbf8bfc19c637f206a29b37eedb38c3320cb7316a7878e7a0defc60891995601a9600c46a04a126d05d666a3177fbc1b834cea8151edfd6de3001bb2dc7
@@ -1,4 +1,8 @@
1
- ## [0.27.1]
1
+ ## [0.27.0]
2
+
3
+ * Added support for Application Calendars [#57]
4
+
5
+ ## [0.26.1]
2
6
 
3
7
  * Prevent error when disable\_warnings not available [#56]
4
8
 
@@ -101,6 +105,7 @@
101
105
  [0.25.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.25.1
102
106
  [0.26.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.26.0
103
107
  [0.26.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.26.1
108
+ [0.27.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.27.0
104
109
 
105
110
  [#13]: https://github.com/cronofy/cronofy-ruby/pull/13
106
111
  [#16]: https://github.com/cronofy/cronofy-ruby/pull/16
@@ -128,3 +133,4 @@
128
133
  [#53]: https://github.com/cronofy/cronofy-ruby/pull/53
129
134
  [#55]: https://github.com/cronofy/cronofy-ruby/pull/55
130
135
  [#56]: https://github.com/cronofy/cronofy-ruby/pull/56
136
+ [#57]: https://github.com/cronofy/cronofy-ruby/pull/57
@@ -75,6 +75,28 @@ module Cronofy
75
75
  end
76
76
  end
77
77
 
78
+ # Internal: Obtains access to an application calendar
79
+ #
80
+ # application_calendar_id - A String to identify the application calendar
81
+ # which is to be accessed.
82
+ #
83
+ # Returns Hash of token elements to allow client to update in local store
84
+ # for user
85
+ #
86
+ # Raises Cronofy::CredentialsMissingError if no credentials available.
87
+ def application_calendar(application_calendar_id)
88
+ do_request do
89
+ body = {
90
+ client_id: @api_client.id,
91
+ client_secret: @api_client.secret,
92
+ application_calendar_id: application_calendar_id,
93
+ }
94
+
95
+ @response = @api_client.request(:post, "/v1/application_calendars", body: body)
96
+ Credentials.new(OAuth2::AccessToken.from_hash(@api_client, @response.parsed))
97
+ end
98
+ end
99
+
78
100
  def set_access_token_from_auth_token(auth_token)
79
101
  set_access_token(auth_token.token, auth_token.refresh_token)
80
102
  end
@@ -703,6 +703,21 @@ module Cronofy
703
703
  @auth.refresh!
704
704
  end
705
705
 
706
+ # Public: Obtains access to an application calendar
707
+ #
708
+ # See http://www.cronofy.com/developers/alpha/api#application-calendar for reference.
709
+ #
710
+ # Returns a set of Cronofy::Credentials for the account.
711
+ #
712
+ # Raises Cronofy::BadRequestError if refresh token code is unknown or has
713
+ # been revoked.
714
+ # Raises Cronofy::AuthenticationFailureError if the client ID and secret are
715
+ # not valid.
716
+ # Raises Cronofy::CredentialsMissingError if no credentials available.
717
+ def application_calendar(application_calendar_id)
718
+ @auth.application_calendar(application_calendar_id)
719
+ end
720
+
706
721
  # Public: Revokes the account's refresh token and access token.
707
722
  #
708
723
  # After making this call the Client will become unusable. You should also
@@ -35,6 +35,7 @@ module Cronofy
35
35
 
36
36
  attr_reader :access_token
37
37
  attr_reader :account_id
38
+ attr_reader :application_calendar_id
38
39
  attr_reader :expires_at
39
40
  attr_reader :expires_in
40
41
  attr_reader :linking_profile
@@ -44,6 +45,7 @@ module Cronofy
44
45
  def initialize(oauth_token)
45
46
  @access_token = oauth_token.token
46
47
  @account_id = oauth_token.params['account_id']
48
+ @application_calendar_id = oauth_token.params['application_calendar_id']
47
49
  @expires_at = oauth_token.expires_at
48
50
  @expires_in = oauth_token.expires_in
49
51
  @refresh_token = oauth_token.refresh_token
@@ -67,6 +69,11 @@ module Cronofy
67
69
  hash[:account_id] = account_id
68
70
  end
69
71
 
72
+ if application_calendar_id
73
+ hash[:application_calendar_id] = application_calendar_id
74
+ end
75
+
76
+
70
77
  if linking_profile
71
78
  hash[:linking_profile] = linking_profile.to_h
72
79
  end
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.26.1".freeze
2
+ VERSION = "0.27.0".freeze
3
3
  end
@@ -235,6 +235,49 @@ describe Cronofy::Auth do
235
235
  end
236
236
  end
237
237
 
238
+ describe '#application_calendar' do
239
+ let(:data_centre_override) { nil }
240
+
241
+ let(:application_calendar_id) { "apc_54475485743" }
242
+
243
+ let(:application_calendar_url) { "https://api.cronofy.com/v1/application_calendars" }
244
+
245
+ before do
246
+ stub_request(:post, application_calendar_url)
247
+ .with(
248
+ body: {
249
+ client_id: client_id,
250
+ client_secret: client_secret,
251
+ application_calendar_id: application_calendar_id,
252
+ },
253
+ )
254
+ .to_return(
255
+ status: response_status,
256
+ body: {
257
+ access_token: new_access_token,
258
+ token_type: 'bearer',
259
+ expires_in: expires_in,
260
+ refresh_token: new_refresh_token,
261
+ scope: scope,
262
+ application_calendar_id: application_calendar_id,
263
+ }.to_json,
264
+ headers: {
265
+ "Content-Type" => "application/json; charset=utf-8"
266
+ }
267
+ )
268
+ end
269
+
270
+ subject do
271
+ Cronofy::Auth.new(
272
+ client_id: client_id,
273
+ client_secret: client_secret,
274
+ data_centre: data_centre_override,
275
+ ).application_calendar(application_calendar_id)
276
+ end
277
+
278
+ it_behaves_like 'an authorization request'
279
+ end
280
+
238
281
  context "with linking profile" do
239
282
  let(:linking_profile_hash) do
240
283
  {
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.26.1
4
+ version: 0.27.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-12-13 00:00:00.000000000 Z
12
+ date: 2018-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2
@@ -151,15 +151,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.6.6
154
+ rubygems_version: 2.6.12
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Cronofy - one API for all the calendars
158
158
  test_files:
159
- - spec/lib/cronofy/auth_spec.rb
159
+ - spec/spec_helper.rb
160
+ - spec/response_parser_spec.rb
160
161
  - spec/lib/cronofy/client_spec.rb
161
- - spec/lib/cronofy/date_or_time_spec.rb
162
- - spec/lib/cronofy/errors_spec.rb
163
162
  - spec/lib/cronofy/event_spec.rb
164
- - spec/response_parser_spec.rb
165
- - spec/spec_helper.rb
163
+ - spec/lib/cronofy/errors_spec.rb
164
+ - spec/lib/cronofy/date_or_time_spec.rb
165
+ - spec/lib/cronofy/auth_spec.rb