wealthforge-ruby 2.2.9 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b531b0ecb28d082fd17c60e19e226f587003b832
4
- data.tar.gz: 3b06336df63f8a4a9bbebb1f74f2fff3e45a46a6
2
+ SHA256:
3
+ metadata.gz: 8bcfa86ac35e188d2834c1206657a9d9e3b28748ccfaca41e8b83f1f29b0779d
4
+ data.tar.gz: e09c9f8a8d7a1db4df56011ab37679a0bcf2d5a5e81b7c5b69d4e439c0bde0d1
5
5
  SHA512:
6
- metadata.gz: 2720af1510a893dc82577ccd6de6bd4955c0f772cfaa0740f9dac5fac7bd34b85a249d3cd84bad87d24d243df9b4ba3c39c4169244eb430daf68d6a526857b25
7
- data.tar.gz: f0595c97c1cc9327967befe00ad58a6fe06a2efb06555a5830044f27fa888fa1688c223e02f776d75d6018d7e95f46b4e19db64ab97bcdafb2f620f881d2e946
6
+ metadata.gz: 97d0f84ddb88d3716ddb4475e9a5f60f16fecac6341e5f5a055bbf5d38b4c80e014ded3c386e1070e3f06ed02479f1a85bcfd45c308abb556a0ba01fe21adafd
7
+ data.tar.gz: adb43e7d8c489746bd40a2983b6d852217a5331740b81e9ba90a33822a779f1d7e0814318cf70ec32699ec55b2c799dea825b1e1721d4386cccbdde41b4ca5ef
data/README.md CHANGED
@@ -24,13 +24,13 @@ Or install it yourself as:
24
24
 
25
25
  Before you can use this gem, you'll need to configure it with the key and cert, which you'll have after registering with WealthForge. If using with Rails, put this code in the initializer.
26
26
 
27
-
28
- WealthForge.configure do |config|
29
- config.client_secret = ENV['WF_CLIENT_SECRET']
30
- config.client_id = ENV['WF_CLIENT_ID']
31
- config.environment = 'development'
32
- end
33
-
27
+ ```ruby
28
+ WealthForge.configure do |config|
29
+ config.client_secret = ENV['WF_CLIENT_SECRET']
30
+ config.client_id = ENV['WF_CLIENT_ID']
31
+ config.environment = 'development'
32
+ end
33
+ ```
34
34
 
35
35
  ## Usage
36
36
 
