dcp.rb 0.1.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dcp.rb +16 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 802a8bb864f7e7c88721c31af50861030cae38e7a155c2abcbb67c7f8081439b
|
4
|
+
data.tar.gz: 121524123a433bff03c6ce1b7c4461813642c4f4668fc46906f9ec238fbd08bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f25a70119b74dc3e62353d566d45ba2f71227dee04eaee2b5cc9d29cf6a4246676b5acaffb805773863730fba939c7c722cc9e04a8413882f5456b6aa2021be
|
7
|
+
data.tar.gz: 90eda25eaa9263674cb9697a10891ddbf886966d20c04cf89575467c9bb680677afe3c073da4ba8156edf1390d4fe2dbe795e6706be908906812a51c547fd553
|
data/lib/dcp.rb
CHANGED
@@ -2,10 +2,18 @@ require 'httparty'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
class DCP
|
5
|
-
def self.
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def self.send_oauth_message(key, token)
|
6
|
+
send_proxy_message(key, token.token, token.expires_at.to_i, "")
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.send_banklist_message(key, password)
|
10
|
+
send_proxy_message(key, password, Time.now.to_i + 60, "")
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.send_proxy_message(key, password, expiry, scopes)
|
14
|
+
body = {
|
15
|
+
oAuthToken: password,
|
16
|
+
expiry: expiry,
|
9
17
|
endpoint: ENV['PROXY_URL']
|
10
18
|
}
|
11
19
|
|
@@ -16,17 +24,19 @@ class DCP
|
|
16
24
|
}.to_json
|
17
25
|
|
18
26
|
message = {signedMessage: message_string}
|
19
|
-
|
27
|
+
|
20
28
|
response = HTTParty.post(ENV['PROXY_URL'], body: message)
|
21
29
|
reply_body = response.body
|
22
30
|
reply = JSON.parse reply_body
|
23
|
-
|
31
|
+
|
24
32
|
unless reply['success']
|
25
33
|
Rails.logger.error "Proxy service returned error #{reply['error']}"
|
26
34
|
end
|
27
35
|
|
28
36
|
return reply
|
29
37
|
end
|
38
|
+
|
39
|
+
private
|
30
40
|
|
31
41
|
def self.sign(key, body)
|
32
42
|
sig = key.personal_sign body.to_json
|