synapse_client 0.1.2 → 0.1.3
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 +4 -4
- data/lib/synapse_client/customer.rb +12 -30
- data/lib/synapse_client/refreshed_tokens.rb +10 -10
- data/lib/synapse_client/version.rb +1 -1
- data/spec/synapse_client_customer_spec.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c46836e82f8fd5cadaf0f92f1f63a3d1ea1e8aef
|
4
|
+
data.tar.gz: 0ecf16d300d068f81a8492e14c37b20d87424a9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0b24502cc145f806e2a2aab43df57154f6dd7de6f7153c594764b64af6bf994485495d1a0ac0543aa50e951150da6499667d22ca8d57bcc539795ed8df636ea
|
7
|
+
data.tar.gz: 555c437e3273c0c4a0a0ab2f192c80079a2e1a4a15a6791e8ce587edd1ee5f0999581a2f7ad9681e2187c6bae0192a725cf9711f8d750345e30591c97edab2fc
|
@@ -99,38 +99,20 @@ module SynapseClient
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
:bank => options[:bank_name],
|
108
|
-
:password => options[:password],
|
109
|
-
:pin => options[:pin] || "1234",
|
110
|
-
:username => options[:username]
|
111
|
-
}
|
112
|
-
|
113
|
-
request = SynapseClient::Request.new("/api/v2/bank/login/", data, client)
|
114
|
-
response = request.post
|
115
|
-
|
116
|
-
if response.instance_of?(SynapseClient::Error)
|
117
|
-
response
|
118
|
-
elsif response["is_mfa"]
|
119
|
-
SynapseClient::MFA.new(response["response"])
|
120
|
-
else
|
121
|
-
add_bank_accounts response["banks"]
|
122
|
-
@bank_accounts
|
123
|
-
end
|
124
|
-
end
|
125
|
-
def unlink_account(options = {}, client)
|
126
|
-
data = {
|
127
|
-
:bank_id => options.delete(:bank_id),
|
128
|
-
}
|
102
|
+
def refresh_tokens
|
103
|
+
rt = SynapseClient::RefreshedTokens.new({
|
104
|
+
:old_access_token => @access_token,
|
105
|
+
:old_refresh_token => @refresh_token
|
106
|
+
}).refresh_old_tokens
|
129
107
|
|
130
|
-
|
131
|
-
|
108
|
+
return rt if rt.instance_of?(SynapseClient::Error)
|
109
|
+
|
110
|
+
@access_token = rt.new_access_token
|
111
|
+
@refresh_token = rt.new_refresh_token
|
112
|
+
@expires_in = rt.new_expires_in
|
113
|
+
|
114
|
+
return self
|
132
115
|
end
|
133
|
-
=end
|
134
116
|
|
135
117
|
|
136
118
|
private
|
@@ -2,15 +2,16 @@
|
|
2
2
|
module SynapseClient
|
3
3
|
class RefreshedTokens
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
attr_accessor :old_access_token
|
6
|
+
attr_accessor :old_refresh_token
|
7
|
+
attr_accessor :new_access_token
|
8
|
+
attr_accessor :new_refresh_token
|
9
|
+
attr_accessor :new_expires_in
|
9
10
|
|
10
11
|
def initialize(options = {})
|
11
12
|
options = Map.new(options)
|
12
13
|
|
13
|
-
@old_access_token
|
14
|
+
@old_access_token = options[:old_access_token]
|
14
15
|
@old_refresh_token = options[:old_refresh_token]
|
15
16
|
end
|
16
17
|
|
@@ -20,18 +21,17 @@ module SynapseClient
|
|
20
21
|
:refresh_token => @old_refresh_token
|
21
22
|
}
|
22
23
|
|
23
|
-
|
24
|
-
response = request.post
|
24
|
+
response = SynapseClient.request(:post, "/api/v2/user/refresh", data)
|
25
25
|
|
26
26
|
unless response.instance_of?(SynapseClient::Error)
|
27
|
-
|
28
|
-
|
27
|
+
@new_access_token = response.data["oauth_consumer_key"]
|
28
|
+
@new_refresh_token = response.data["refresh_token"]
|
29
|
+
@new_expires_in = response.data["expires_in"]
|
29
30
|
|
30
31
|
return self
|
31
32
|
else
|
32
33
|
return response
|
33
34
|
end
|
34
|
-
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -64,5 +64,25 @@ describe SynapseClient::Customer do
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
describe "refreshing a customer's token" do
|
68
|
+
it "should successfully get new oauth consumer key, refresh token, and expires in." do
|
69
|
+
customer = SynapseClient::Customer.retrieve(@customer.access_token, @customer.refresh_token)
|
70
|
+
|
71
|
+
old_access_token = @customer.access_token.dup
|
72
|
+
old_refresh_token = @customer.refresh_token.dup
|
73
|
+
|
74
|
+
response = customer.refresh_tokens
|
75
|
+
|
76
|
+
expect(response).to be_a SynapseClient::Customer
|
77
|
+
|
78
|
+
expect(customer.access_token).to be_a String
|
79
|
+
expect(customer.refresh_token).to be_a String
|
80
|
+
expect(customer.expires_in).to be_a Fixnum
|
81
|
+
|
82
|
+
expect(customer.access_token).not_to be eq(old_access_token)
|
83
|
+
expect(customer.refresh_token).not_to be eq(old_refresh_token)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
67
87
|
end
|
68
88
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapse_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Matthias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|