@@ -41,18 +41,23 @@ Please refer to the official WealthForge API [documentation](https://wealthforge
41
41
 
42
42
  #### Investment
43
43
 
44
- WealthForge::Investment.create params
45
- WealthForge::Investment.get investment_id
46
- WealthForge::Investment.file_upload path, mime_type, title, subscription_id
44
+ ```ruby
45
+ WealthForge::Investment.create params
46
+ WealthForge::Investment.get investment_id
47
+ WealthForge::Investment.file_upload path, mime_type, title, subscription_id
48
+ ```
47
49
 
48
50
  #### Issuer
49
51
 
50
- WealthForge::Issuer.create params
52
+ ```ruby
53
+ WealthForge::Issuer.create params
54
+ ```
51
55
 
52
56
  #### Offering
53
57
 
54
- WealthForge::Offering.create params
55
-
58
+ ```ruby
59
+ WealthForge::Offering.create params
60
+ ```
56
61
 
57
62
  ## Contributing
58
63
 
@@ -1,12 +1,11 @@
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'
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"
7
7
 
8
8
  module WealthForge
9
-
10
9
  class << self
11
10
  attr_accessor :configuration
12
11
  end
@@ -21,8 +20,7 @@ module WealthForge
21
20
 
22
21
  def self.configure
23
22
  yield(configuration)
24
- configuration.api_url = configuration.environment == 'production' ? configuration.production_url : configuration.sandbox_url
23
+ configuration.api_url = configuration.environment == "production" ? configuration.production_url : configuration.sandbox_url
25
24
  configuration.token_url = "#{configuration.api_url}/auth/tokens"
26
25
  end
27
-
28
26
  end
@@ -1,7 +1,5 @@
1
1
  module WealthForge
2
-
3
2
  class Configuration
4
-
5
3
  attr_accessor :client_id
6
4
  attr_accessor :client_secret
7
5
  attr_accessor :environment
@@ -12,16 +10,14 @@ module WealthForge
12
10
  attr_accessor :sandbox_url
13
11
 
14
12
  def initialize
15
- @client_id = nil
16
- @client_secret = nil
17
- @environment = nil
18
- @api_url = nil
19
- @token_url = nil
20
- @production_url = 'https://api.wealthforge.com/v1'
21
- @sandbox_url = 'https://api.wealthforge.org/v1'
22
- @version = 'v1'
13
+ @client_id = nil
14
+ @client_secret = nil
15
+ @environment = nil
16
+ @api_url = nil
17
+ @token_url = nil
18
+ @production_url = "https://api.wealthforge.com/v1"
19
+ @sandbox_url = "https://api.wealthforge.org/v1"
20
+ @version = "v1"
23
21
  end
24
-
25
22
  end
26
-
27
23
  end
@@ -1,32 +1,30 @@
1
- require 'openssl'
2
- require 'faraday'
3
- require 'json'
4
- require 'csv'
5
- require 'timeout'
6
- require 'resolv-replace'
7
- require 'jwt'
1
+ require "openssl"
2
+ require "faraday"
3
+ require "json"
4
+ require "csv"
5
+ require "timeout"
6
+ require "resolv-replace"
7
+ require "jwt"
8
8
 
9
9
  class WealthForge::Connection
10
-
11
10
  def self.post(endpoint, params)
12
11
  begin
13
12
  response = connection.post do |req|
14
13
  req.url endpoint
15
- req.headers['Content-Type'] = 'application/json'
14
+ req.headers["Content-Type"] = "application/json"
16
15
  req.body = params.to_json
17
- end
16
+ end
18
17
  rescue => e
19
18
  raise WealthForge::ApiException.new(e)
20
19
  end
21
20
  JSON.parse(response.body)
22
21
  end
23
22
 
24
-
25
23
  def self.get(endpoint, params)
26
24
  begin
27
25
  response = connection.get do |req|
28
26
  req.url endpoint
29
- req.headers['Content-Type'] = 'application/json'
27
+ req.headers["Content-Type"] = "application/json"
30
28
  req.body = params.to_json
31
29
  end
32
30
  rescue => e
@@ -35,23 +33,21 @@ class WealthForge::Connection
35
33
  JSON.parse(response.body)
36
34
  end
37
35
 
38
-
39
36
  def self.patch(endpoint, params)
40
37
  begin
41
38
  response = connection.patch do |req|
42
39
  req.url endpoint
43
- req.headers['Content-Type'] = 'application/json'
40
+ req.headers["Content-Type"] = "application/json"
44
41
  req.body = params.to_json
45
42
  end
46
43
  rescue => e
47
44
  raise WealthForge::ApiException.new(e)
48
45
  end
49
46
  response.body
50
- end
51
-
47
+ end
52
48
 
53
- def self.file_upload (endpoint, file, filename, mime_type)
54
- payload = {:file => Faraday::UploadIO.new(file, mime_type, filename)}
49
+ def self.file_upload(endpoint, file, filename, mime_type)
50
+ payload = {file: Faraday::UploadIO.new(file, mime_type, filename)}
55
51
  begin
56
52
  response = connection_multipart.post do |req|
57
53
  req.url endpoint
@@ -63,55 +59,51 @@ class WealthForge::Connection
63
59
  JSON.parse(response.body)
64
60
  end
65
61
 
66
-
67
62
  def self.connection
68
63
  set_token
69
- return Faraday.new(:url => @api_url) do |faraday|
64
+ Faraday.new(url: @api_url) do |faraday|
70
65
  faraday.request :url_encoded
71
66
  faraday.options.timeout = 5
72
67
  faraday.options.open_timeout = 5
73
- faraday.headers['Authorization'] = @wf_token
68
+ faraday.headers["Authorization"] = @wf_token
74
69
  faraday.use CustomErrors
75
70
  faraday.adapter Faraday.default_adapter
76
71
  end
77
72
  end
78
73
 
79
-
80
74
  def self.connection_multipart
81
75
  set_token
82
- return Faraday.new(:url => @api_url) do |faraday|
76
+ Faraday.new(url: @api_url) do |faraday|
83
77
  faraday.request :multipart
84
- faraday.headers['Authorization'] = @wf_token
78
+ faraday.headers["Authorization"] = @wf_token
85
79
  faraday.use CustomErrors
86
80
  faraday.adapter Faraday.default_adapter
87
81
  end
88
82
  end
89
83
 
90
-
91
- def self.set_token
92
- if @wf_token == nil
93
- @wf_client_id = WealthForge.configuration.client_id
84
+ def self.set_token
85
+ if @wf_token.nil?
86
+ @wf_client_id = WealthForge.configuration.client_id
94
87
  @wf_client_secret = WealthForge.configuration.client_secret
95
- @api_url = WealthForge.configuration.api_url
96
- @token_url = WealthForge.configuration.token_url
97
- @wf_token = retrieve_token
88
+ @api_url = WealthForge.configuration.api_url
89
+ @token_url = WealthForge.configuration.token_url
90
+ @wf_token = retrieve_token
98
91
  end
99
92
 
100
93
  # test to see if token has expired
101
94
  t = @wf_token.reverse.chomp("Bearer ".reverse).reverse
102
95
  decoded_token = JWT.decode t, nil, false
103
- token_exp = decoded_token[0]['exp']
96
+ token_exp = decoded_token[0]["exp"]
104
97
  leeway = 60
105
- now = Time.now.to_i
106
- token_window = token_exp - leeway
98
+ now = Time.now.to_i
99
+ token_window = token_exp - leeway
107
100
  refresh_token = !(token_window > now)
108
-
101
+
109
102
  if refresh_token == true
110
- # makes a call to get a new token
103
+ # makes a call to get a new token
111
104
  @wf_token = retrieve_token
112
- end
113
- end
114
-
105
+ end
106
+ end
115
107
 
116
108
  def self.retrieve_token
117
109
  auth = Faraday.new.post(@token_url) do |faraday|
@@ -121,26 +113,21 @@ class WealthForge::Connection
121
113
  clientId: @wf_client_id,
122
114
  clientSecret: @wf_client_secret
123
115
  },
