wealthforge-ruby 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -37
- data/lib/wealthforge-ruby.rb +6 -8
- data/lib/wealthforge/configuration.rb +13 -11
- data/lib/wealthforge/connection.rb +76 -39
- data/lib/wealthforge/investment.rb +9 -84
- data/lib/wealthforge/issuer.rb +3 -31
- data/lib/wealthforge/offering.rb +1 -12
- data/lib/wealthforge/version.rb +1 -1
- metadata +24 -44
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/fixtures/vcr_cassettes/all_investors.yml +0 -14242
- data/fixtures/vcr_cassettes/create_investor.yml +0 -42
- data/fixtures/vcr_cassettes/create_issuer.yml +0 -42
- data/fixtures/vcr_cassettes/create_offering.yml +0 -42
- data/fixtures/vcr_cassettes/create_subscription_agreement.yml +0 -42
- data/fixtures/vcr_cassettes/due_dilegence.yml +0 -42
- data/fixtures/vcr_cassettes/due_dilegence_file.yml +0 -275
- data/fixtures/vcr_cassettes/get_investment_by_id.yml +0 -127
- data/fixtures/vcr_cassettes/get_investments.yml +0 -9137
- data/fixtures/vcr_cassettes/get_investor.yml +0 -45
- data/fixtures/vcr_cassettes/get_issuer.yml +0 -46
- data/fixtures/vcr_cassettes/get_issuers.yml +0 -238
- data/fixtures/vcr_cassettes/get_offering_by_id.yml +0 -94
- data/fixtures/vcr_cassettes/get_subscription_agreement.yml +0 -40
- data/fixtures/vcr_cassettes/investment_account.yml +0 -44
- data/fixtures/vcr_cassettes/investment_certificate.yml +0 -77
- data/fixtures/vcr_cassettes/investment_status.yml +0 -81
- data/fixtures/vcr_cassettes/list_offerings.yml +0 -375
- data/fixtures/vcr_cassettes/redirect_url.yml +0 -42
- data/fixtures/vcr_cassettes/request_investment_approval.yml +0 -48
- data/fixtures/vcr_cassettes/request_subscription_approval.yml +0 -48
- data/fixtures/vcr_cassettes/subscription_agreement.yml +0 -153
- data/fixtures/vcr_cassettes/term_sheets.yml +0 -183
- data/fixtures/vcr_cassettes/update_investment.yml +0 -87
- data/fixtures/vcr_cassettes/update_investment_account.yml +0 -44
- data/fixtures/vcr_cassettes/update_investor.yml +0 -80
- data/fixtures/vcr_cassettes/upload_accreditation_files.yml +0 -78
- data/lib/wealthforge/investor.rb +0 -37
- data/wealthforge-ruby.gemspec +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2309bce743622e8eb49912b27e80e7ae7026fc02
|
4
|
+
data.tar.gz: b0ffddeac60fa25703bd98072ac82e2360005e52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad5a449f13e7e79063c5df328518050872b1846b1c2c7b08acf34783b0b73dec70f9574f3a92d1e3777a4afc2d9067154b3ba0cb2b51452cbdf9fb9db90e59fb
|
7
|
+
data.tar.gz: 7f2ac8c50468da962e6b47037ea08d7b286e9529cd5f558633108ca1b4ada6e9debe0377cd7cfb42dab2d419bce40a0cd1c48fdc2b8d52b594a0aca59c75afb5
|
data/README.md
CHANGED
@@ -26,62 +26,32 @@ Before you can use this gem, you'll need to configure it with the key and cert,
|
|
26
26
|
|
27
27
|
|
28
28
|
WealthForge.configure do |config|
|
29
|
-
config.
|
30
|
-
config.
|
29
|
+
config.client_secret = ENV['WF_CLIENT_SECRET']
|
30
|
+
config.client_id = ENV['WF_CLIENT_ID']
|
31
31
|
config.environment = 'development'
|
32
32
|
end
|
33
33
|
|
34
|
-
or
|
35
|
-
|
36
|
-
WealthForge.configure do |config|
|
37
|
-
config.wf_crt = ENV['WF_CRT']
|
38
|
-
config.wf_key = ENV['WF_KEY']
|
39
|
-
config.environment = 'development'
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
34
|
|
44
35
|
## Usage
|
45
36
|
|
46
|
-
Please refer to the official WealthForge API [documentation](https://api.
|
37
|
+
Please refer to the official WealthForge API [documentation](https://wealthforge.api-docs.io/) for a full list of API calls. Note that this is currently a partial implementation of the most commonly used functionality.
|
47
38
|
|
48
39
|
|
49
40
|
### Available Calls
|
50
41
|
|
51
|
-
#### Investor
|
52
|
-
|
53
|
-
WealthForge::Investor.all
|
54
|
-
WealthForge::Investor.create params
|
55
|
-
WealthForge::Investor.get investor_id
|
56
|
-
WealthForge::Investor.update investor_id, params
|
57
|
-
WealthForge::Investor.accreditation_evidence investor_id, params
|
58
|
-
|
59
42
|
#### Investment
|
60
43
|
|
61
|
-
WealthForge::Investment.all
|
62
44
|
WealthForge::Investment.create params
|
63
45
|
WealthForge::Investment.get investment_id
|
64
|
-
WealthForge::Investment.
|
65
|
-
WealthForge::Investment.redirect_url investment_id
|
66
|
-
WealthForge::Investment.status investment_id
|
67
|
-
WealthForge::Investment.account investment_id
|
68
|
-
WealthForge::Investment.update_account investment_id, account
|
69
|
-
WealthForge::Investment.approve investment_id
|
70
|
-
WealthForge::Investment.approve_subscription investment_id
|
71
|
-
WealthForge::Investment.due_diligence investment_id
|
72
|
-
WealthForge::Investment.create_subscription_agreement investment_id, params
|
46
|
+
WealthForge::Investment.file_upload path, mime_type, title, subscription_id
|
73
47
|
|
74
48
|
#### Issuer
|
75
49
|
|
76
|
-
WealthForge::Issuer.all
|
77
50
|
WealthForge::Issuer.create params
|
78
|
-
WealthForge::Issuer.get id
|
79
51
|
|
80
52
|
#### Offering
|
81
53
|
|
82
54
|
WealthForge::Offering.create params
|
83
|
-
WealthForge::Offering.all
|
84
|
-
WealthForge::Offering.get id
|
85
55
|
|
86
56
|
|
87
57
|
## Contributing
|
@@ -93,8 +63,8 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/dinosi
|
|
93
63
|
|
94
64
|
All tests can be run by typing `rspec`. Prior to running tests, you'll need to export your cert and key as such:
|
95
65
|
|
96
|
-
export
|
97
|
-
export
|
66
|
+
export WF_CLIENT_SECRET=[secret]
|
67
|
+
export WF_CLIENT_ID=[client-id]
|
98
68
|
|
99
69
|
|
100
70
|
## License
|
@@ -109,4 +79,4 @@ This project and the code therein was not created by and is not supported by Wea
|
|
109
79
|
|
110
80
|
## Author
|
111
81
|
|
112
|
-
Dino Simone (dino@simone.is)
|
82
|
+
Dino Simone (dino@simone.is) | dinosimone.com
|
data/lib/wealthforge-ruby.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require "wealthforge/issuer"
|
8
|
-
require "wealthforge/offering"
|
1
|
+
require 'wealthforge/configuration'
|
2
|
+
require 'wealthforge/api_exception'
|
3
|
+
require 'wealthforge/connection'
|
4
|
+
require 'wealthforge/investment'
|
5
|
+
require 'wealthforge/issuer'
|
6
|
+
require 'wealthforge/offering'
|
9
7
|
|
10
8
|
module WealthForge
|
11
9
|
|
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
1
|
module WealthForge
|
2
|
+
|
3
3
|
class Configuration
|
4
4
|
|
5
|
-
attr_accessor :
|
6
|
-
attr_accessor :
|
7
|
-
attr_accessor :wf_crt_file
|
8
|
-
attr_accessor :wf_key_file
|
5
|
+
attr_accessor :client_id
|
6
|
+
attr_accessor :client_secret
|
9
7
|
attr_accessor :environment
|
10
|
-
|
8
|
+
attr_accessor :api_url
|
9
|
+
attr_accessor :token_url
|
10
|
+
attr_accessor :version
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@environment
|
13
|
+
@client_id = nil
|
14
|
+
@client_secret = nil
|
15
|
+
@api_url = 'https://api.wealthforge.org/v1/'
|
16
|
+
@token_url = 'https://api.wealthforge.org/v1/auth/tokens'
|
17
|
+
@environment = 'development'
|
18
|
+
@version = 'v2'
|
18
19
|
end
|
19
20
|
|
20
21
|
end
|
22
|
+
|
21
23
|
end
|
@@ -4,7 +4,7 @@ require 'json'
|
|
4
4
|
require 'csv'
|
5
5
|
require 'timeout'
|
6
6
|
require 'resolv-replace'
|
7
|
-
|
7
|
+
require 'jwt'
|
8
8
|
|
9
9
|
class WealthForge::Connection
|
10
10
|
|
@@ -13,81 +13,118 @@ class WealthForge::Connection
|
|
13
13
|
response = connection.post do |req|
|
14
14
|
req.url endpoint
|
15
15
|
req.headers['Content-Type'] = 'application/json'
|
16
|
-
req.body =
|
17
|
-
|
18
|
-
JSON.parse(response.body, symbolize_names: true)
|
16
|
+
req.body = params.to_json
|
17
|
+
end
|
19
18
|
rescue => e
|
20
19
|
raise WealthForge::ApiException.new(e)
|
21
20
|
end
|
21
|
+
JSON.parse(response.body)
|
22
22
|
end
|
23
23
|
|
24
24
|
|
25
|
-
def self.
|
25
|
+
def self.get(endpoint, params)
|
26
26
|
begin
|
27
|
-
response = connection.
|
27
|
+
response = connection.get do |req|
|
28
28
|
req.url endpoint
|
29
29
|
req.headers['Content-Type'] = 'application/json'
|
30
|
-
req.body =
|
30
|
+
req.body = params.to_json
|
31
31
|
end
|
32
|
-
JSON.parse(response.body, symbolize_names: true)
|
33
32
|
rescue => e
|
34
33
|
raise WealthForge::ApiException.new(e)
|
35
34
|
end
|
35
|
+
JSON.parse(response.body)
|
36
36
|
end
|
37
37
|
|
38
38
|
|
39
|
-
def self.
|
39
|
+
def self.file_upload (endpoint, file, filename, mime_type)
|
40
|
+
payload = {:file => Faraday::UploadIO.new(file, mime_type, filename)}
|
40
41
|
begin
|
41
|
-
response =
|
42
|
+
response = connection_multipart.post do |req|
|
42
43
|
req.url endpoint
|
43
|
-
req.
|
44
|
-
req.body = prep_params(params)
|
44
|
+
req.body = payload
|
45
45
|
end
|
46
|
-
raw == false ? JSON.parse(response.body, symbolize_names: true) : response.body
|
47
46
|
rescue => e
|
48
47
|
raise WealthForge::ApiException.new(e)
|
49
48
|
end
|
49
|
+
JSON.parse(response.body)
|
50
50
|
end
|
51
51
|
|
52
52
|
|
53
|
-
|
53
|
+
def self.connection
|
54
|
+
set_token
|
55
|
+
return Faraday.new(:url => @api_url) do |faraday|
|
56
|
+
faraday.request :url_encoded
|
57
|
+
faraday.headers['Authorization'] = @wf_token
|
58
|
+
faraday.adapter Faraday.default_adapter
|
59
|
+
faraday.use CustomErrors
|
60
|
+
end
|
61
|
+
end
|
54
62
|
|
55
63
|
|
56
|
-
def self.
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
64
|
+
def self.connection_multipart
|
65
|
+
set_token
|
66
|
+
return Faraday.new(:url => @api_url) do |faraday|
|
67
|
+
faraday.request :multipart
|
68
|
+
faraday.headers['Authorization'] = @wf_token
|
69
|
+
faraday.adapter Faraday.default_adapter
|
70
|
+
faraday.use CustomErrors
|
61
71
|
end
|
62
|
-
wf_params.to_json
|
63
72
|
end
|
64
73
|
|
65
74
|
|
66
|
-
def self.
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
75
|
+
def self.set_token
|
76
|
+
if @wf_token == nil
|
77
|
+
@wf_client_id = WealthForge.configuration.client_id
|
78
|
+
@wf_client_secret = WealthForge.configuration.client_secret
|
79
|
+
@api_url = WealthForge.configuration.api_url
|
80
|
+
@token_url = WealthForge.configuration.token_url
|
81
|
+
@wf_token = retrieve_token
|
73
82
|
end
|
83
|
+
|
84
|
+
# test to see if token has expired
|
85
|
+
t = @wf_token.reverse.chomp("Bearer ".reverse).reverse
|
86
|
+
decoded_token = JWT.decode t, nil, false
|
87
|
+
token_exp = decoded_token[0]['exp']
|
88
|
+
leeway = 60
|
89
|
+
now = Time.now.to_i
|
90
|
+
token_window = token_exp - leeway
|
91
|
+
refresh_token = !(token_window > now)
|
92
|
+
|
93
|
+
if refresh_token == true
|
94
|
+
# makes a call to get a new token
|
95
|
+
@wf_token = retrieve_token
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def self.retrieve_token
|
101
|
+
auth = Faraday.new.post(@token_url) do |faraday|
|
102
|
+
faraday.body = {
|
103
|
+
data: {
|
104
|
+
attributes: {
|
105
|
+
clientId: @wf_client_id,
|
106
|
+
clientSecret: @wf_client_secret
|
107
|
+
},
|
108
|
+
type: 'token'
|
109
|
+
}
|
110
|
+
}.to_json
|
111
|
+
end.body
|
112
|
+
@wf_token = 'Bearer ' + JSON.parse(auth)['data']['attributes']['accessToken']
|
74
113
|
end
|
114
|
+
end
|
75
115
|
|
76
116
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
}
|
85
|
-
if WealthForge.configuration.environment.eql? 'production'
|
86
|
-
ssl_options[:ca_file] = ENV['CA_FILE']
|
117
|
+
class CustomErrors < Faraday::Response::RaiseError
|
118
|
+
|
119
|
+
def on_complete(env)
|
120
|
+
case env[:status]
|
121
|
+
when 400...600
|
122
|
+
json_body = JSON.parse(env[:body])
|
123
|
+
return json_body
|
87
124
|
else
|
88
|
-
|
125
|
+
super
|
89
126
|
end
|
90
|
-
ssl_options
|
91
127
|
end
|
92
128
|
|
93
129
|
end
|
130
|
+
|
@@ -1,90 +1,15 @@
|
|
1
|
-
require 'base64'
|
2
|
-
require 'mime/types'
|
3
|
-
|
4
1
|
class WealthForge::Investment
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def self.create(params)
|
12
|
-
WealthForge::Connection.post "investment", params
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
def self.get(investment_id)
|
17
|
-
WealthForge::Connection.get "investment/#{investment_id}", nil
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
def self.update(investment_id, params)
|
22
|
-
WealthForge::Connection.put "investment/#{investment_id}", params
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
def self.redirect_url(investment_id)
|
27
|
-
WealthForge::Connection.get "investment/#{investment_id}/start", nil
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def self.status(investment_id)
|
32
|
-
WealthForge::Connection.get "investment/#{investment_id}/status", nil
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
def self.account(investment_id)
|
37
|
-
WealthForge::Connection.get "investment/#{investment_id}/account", nil
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
def self.update_account(investment_id, params)
|
42
|
-
WealthForge::Connection.put "investment/#{investment_id}/account", params
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def self.approve(investment_id)
|
47
|
-
WealthForge::Connection.put "investment/#{investment_id}/approve", nil
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
def self.approve_subscription(investment_id)
|
52
|
-
WealthForge::Connection.put "investment/#{investment_id}/approveSubscriptionAgreement", nil
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
def self.certificate(investment_id)
|
57
|
-
WealthForge::Connection.get "investment/#{investment_id}/certificate", nil, true
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
def self.due_diligence(investment_id)
|
62
|
-
WealthForge::Connection.get "investment/#{investment_id}/duediligence", nil
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
def self.subscription_agreement(investment_id)
|
67
|
-
WealthForge::Connection.get "investment/#{investment_id}/subscriptionAgreement", nil
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def self.create_subscription_agreement(investment_id, params)
|
72
|
-
mapped_params = {
|
73
|
-
status: {code: 'FILE_INPROGRESS', active: true},
|
74
|
-
mimeType: MIME::Types.type_for(params[:filename]).first.to_s,
|
75
|
-
folder: {parentFolder: {code: 'DUE_DILIGENCE'}},
|
76
|
-
fileName: params[:filename],
|
77
|
-
displayTitle: params[:filename],
|
78
|
-
content: Base64.strict_encode64(params[:file]),
|
79
|
-
parent: params[:parent]
|
80
|
-
}
|
81
|
-
WealthForge::Connection.put "investment/#{investment_id}/subscriptionAgreement", mapped_params
|
82
|
-
end
|
83
|
-
|
3
|
+
def self.create(params = {})
|
4
|
+
WealthForge::Connection.post 'subscriptions', params
|
5
|
+
end
|
84
6
|
|
85
|
-
|
86
|
-
|
87
|
-
|
7
|
+
def self.get(subscription_id)
|
8
|
+
WealthForge::Connection.get "subscriptions/#{subscription_id}", nil
|
9
|
+
end
|
88
10
|
|
11
|
+
def self.file_upload(file_path, mime_type, filename, subscription_id)
|
12
|
+
WealthForge::Connection.file_upload "files/#{subscription_id}", file_path, filename, mime_type
|
13
|
+
end
|
89
14
|
|
90
15
|
end
|
data/lib/wealthforge/issuer.rb
CHANGED
@@ -1,35 +1,7 @@
|
|
1
|
-
|
2
1
|
class WealthForge::Issuer
|
3
2
|
|
4
|
-
def self.
|
5
|
-
WealthForge::Connection.
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.create(params = {})
|
9
|
-
params[:country] = {code: params[:country]}
|
10
|
-
params[:state_of_formation] = {code: params[:state_of_formation]}
|
11
|
-
params[:entity_type] = {code: params[:entity_type]}
|
12
|
-
WealthForge::Connection.post "issuer", params
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.get(issuer_id)
|
16
|
-
WealthForge::Connection.get "issuer/#{issuer_id}", nil
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.update(params = {}, issuer_id)
|
20
|
-
WealthForge::Connection.post "issuer/#{issuer_id}", params
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.accounts(issuer_id)
|
24
|
-
WealthForge::Connection.get "issuer/#{issuer_id}/accounts", nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.create_account(params = {}, issuer_id)
|
28
|
-
WealthForge::Connection.post "issuer/#{issuer_id}/accounts", params
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.update_account(params, issuer_id, account_id)
|
32
|
-
WealthForge::Connection.put "issuer/#{issuer_id}/accounts/#{account_id}", params
|
3
|
+
def self.create(params)
|
4
|
+
WealthForge::Connection.post 'issuers', params
|
33
5
|
end
|
34
6
|
|
35
|
-
end
|
7
|
+
end
|