synapse_payments 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/synapse_payments/client.rb +8 -8
- data/lib/synapse_payments/node.rb +2 -5
- data/lib/synapse_payments/nodes.rb +6 -5
- data/lib/synapse_payments/request.rb +5 -2
- data/lib/synapse_payments/transactions.rb +7 -6
- data/lib/synapse_payments/user_client.rb +6 -5
- data/lib/synapse_payments/users.rb +5 -5
- data/lib/synapse_payments/version.rb +1 -1
- data/samples.md +2 -1
- 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: 4f4123d596fcbe30b219c5e2d9266a762d37285c
|
4
|
+
data.tar.gz: 79e51fd423fb548577e4dd78e210e1eb6e29fda1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a81f7a5435941163e016e2bb63d838818198a99c67aa0d84a7d4a892cc416a1f22e04043e142b97001777b378455aa1d9cdc71fad64bf3a9c338789d38c3d1a2
|
7
|
+
data.tar.gz: 4c86931ec9f611bd4d78be0f5d9ea1cc634a911813cfa16a02c91cc06a30bc3cbcc4c8f6aac3147b801f5f596fb5656d0867e39a92561124961e459795f93e1c
|
@@ -40,20 +40,20 @@ module SynapsePayments
|
|
40
40
|
credentials.values.all?
|
41
41
|
end
|
42
42
|
|
43
|
-
def get(path:, oauth_key: nil)
|
44
|
-
Request.new(client: self, method: :get, path: path, oauth_key: oauth_key).perform
|
43
|
+
def get(path:, oauth_key: nil, fingerprint: nil)
|
44
|
+
Request.new(client: self, method: :get, path: path, oauth_key: oauth_key, fingerprint: fingerprint).perform
|
45
45
|
end
|
46
46
|
|
47
|
-
def post(path:, json:, oauth_key: nil)
|
48
|
-
Request.new(client: self, method: :post, path: path, oauth_key: oauth_key, json: json).perform
|
47
|
+
def post(path:, json:, oauth_key: nil, fingerprint: nil)
|
48
|
+
Request.new(client: self, method: :post, path: path, oauth_key: oauth_key, fingerprint: fingerprint, json: json).perform
|
49
49
|
end
|
50
50
|
|
51
|
-
def patch(path:, json:, oauth_key: nil)
|
52
|
-
Request.new(client: self, method: :patch, path: path, oauth_key: oauth_key, json: json).perform
|
51
|
+
def patch(path:, json:, oauth_key: nil, fingerprint: nil)
|
52
|
+
Request.new(client: self, method: :patch, path: path, oauth_key: oauth_key, fingerprint: fingerprint, json: json).perform
|
53
53
|
end
|
54
54
|
|
55
|
-
def delete(path:, oauth_key: nil)
|
56
|
-
Request.new(client: self, method: :delete, path: path, oauth_key: oauth_key).perform
|
55
|
+
def delete(path:, oauth_key: nil, fingerprint: nil)
|
56
|
+
Request.new(client: self, method: :delete, path: path, oauth_key: oauth_key, fingerprint: fingerprint).perform
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
@@ -3,12 +3,9 @@ module SynapsePayments
|
|
3
3
|
|
4
4
|
attr_reader :transactions
|
5
5
|
|
6
|
-
def initialize(client, user_id, node_id, oauth_key)
|
6
|
+
def initialize(client, user_id, node_id, oauth_key, fingerprint)
|
7
7
|
@client = client
|
8
|
-
@
|
9
|
-
@node_id = node_id
|
10
|
-
@oauth_key = oauth_key
|
11
|
-
@transactions = Transactions.new(@client, user_id, node_id, oauth_key)
|
8
|
+
@transactions = Transactions.new(@client, user_id, node_id, oauth_key, fingerprint)
|
12
9
|
end
|
13
10
|
|
14
11
|
end
|
@@ -1,26 +1,27 @@
|
|
1
1
|
module SynapsePayments
|
2
2
|
class Nodes
|
3
3
|
|
4
|
-
def initialize(client, user_id, oauth_key)
|
4
|
+
def initialize(client, user_id, oauth_key, fingerprint)
|
5
5
|
@client = client
|
6
6
|
@user_id = user_id
|
7
7
|
@oauth_key = oauth_key
|
8
|
+
@fingerprint = fingerprint
|
8
9
|
end
|
9
10
|
|
10
11
|
def all
|
11
|
-
@client.get(path: "/users/#{@user_id}/nodes", oauth_key: @oauth_key)
|
12
|
+
@client.get(path: "/users/#{@user_id}/nodes", oauth_key: @oauth_key, fingerprint: @fingerprint)
|
12
13
|
end
|
13
14
|
|
14
15
|
def find(id)
|
15
|
-
@client.get(path: "/users/#{@user_id}/nodes/#{id}", oauth_key: @oauth_key)
|
16
|
+
@client.get(path: "/users/#{@user_id}/nodes/#{id}", oauth_key: @oauth_key, fingerprint: @fingerprint)
|
16
17
|
end
|
17
18
|
|
18
19
|
def create(data)
|
19
|
-
@client.post(path: "/users/#{@user_id}/nodes", oauth_key: @oauth_key, json: data)
|
20
|
+
@client.post(path: "/users/#{@user_id}/nodes", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)
|
20
21
|
end
|
21
22
|
|
22
23
|
def delete(id)
|
23
|
-
@client.delete(path: "/users/#{@user_id}/nodes/#{id}", oauth_key: @oauth_key)
|
24
|
+
@client.delete(path: "/users/#{@user_id}/nodes/#{id}", oauth_key: @oauth_key, fingerprint: @fingerprint)
|
24
25
|
end
|
25
26
|
|
26
27
|
end
|
@@ -8,11 +8,12 @@ module SynapsePayments
|
|
8
8
|
'X-Ruby-Platform' => RUBY_PLATFORM
|
9
9
|
}
|
10
10
|
|
11
|
-
def initialize(client:, method:, path:, oauth_key: nil, json: nil)
|
11
|
+
def initialize(client:, method:, path:, oauth_key: nil, fingerprint: nil, json: nil)
|
12
12
|
@client = client
|
13
13
|
@method = method
|
14
14
|
@path = path
|
15
15
|
@oauth_key = oauth_key
|
16
|
+
@fingerprint = fingerprint
|
16
17
|
@json = json
|
17
18
|
end
|
18
19
|
|
@@ -23,10 +24,12 @@ module SynapsePayments
|
|
23
24
|
fail_or_return_response_body(response.code, response_body)
|
24
25
|
end
|
25
26
|
|
27
|
+
private
|
28
|
+
|
26
29
|
def http_client
|
27
30
|
headers = HEADERS.merge({
|
28
31
|
'X-SP-GATEWAY' => "#{@client.client_id}|#{@client.client_secret}",
|
29
|
-
'X-SP-USER' => "#{@oauth_key}
|
32
|
+
'X-SP-USER' => "#{@oauth_key}|#{@fingerprint}",
|
30
33
|
'X-SP-USER-IP' => ''
|
31
34
|
})
|
32
35
|
HTTP.headers(headers).timeout(write: 2, connect: 5, read: 10)
|
@@ -1,15 +1,16 @@
|
|
1
1
|
module SynapsePayments
|
2
2
|
class Transactions
|
3
3
|
|
4
|
-
def initialize(client, user_id, node_id, oauth_key)
|
4
|
+
def initialize(client, user_id, node_id, oauth_key, fingerprint)
|
5
5
|
@client = client
|
6
6
|
@user_id = user_id
|
7
7
|
@node_id = node_id
|
8
8
|
@oauth_key = oauth_key
|
9
|
+
@fingerprint = fingerprint
|
9
10
|
end
|
10
11
|
|
11
12
|
def all
|
12
|
-
@client.get(path: "/users/#{@user_id}/nodes/#{@node_id}/trans", oauth_key: @oauth_key)
|
13
|
+
@client.get(path: "/users/#{@user_id}/nodes/#{@node_id}/trans", oauth_key: @oauth_key, fingerprint: @fingerprint)
|
13
14
|
end
|
14
15
|
|
15
16
|
def create(node_id:, node_type:, amount:, currency:, ip_address:, **args)
|
@@ -27,19 +28,19 @@ module SynapsePayments
|
|
27
28
|
}.merge(args)
|
28
29
|
}
|
29
30
|
|
30
|
-
@client.post(path: "/users/#{@user_id}/nodes/#{@node_id}/trans", oauth_key: @oauth_key, json: data)
|
31
|
+
@client.post(path: "/users/#{@user_id}/nodes/#{@node_id}/trans", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)
|
31
32
|
end
|
32
33
|
|
33
34
|
def delete(id)
|
34
|
-
@client.delete(path: "/users/#{@user_id}/nodes/#{@node_id}/trans/#{id}", oauth_key: @oauth_key)
|
35
|
+
@client.delete(path: "/users/#{@user_id}/nodes/#{@node_id}/trans/#{id}", oauth_key: @oauth_key, fingerprint: @fingerprint)
|
35
36
|
end
|
36
37
|
|
37
38
|
def find(id)
|
38
|
-
@client.get(path: "/users/#{@user_id}/nodes/#{@node_id}/trans/#{id}", oauth_key: @oauth_key)
|
39
|
+
@client.get(path: "/users/#{@user_id}/nodes/#{@node_id}/trans/#{id}", oauth_key: @oauth_key, fingerprint: @fingerprint)
|
39
40
|
end
|
40
41
|
|
41
42
|
def update(id, data)
|
42
|
-
@client.patch(path: "/users/#{@user_id}/nodes/#{@node_id}/trans/#{id}", oauth_key: @oauth_key, json: data)
|
43
|
+
@client.patch(path: "/users/#{@user_id}/nodes/#{@node_id}/trans/#{id}", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)
|
43
44
|
end
|
44
45
|
|
45
46
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module SynapsePayments
|
2
2
|
class UserClient
|
3
3
|
|
4
|
-
def initialize(client, user_id, response)
|
4
|
+
def initialize(client, user_id, fingerprint, response)
|
5
5
|
@client = client
|
6
6
|
@user_id = user_id
|
7
|
+
@fingerprint = fingerprint
|
7
8
|
@response = response
|
8
9
|
@oauth_key = response[:oauth_key]
|
9
10
|
|
@@ -15,7 +16,7 @@ module SynapsePayments
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
@nodes = Nodes.new(@client, user_id, oauth_key)
|
19
|
+
@nodes = Nodes.new(@client, user_id, oauth_key, fingerprint)
|
19
20
|
end
|
20
21
|
|
21
22
|
def user
|
@@ -49,7 +50,7 @@ module SynapsePayments
|
|
49
50
|
}
|
50
51
|
}
|
51
52
|
|
52
|
-
@client.patch(path: "/users/#{@user_id}", oauth_key: @oauth_key, json: data)
|
53
|
+
@client.patch(path: "/users/#{@user_id}", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)
|
53
54
|
end
|
54
55
|
|
55
56
|
def answer_kba(question_set_id:, answers:)
|
@@ -60,7 +61,7 @@ module SynapsePayments
|
|
60
61
|
}
|
61
62
|
}
|
62
63
|
|
63
|
-
@client.patch(path: "/users/#{@user_id}", oauth_key: @oauth_key, json: data)
|
64
|
+
@client.patch(path: "/users/#{@user_id}", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)
|
64
65
|
end
|
65
66
|
|
66
67
|
# Adds a bank account by creating a node of node type ACH-US.
|
@@ -97,7 +98,7 @@ module SynapsePayments
|
|
97
98
|
if id.nil?
|
98
99
|
@nodes
|
99
100
|
else
|
100
|
-
Node.new(@client, @user_id, id, @oauth_key)
|
101
|
+
Node.new(@client, @user_id, id, @oauth_key, @fingerprint)
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
@@ -9,12 +9,12 @@ module SynapsePayments
|
|
9
9
|
@client.get(path: '/users')
|
10
10
|
end
|
11
11
|
|
12
|
-
def authenticate_as(id:, refresh_token:)
|
13
|
-
response = @client.post(path: "/oauth/#{id}", json: { refresh_token: refresh_token })
|
14
|
-
UserClient.new(@client, id, response)
|
12
|
+
def authenticate_as(id:, refresh_token:, fingerprint: nil)
|
13
|
+
response = @client.post(path: "/oauth/#{id}", fingerprint: fingerprint, json: { refresh_token: refresh_token })
|
14
|
+
UserClient.new(@client, id, fingerprint, response)
|
15
15
|
end
|
16
16
|
|
17
|
-
def create(name:, email:, phone:, is_business: false, **args)
|
17
|
+
def create(name:, email:, phone:, fingerprint: nil, is_business: false, **args)
|
18
18
|
data = {
|
19
19
|
logins: email.is_a?(Array) ? email : [{ email: email }],
|
20
20
|
phone_numbers: phone.is_a?(Array) ? phone : [phone],
|
@@ -26,7 +26,7 @@ module SynapsePayments
|
|
26
26
|
}
|
27
27
|
}
|
28
28
|
|
29
|
-
@client.post(path: '/users', json: data)
|
29
|
+
@client.post(path: '/users', json: data, fingerprint: fingerprint)
|
30
30
|
end
|
31
31
|
|
32
32
|
def find(id)
|
data/samples.md
CHANGED
@@ -28,7 +28,8 @@ response = client.users.all
|
|
28
28
|
response = client.users.create(
|
29
29
|
name: 'John Smith',
|
30
30
|
email: 'johnsmith@example.com',
|
31
|
-
phone: '123-456-7890'
|
31
|
+
phone: '123-456-7890',
|
32
|
+
fingerprint: 'abc123' # optional but recommended
|
32
33
|
)
|
33
34
|
|
34
35
|
# or specify multiple names, logins, phones...
|
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.
|
4
|
+
version: 0.2.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-11-
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|