124
- type: 'token'
116
+ type: "token"
125
117
  }
126
118
  }.to_json
127
119
  end.body
128
- @wf_token = 'Bearer ' + JSON.parse(auth)['data']['attributes']['accessToken']
120
+ @wf_token = "Bearer " + JSON.parse(auth)["data"]["attributes"]["accessToken"]
129
121
  end
130
122
  end
131
123
 
132
-
133
124
  class CustomErrors < Faraday::Response::RaiseError
134
-
135
125
  def on_complete(env)
136
126
  case env[:status]
137
127
  when 400...600
138
- json_body = JSON.parse(env[:body])
139
- return json_body
128
+ JSON.parse(env[:body])
140
129
  else
141
130
  super
142
131
  end
143
132
  end
144
-
145
133
  end
146
-
@@ -1,19 +1,17 @@
1
1
  class WealthForge::Investment
2
+ def self.create(params = {})
3
+ WealthForge::Connection.post "subscriptions", params
4
+ end
2
5
 
3
- def self.create(params = {})
4
- WealthForge::Connection.post 'subscriptions', params
5
- end
6
+ def self.get(subscription_id)
7
+ WealthForge::Connection.get "subscriptions/#{subscription_id}", nil
8
+ end
6
9
 
7
- def self.get(subscription_id)
8
- WealthForge::Connection.get "subscriptions/#{subscription_id}", nil
9
- end
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
14
-
15
- def self.cancel_subscription(subscription_id)
16
- WealthForge::Connection.patch "subscriptions/#{subscription_id}/status/SPONSOR_CANCELLED", nil
17
- end
10
+ def self.file_upload(file_path, mime_type, filename, subscription_id)
11
+ WealthForge::Connection.file_upload "files/#{subscription_id}", file_path, filename, mime_type
12
+ end
18
13
 
14
+ def self.cancel_subscription(subscription_id)
15
+ WealthForge::Connection.patch "subscriptions/#{subscription_id}/status/SPONSOR_CANCELLED", nil
16
+ end
19
17
  end
@@ -1,7 +1,5 @@
1
1
  class WealthForge::Issuer
2
-
3
2
  def self.create(params)
4
- WealthForge::Connection.post 'issuers', params
3
+ WealthForge::Connection.post "issuers", params
5
4
  end
6
-
7
- end
5
+ end
@@ -1,11 +1,9 @@
1
1
  class WealthForge::Offering
2
-
3
2
  def self.create(params)
4
- WealthForge::Connection.post 'offerings', params
3
+ WealthForge::Connection.post "offerings", params
5
4
  end
6
5
 
7
6
  def self.get(offering_id)
8
7
  WealthForge::Connection.get "offerings/#{offering_id}", nil
9
8
  end
10
-
11
9
  end
@@ -1,3 +1,3 @@
1
1
  module WealthForge
2
- VERSION = '2.2.9'
2
+ VERSION = "2.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wealthforge-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.9
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Simone | dinosimone.com
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-14 00:00:00.000000000 Z
11
+ date: 2021-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,112 +16,176 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.14.0
19
+ version: '1.5'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.5.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: 0.14.0
29
+ version: '1.5'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.5.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: mime-types
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '3.1'
39
+ version: '3.3'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.3.1
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - "~>"
39
48
  - !ruby/object:Gem::Version
40
- version: '3.1'
49
+ version: '3.3'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.3.1
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: jwt
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
- - - '='
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '2.2'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.2.3
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2.2'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.2.3
73
+ - !ruby/object:Gem::Dependency
74
+ name: openssl
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '2.2'
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '2.2'
87
+ - !ruby/object:Gem::Dependency
88
+ name: json
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '2.5'
94
+ - - ">="
46
95
  - !ruby/object:Gem::Version
47
- version: 2.1.0
96
+ version: 2.5.1
48
97
  type: :runtime
49
98
  prerelease: false
50
99
  version_requirements: !ruby/object:Gem::Requirement
51
100
  requirements:
52
- - - '='
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.5'
104
+ - - ">="
53
105
  - !ruby/object:Gem::Version
54
- version: 2.1.0
106
+ version: 2.5.1
55
107
  - !ruby/object:Gem::Dependency
56
108
  name: rake
57
109
  requirement: !ruby/object:Gem::Requirement
58
110
  requirements:
59
111
  - - "~>"
60
112
  - !ruby/object:Gem::Version
61
- version: '10.0'
113
+ version: '13.0'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 13.0.6
62
117
  type: :development
63
118
  prerelease: false
64
119
  version_requirements: !ruby/object:Gem::Requirement
65
120
  requirements:
66
121
  - - "~>"
67
122
  - !ruby/object:Gem::Version
68
- version: '10.0'
123
+ version: '13.0'
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: 13.0.6
69
127
  - !ruby/object:Gem::Dependency
70
128
  name: rspec
71
129
  requirement: !ruby/object:Gem::Requirement
72
130
  requirements:
73
131
  - - "~>"
74
132
  - !ruby/object:Gem::Version
75
- version: '3.0'
133
+ version: '3.10'
76
134
  type: :development
77
135
  prerelease: false
78
136
  version_requirements: !ruby/object:Gem::Requirement
79
137
  requirements:
80
138
  - - "~>"
81
139
  - !ruby/object:Gem::Version
82
- version: '3.0'
140
+ version: '3.10'
83
141
  - !ruby/object:Gem::Dependency
84
142
  name: vcr
85
143
  requirement: !ruby/object:Gem::Requirement
86
144
  requirements:
87
145
  - - "~>"
88
146
  - !ruby/object:Gem::Version
89
- version: '3.0'
147
+ version: '6.0'
90
148
  type: :development
91
149
  prerelease: false
92
150
  version_requirements: !ruby/object:Gem::Requirement
93
151
  requirements:
94
152
  - - "~>"
95
153
  - !ruby/object:Gem::Version
96
- version: '3.0'
154
+ version: '6.0'
97
155
  - !ruby/object:Gem::Dependency
98
156
  name: webmock
99
157
  requirement: !ruby/object:Gem::Requirement
100
158
  requirements:
101
159
  - - "~>"
102
160
  - !ruby/object:Gem::Version
103
- version: '2.3'
161
+ version: '3.13'
104
162
  type: :development
105
163
  prerelease: false
106
164
  version_requirements: !ruby/object:Gem::Requirement
107
165
  requirements:
108
166
  - - "~>"
109
167
  - !ruby/object:Gem::Version
110
- version: '2.3'
168
+ version: '3.13'
111
169
  - !ruby/object:Gem::Dependency
112
- name: factory_girl
170
+ name: factory_bot
113
171
  requirement: !ruby/object:Gem::Requirement
114
172
  requirements:
115
173
  - - "~>"
116
174
  - !ruby/object:Gem::Version
117
- version: '4.0'
175
+ version: '4.8'
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: 4.8.2
118
179
  type: :development
119
180
  prerelease: false
120
181
  version_requirements: !ruby/object:Gem::Requirement
121
182
  requirements:
122
183
  - - "~>"
123
184
  - !ruby/object:Gem::Version
124
- version: '4.0'
185
+ version: '4.8'
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: 4.8.2
125
189
  description: The WealthForge API acts as a connection between WealthForge's back-end
126
190
  transaction engine, CapitalForge, and your front-end website.
127
191
  email:
@@ -148,7 +212,7 @@ homepage: https://github.com/dinosimone/wealthforge-ruby
148
212
  licenses:
149
213
  - MIT
150
214
  metadata: {}
151
- post_install_message:
215
+ post_install_message:
152
216
  rdoc_options: []
153
217
  require_paths:
154
218
  - lib
@@ -163,9 +227,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
227
  - !ruby/object:Gem::Version
164
228
  version: '0'
165
229
  requirements: []
166
- rubyforge_project:
167
- rubygems_version: 2.6.13
168
- signing_key:
230
+ rubygems_version: 3.0.3
231
+ signing_key:
169
232
  specification_version: 4
170
233
  summary: WealthForge API Client
171
234
  test_files: []