cronofy 0.8.0 → 0.8.1

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
  SHA1:
3
- metadata.gz: 116368dec8928956ee2044c6aaac191fc0ad42b0
4
- data.tar.gz: 3f7525985969bd9442ef05d7997f88b10060acea
3
+ metadata.gz: 3467ae0391c9af2279187f55e7077710c716a62f
4
+ data.tar.gz: 5aba29d7e88b690d15ed3ddf529c8207af567606
5
5
  SHA512:
6
- metadata.gz: 84d9b8f66d11577350ecf293c00dd0bd69dd5827595625d410b0709937872ce7c52019eafc5693998dd3d03dcb3bbfe8626d9c8f0f4bc04cc5a0a40106c8bfa0
7
- data.tar.gz: cb35302981dae646f87f0ce47aa297a295a3fad4a913b15a1a49592edd9b010042288671f42a9ad7468cb0761f7b3a1adbe298434cee8cc2a801af3f0817a968
6
+ metadata.gz: af83971d843ba0ebd4a8043e9f93ab551442b580a45ae1969be56ff4294b680fb2252500503acd2d1c46b34206624c5bb07cfaa291700d0ea422978c2a7565e4
7
+ data.tar.gz: 1f105236fdd6898bb246bf080265d352dcdedc94d96b65fb48d96b891405a2bddf1a8197e0ad320d9c71f4622c1ec4e6d4b44789c315c8abdde6a805dd8bde42
data/lib/cronofy/types.rb CHANGED
@@ -4,7 +4,33 @@ require "time"
4
4
 
5
5
  module Cronofy
6
6
  class Credentials
7
- class LinkingProfile < Hashie::Mash
7
+ class LinkingProfile
8
+ attr_reader :provider_name
9
+ attr_reader :profile_id
10
+ attr_reader :profile_name
11
+
12
+ def initialize(hash)
13
+ @provider_name = hash['provider_name'] || hash[:provider_name]
14
+ @profile_id = hash['profile_id'] || hash[:profile_id]
15
+ @profile_name = hash['profile_name'] || hash[:profile_name]
16
+ end
17
+
18
+ def to_h
19
+ {
20
+ provider_name: provider_name,
21
+ profile_id: profile_id,
22
+ profile_name: profile_name,
23
+ }
24
+ end
25
+
26
+ def ==(other)
27
+ case other
28
+ when LinkingProfile
29
+ self.provider_name == other.provider_name &&
30
+ self.profile_id == other.profile_id &&
31
+ self.profile_name == other.profile_name
32
+ end
33
+ end
8
34
  end
9
35
 
10
36
  attr_reader :access_token
@@ -29,13 +55,23 @@ module Cronofy
29
55
  end
30
56
 
31
57
  def to_h
32
- {
58
+ hash = {
33
59
  access_token: access_token,
34
60
  expires_at: expires_at,
35
61
  expires_in: expires_in,
36
62
  refresh_token: refresh_token,
37
63
  scope: scope,
38
64
  }
65
+
66
+ if account_id
67
+ hash[:account_id] = account_id
68
+ end
69
+
70
+ if linking_profile
71
+ hash[:linking_profile] = linking_profile.to_h
72
+ end
73
+
74
+ hash
39
75
  end
40
76
 
41
77
  def to_hash
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.8.0".freeze
2
+ VERSION = "0.8.1".freeze
3
3
  end
@@ -189,6 +189,19 @@ describe Cronofy::Auth do
189
189
  it 'exposes the account_id' do
190
190
  expect(subject.account_id).to eq account_id
191
191
  end
192
+
193
+ it "includes the account_id in its hash" do
194
+ expected = {
195
+ :access_token => subject.access_token,
196
+ :expires_at => subject.expires_at,
197
+ :expires_in => subject.expires_in,
198
+ :refresh_token => subject.refresh_token,
199
+ :scope => subject.scope,
200
+ :account_id => account_id,
201
+ }
202
+
203
+ expect(subject.to_h).to eq(expected)
204
+ end
192
205
  end
193
206
 
194
207
  context "with linking profile" do
@@ -204,6 +217,19 @@ describe Cronofy::Auth do
204
217
  expected = Cronofy::Credentials::LinkingProfile.new(linking_profile_hash)
205
218
  expect(subject.linking_profile).to eq expected
206
219
  end
220
+
221
+ it "includes the linking profile in its hash" do
222
+ expected = {
223
+ :access_token => subject.access_token,
224
+ :expires_at => subject.expires_at,
225
+ :expires_in => subject.expires_in,
226
+ :refresh_token => subject.refresh_token,
227
+ :scope => subject.scope,
228
+ :linking_profile => linking_profile_hash,
229
+ }
230
+
231
+ expect(subject.to_h).to eq(expected)
232
+ end
207
233
  end
208
234
 
209
235
  it_behaves_like 'an authorization request'
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.8.0
4
+ version: 0.8.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: 2015-12-31 00:00:00.000000000 Z
12
+ date: 2016-01-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2