synapse_payments 0.3.1 → 0.4.0

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: 87b8e53a05737dc15b71138d93428e21e59a955d
4
- data.tar.gz: 35d0134db2bae2219a1f0cfaae0fa4a18524f17d
3
+ metadata.gz: 71ea3da1b22eb4f7df46e3f8af695d9edd118bb9
4
+ data.tar.gz: 05fac6386bd5fd783579b309b637c7202788a58c
5
5
  SHA512:
6
- metadata.gz: 44cc26fe873fa9a42eee01960914a7c5d795f81f7c0894d2336023e5444ca2ee1e229673dda3dbd5a5e2396c24965b6d9c4163e35ab08c3290ac7175ae597d8d
7
- data.tar.gz: 024c3e4d10414bc40eed6a1795d4b25d56d8f926335c1ea7e1dcc218fe5c8d753aef42bb22b7cf8aa0977e0e24a360040fc9c93592fb71ed16570cc1ae2a62a0
6
+ metadata.gz: e3d88e8233269add1592dec231f244f82e5ca9c0003bd74487f568980281a2fdfc4aaa6c86ed4c0f564e25a5e43ce9242488b4d5dc31cca6269bf038d16542aa
7
+ data.tar.gz: 5bc7cfe6f4ad624285a0c8b542339897b5f8925b084481dd65809b8a0b7a7efbbda2393dc4dd506044882cc294a8ccf78f962035a847b8f2c6cf9866ee7e7455
@@ -40,6 +40,13 @@ module SynapsePayments
40
40
  credentials.values.all?
41
41
  end
42
42
 
43
+ # @return [Array]
44
+ def institutions
45
+ institutions = HTTP.get('https://synapsepay.com/api/v3/institutions/show').parse
46
+ symbolize_keys!(institutions)
47
+ institutions[:banks]
48
+ end
49
+
43
50
  def get(path:, oauth_key: nil, fingerprint: nil)
44
51
  Request.new(client: self, method: :get, path: path, oauth_key: oauth_key, fingerprint: fingerprint).perform
45
52
  end
@@ -56,5 +63,18 @@ module SynapsePayments
56
63
  Request.new(client: self, method: :delete, path: path, oauth_key: oauth_key, fingerprint: fingerprint).perform
57
64
  end
58
65
 
66
+ def symbolize_keys!(object)
67
+ if object.is_a?(Array)
68
+ object.each_with_index do |val, index|
69
+ object[index] = symbolize_keys!(val)
70
+ end
71
+ elsif object.is_a?(Hash)
72
+ object.keys.each do |key|
73
+ object[key.to_sym] = symbolize_keys!(object.delete(key))
74
+ end
75
+ end
76
+ object
77
+ end
78
+
59
79
  end
60
80
  end
@@ -20,7 +20,7 @@ module SynapsePayments
20
20
  def perform
21
21
  options_key = @method == :get ? :params : :json
22
22
  response = http_client.public_send(@method, "#{@client.api_base}#{@path}", options_key => @json)
23
- response_body = symbolize_keys!(response.parse)
23
+ response_body = @client.symbolize_keys!(response.parse)
24
24
  fail_or_return_response_body(response.code, response_body)
25
25
  end
26
26
 
@@ -35,19 +35,6 @@ module SynapsePayments
35
35
  HTTP.headers(headers).timeout(write: 2, connect: 5, read: 10)
36
36
  end
37
37
 
38
- def symbolize_keys!(object)
39
- if object.is_a?(Array)
40
- object.each_with_index do |val, index|
41
- object[index] = symbolize_keys!(val)
42
- end
43
- elsif object.is_a?(Hash)
44
- object.keys.each do |key|
45
- object[key.to_sym] = symbolize_keys!(object.delete(key))
46
- end
47
- end
48
- object
49
- end
50
-
51
38
  def fail_or_return_response_body(code, body)
52
39
  if code < 200 || code >= 206
53
40
  error = SynapsePayments::Error.error_from_response(body, code)
@@ -103,6 +103,28 @@ module SynapsePayments
103
103
  nodes.create(data)
104
104
  end
105
105
 
106
+ def bank_login(bank_name:, username:, password:)
107
+ data = {
108
+ type: 'ACH-US',
109
+ info: {
110
+ bank_id: username,
111
+ bank_pw: password,
112
+ bank_name: bank_name
113
+ }
114
+ }
115
+
116
+ nodes.create(data)
117
+ end
118
+
119
+ def verify_mfa(access_token:, answer:)
120
+ data = {
121
+ access_token: access_token,
122
+ mfa_answer: answer
123
+ }
124
+
125
+ nodes.create(data)
126
+ end
127
+
106
128
  def send_money(from:, to:, to_node_type:, amount:, currency:, ip_address:, **args)
107
129
  nodes(from).transactions.create(node_id: to, node_type: to_node_type, amount: amount, currency: currency, ip_address: ip_address, **args)
108
130
  end
@@ -1,3 +1,3 @@
1
1
  module SynapsePayments
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
data/samples.md CHANGED
@@ -14,6 +14,20 @@ client = SynapsePayments::Client.new do |config|
14
14
  end
15
15
  ```
16
16
 
17
+ ### Institutions
18
+
19
+ #### Retrieve all supported banks for login
20
+
21
+ ```ruby
22
+ response = client.institutions
23
+
24
+ response.size
25
+ # => 16
26
+
27
+ response[1][:bank_name]
28
+ # => "Bank of America"
29
+ ```
30
+
17
31
  ### Users
18
32
 
19
33
  #### Retrieve all users (paginated)
@@ -124,6 +138,29 @@ response = user_client.add_bank_account(
124
138
  )
125
139
  ```
126
140
 
141
+ #### Bank account login
142
+
143
+ The following could return a list of nodes (bank accounts) or MFA question.
144
+
145
+ ```ruby
146
+ response = user_client.bank_login(
147
+ bank_id: 'bofa', # from bank_code at https://synapsepay.com/api/v3/institutions/show
148
+ username: 'username',
149
+ password: 'password'
150
+ )
151
+ ```
152
+
153
+ #### Verify MFA for bank account login
154
+
155
+ Note that this is an additional step for some banks, since not all support MFA.
156
+
157
+ ```ruby
158
+ response = user_client.verify_mfa(
159
+ access_token: '8MNcKv1blk...', # returned in previous bank_login call
160
+ answer: 'your answer'
161
+ )
162
+ ```
163
+
127
164
  #### Send money 💸
128
165
 
129
166
  ```ruby
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapse_payments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Julio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2015-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler