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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4636a88b781418553e2e97de39a7edd3e76f833
4
- data.tar.gz: 8db58c259fd1d4c6c552f0788e53f26d6f94053f
3
+ metadata.gz: c46836e82f8fd5cadaf0f92f1f63a3d1ea1e8aef
4
+ data.tar.gz: 0ecf16d300d068f81a8492e14c37b20d87424a9a
5
5
  SHA512:
6
- metadata.gz: d157a8213f38001d4f06a907196877b479777b31f45819547d0af5444b3003a0fe1dee5e4c431cc688420132027b10879d7e25616bf460e8fb0081e173e8b6b4
7
- data.tar.gz: 82389bfbe4f943911732ce7d1bce1009f6a96a24ec1a69ed9cbed0ef9c88687a654f09bbfd3133dec1ff0e8027d453e7a40e25481840525cfc094aba05a226f4
6
+ metadata.gz: d0b24502cc145f806e2a2aab43df57154f6dd7de6f7153c594764b64af6bf994485495d1a0ac0543aa50e951150da6499667d22ca8d57bcc539795ed8df636ea
7
+ data.tar.gz: 555c437e3273c0c4a0a0ab2f192c80079a2e1a4a15a6791e8ce587edd1ee5f0999581a2f7ad9681e2187c6bae0192a725cf9711f8d750345e30591c97edab2fc
@@ -99,38 +99,20 @@ module SynapseClient
99
99
  end
100
100
  end
101
101
 
102
- =begin
103
- def link_account(options = {}, client)
104
- options.to_options!.compact
105
-
106
- data = {
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
- request = SynapseClient::Request.new("/api/v2/bank/delete/", data, client)
131
- request.post
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
- attr_reader :old_access_token
6
- attr_reader :old_refresh_token
7
- attr_reader :new_access_token
8
- attr_reader :new_refresh_token
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 = options[: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
- request = SynapseClient::Request.new("/oauth2/access_token", data)
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
- self.new_access_token = response["access_token"]
28
- self.new_refresh_token = response["refresh_token"]
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
@@ -1,3 +1,3 @@
1
1
  module SynapseClient
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  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.2
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-09 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client