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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dcp.rb +16 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00b4d70fb9366b5c14adf9986391457bdbfbefdde2b69bfda3eeda7408e75601
4
- data.tar.gz: b05e506883147fb1249a3c53ca08ee0d8e0418b39727be2604084ac9fd2c75d0
3
+ metadata.gz: 802a8bb864f7e7c88721c31af50861030cae38e7a155c2abcbb67c7f8081439b
4
+ data.tar.gz: 121524123a433bff03c6ce1b7c4461813642c4f4668fc46906f9ec238fbd08bf
5
5
  SHA512:
6
- metadata.gz: 3170e990e37e8f6da481c61f77cfeb9f9866ca154b1fe97cded272e49080bb4191077a702a55d7cd9fa2ba59d1e6cf23a4ef09f7cbae8fd4856dc8cc07a29805
7
- data.tar.gz: 1f35424f75767ce81f01f49945414f30ed6ee25babee6a5fb4e3564da65406c32cfc1b8a3f922372934dda506c2f7d92a8ad31b835d4285cab2f48deae86c0ba
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.send_message(key, token)
6
- body = {
7
- oAuthToken: token.token,
8
- expiry: token.expires_at.to_i,
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dcp.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Huctwith