synapse_pay_rest 0.0.11 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +39 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +45 -0
- data/README.md +35 -0
- data/Rakefile +10 -0
- data/lib/synapse_pay_rest.rb +20 -25
- data/lib/synapse_pay_rest/api/nodes.rb +46 -0
- data/lib/synapse_pay_rest/api/trans.rb +38 -0
- data/lib/synapse_pay_rest/api/users.rb +97 -0
- data/lib/synapse_pay_rest/error.rb +114 -0
- data/lib/synapse_pay_rest/http_client.rb +109 -98
- data/lib/synapse_pay_rest/version.rb +3 -0
- data/samples.md +276 -0
- data/synapse_pay_rest.gemspec +27 -0
- metadata +74 -8
- data/lib/synapse_pay_rest/api/Nodes.rb +0 -55
- data/lib/synapse_pay_rest/api/Trans.rb +0 -51
- data/lib/synapse_pay_rest/api/Users.rb +0 -103
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'synapse_pay_rest/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'synapse_pay_rest'
|
7
|
+
s.version = SynapsePayRest::VERSION
|
8
|
+
s.date = Date.today.to_s
|
9
|
+
s.summary = "SynapsePay v3 Rest API Wrapper"
|
10
|
+
s.description = "A simple ruby wrapper for the SynapsePay v3 Rest API"
|
11
|
+
s.authors = ["Thomas Hipps", "Steven Broderick"]
|
12
|
+
s.email = 'steven@synapsepay.com'
|
13
|
+
s.homepage = 'https://rubygems.org/gems/synapse_pay_rest'
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
s.bindir = "exe"
|
18
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
s.add_development_dependency "rake", "~> 10.0"
|
23
|
+
s.add_development_dependency "minitest"
|
24
|
+
s.add_development_dependency "minitest-reporters"
|
25
|
+
|
26
|
+
s.add_dependency "rest-client"
|
27
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,72 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapse_pay_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Hipps
|
8
|
+
- Steven Broderick
|
8
9
|
autorequire:
|
9
|
-
bindir:
|
10
|
+
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.10'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.10'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: minitest
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest-reporters
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
13
70
|
- !ruby/object:Gem::Dependency
|
14
71
|
name: rest-client
|
15
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -25,16 +82,25 @@ dependencies:
|
|
25
82
|
- !ruby/object:Gem::Version
|
26
83
|
version: '0'
|
27
84
|
description: A simple ruby wrapper for the SynapsePay v3 Rest API
|
28
|
-
email:
|
85
|
+
email: steven@synapsepay.com
|
29
86
|
executables: []
|
30
87
|
extensions: []
|
31
88
|
extra_rdoc_files: []
|
32
89
|
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
33
95
|
- lib/synapse_pay_rest.rb
|
34
|
-
- lib/synapse_pay_rest/api/
|
35
|
-
- lib/synapse_pay_rest/api/
|
36
|
-
- lib/synapse_pay_rest/api/
|
96
|
+
- lib/synapse_pay_rest/api/nodes.rb
|
97
|
+
- lib/synapse_pay_rest/api/trans.rb
|
98
|
+
- lib/synapse_pay_rest/api/users.rb
|
99
|
+
- lib/synapse_pay_rest/error.rb
|
37
100
|
- lib/synapse_pay_rest/http_client.rb
|
101
|
+
- lib/synapse_pay_rest/version.rb
|
102
|
+
- samples.md
|
103
|
+
- synapse_pay_rest.gemspec
|
38
104
|
homepage: https://rubygems.org/gems/synapse_pay_rest
|
39
105
|
licenses:
|
40
106
|
- MIT
|
@@ -55,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
121
|
version: '0'
|
56
122
|
requirements: []
|
57
123
|
rubyforge_project:
|
58
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.5.1
|
59
125
|
signing_key:
|
60
126
|
specification_version: 4
|
61
127
|
summary: SynapsePay v3 Rest API Wrapper
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module SynapsePayRest
|
2
|
-
class Nodes
|
3
|
-
|
4
|
-
attr_accessor :client
|
5
|
-
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
8
|
-
end
|
9
|
-
|
10
|
-
def create_node_path(node_id: nil)
|
11
|
-
path = '/users/%s' % @client.user_id + '/nodes'
|
12
|
-
if node_id
|
13
|
-
path += '/%s' %node_id
|
14
|
-
end
|
15
|
-
return path
|
16
|
-
end
|
17
|
-
|
18
|
-
def add(payload: raise("payload is required"))
|
19
|
-
path = create_node_path()
|
20
|
-
response = @client.post(path, payload)
|
21
|
-
return response
|
22
|
-
end
|
23
|
-
|
24
|
-
def get(node_id: nil, page: nil)
|
25
|
-
if node_id
|
26
|
-
path = create_node_path(node_id: node_id)
|
27
|
-
else
|
28
|
-
path = create_node_path()
|
29
|
-
end
|
30
|
-
if page
|
31
|
-
path += '?page=%s' %page
|
32
|
-
end
|
33
|
-
response = @client.get(path)
|
34
|
-
return response
|
35
|
-
end
|
36
|
-
|
37
|
-
def verify(node_id: nil, payload: raise("payload is required"))
|
38
|
-
if node_id
|
39
|
-
path = create_node_path(node_id: node_id)
|
40
|
-
response = @client.patch(path, payload)
|
41
|
-
return response
|
42
|
-
else
|
43
|
-
path = create_node_path()
|
44
|
-
response = @client.post(path, payload)
|
45
|
-
return response
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def delete(node_id: raise("node_id is required"))
|
50
|
-
path = create_node_path(node_id: node_id)
|
51
|
-
response = @client.delete(path)
|
52
|
-
return response
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
module SynapsePayRest
|
2
|
-
class Trans
|
3
|
-
|
4
|
-
attr_accessor :client
|
5
|
-
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
8
|
-
end
|
9
|
-
|
10
|
-
def create_transaction_path(node_id: raise("node_id is required"), trans_id: nil)
|
11
|
-
path = '/users/' + @client.user_id + '/nodes/' + node_id + '/trans'
|
12
|
-
if trans_id
|
13
|
-
path += '/' + trans_id
|
14
|
-
end
|
15
|
-
return path
|
16
|
-
end
|
17
|
-
|
18
|
-
def create(node_id: raise("node_id is required"), payload: raise("payload is required"))
|
19
|
-
path = create_transaction_path(node_id: node_id)
|
20
|
-
response = @client.post(path, payload)
|
21
|
-
return response
|
22
|
-
end
|
23
|
-
|
24
|
-
def update(node_id: raise("node_id is required"), trans_id: raise("trans_id is required"), payload: raise("payload is required"))
|
25
|
-
path = create_transaction_path(node_id: node_id, trans_id: trans_id)
|
26
|
-
response = @client.patch(path, payload)
|
27
|
-
return response
|
28
|
-
end
|
29
|
-
|
30
|
-
def get(node_id: raise("node_id is required"), trans_id: nil, page: nil)
|
31
|
-
if trans_id
|
32
|
-
path = create_transaction_path(node_id: node_id, trans_id: trans_id)
|
33
|
-
response = @client.get(path)
|
34
|
-
return response
|
35
|
-
else
|
36
|
-
path = create_transaction_path(node_id: node_id)
|
37
|
-
if page
|
38
|
-
path += '?page=%d' %page
|
39
|
-
end
|
40
|
-
response = @client.get(path)
|
41
|
-
return response
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def delete(node_id: raise("node_id is required"), trans_id: raise("trans_id is required"))
|
46
|
-
path = create_transaction_path(node_id: node_id, trans_id: trans_id)
|
47
|
-
response = @client.delete(path)
|
48
|
-
return response
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'mime-types'
|
2
|
-
require 'base64'
|
3
|
-
require 'open-uri'
|
4
|
-
|
5
|
-
module SynapsePayRest
|
6
|
-
class Users
|
7
|
-
|
8
|
-
attr_accessor :client
|
9
|
-
|
10
|
-
def initialize(client)
|
11
|
-
@client = client
|
12
|
-
end
|
13
|
-
|
14
|
-
def create_user_path(user_id: nil)
|
15
|
-
path = '/users'
|
16
|
-
if user_id
|
17
|
-
path += '/%s' %user_id
|
18
|
-
end
|
19
|
-
return path
|
20
|
-
end
|
21
|
-
|
22
|
-
def refresh(payload: raise("payload is required"))
|
23
|
-
path = '/oauth/%s' % @client.user_id
|
24
|
-
response = @client.post(path, payload)
|
25
|
-
if response.has_key?('oauth_key')
|
26
|
-
@client.update_headers(oauth_key: response['oauth_key'])
|
27
|
-
end
|
28
|
-
return response
|
29
|
-
end
|
30
|
-
|
31
|
-
def get(user_id: nil, query: nil, page: nil, per_page: nil)
|
32
|
-
if user_id
|
33
|
-
path = create_user_path(user_id: user_id)
|
34
|
-
response = @client.get(path)
|
35
|
-
if response.has_key?('_id')
|
36
|
-
@client.update_headers(user_id: response['_id'])
|
37
|
-
end
|
38
|
-
elsif query
|
39
|
-
path += '?query=%s' %query
|
40
|
-
if page
|
41
|
-
path += '&page=%s' %page
|
42
|
-
end
|
43
|
-
if per_page
|
44
|
-
path += '&per_page=%s' %per_page
|
45
|
-
end
|
46
|
-
elsif page
|
47
|
-
path += '?page=%s' %page
|
48
|
-
if per_page
|
49
|
-
path += '&per_page=%s' %per_page
|
50
|
-
end
|
51
|
-
elsif per_page
|
52
|
-
path += '?page=%s' %per_page
|
53
|
-
else
|
54
|
-
path = create_user_path()
|
55
|
-
end
|
56
|
-
response = @client.get(path)
|
57
|
-
return response
|
58
|
-
end
|
59
|
-
|
60
|
-
def update(payload: raise("payload is required"))
|
61
|
-
path = create_user_path(user_id: @client.user_id)
|
62
|
-
response = @client.patch(path, payload)
|
63
|
-
return response
|
64
|
-
end
|
65
|
-
|
66
|
-
def create(payload: raise("payload is required"))
|
67
|
-
path = create_user_path()
|
68
|
-
response = @client.post(path, payload)
|
69
|
-
if response.has_key?('_id')
|
70
|
-
@client.update_headers(user_id: response['_id'])
|
71
|
-
end
|
72
|
-
return response
|
73
|
-
end
|
74
|
-
|
75
|
-
def add_doc(payload: raise("payload is required"))
|
76
|
-
path = create_user_path(user_id: @client.user_id)
|
77
|
-
response = @client.patch(path, payload)
|
78
|
-
return response
|
79
|
-
end
|
80
|
-
|
81
|
-
def answer_kba(payload: raise("payload is required"))
|
82
|
-
path = create_user_path(user_id: @client.user_id)
|
83
|
-
response = @client.patch(path, payload)
|
84
|
-
return response
|
85
|
-
end
|
86
|
-
|
87
|
-
def attach_file(file_path: raise("file_path is required"))
|
88
|
-
path = create_user_path(user_id: @client.user_id)
|
89
|
-
file_contents = open(file_path) { |f| f.read }
|
90
|
-
file_type = MIME::Types.type_for(file_path).first.content_type
|
91
|
-
mime_padding = 'data:' + file_type + ';base64,'
|
92
|
-
encoded = Base64.encode64(file_contents)
|
93
|
-
base64_attachment = mime_padding + encoded
|
94
|
-
payload = {
|
95
|
-
'doc' => {
|
96
|
-
'attachment' => base64_attachment
|
97
|
-
}
|
98
|
-
}
|
99
|
-
response = @client.patch(path, payload)
|
100
|
-
return response
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|