wealthforge-ruby 2.2.6 → 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: 659ffec61da1f314d37ee5a99d00bb302930a41a
4
- data.tar.gz: b411441c8d0680fb81f4dc1a6d297c1745d8499f
2
+ SHA256:
3
+ metadata.gz: 8bcfa86ac35e188d2834c1206657a9d9e3b28748ccfaca41e8b83f1f29b0779d
4
+ data.tar.gz: e09c9f8a8d7a1db4df56011ab37679a0bcf2d5a5e81b7c5b69d4e439c0bde0d1
5
5
  SHA512:
6
- metadata.gz: 9a5e7f186cce7f361e5472fc5f4684c4dd1bd3bfca083f1c5b6e0f330324632fe9164acd41c6adf802074b146b3e267ef71289623b305287771aa9365e501667
7
- data.tar.gz: 3fdc774a2ab6e412f825fc5ebf3d03cfb996ef2c45d5fda28123e5c2269c9a7b23d3d575489325bfb1f67a5ae93bf9f0cf8b5175e56298fb0dd61e998e47eaf7
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
- JSON.parse(response.body)
50
- end
51
-
46
+ response.body
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,53 +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
- faraday.headers['Authorization'] = @wf_token
72
- faraday.adapter Faraday.default_adapter
66
+ faraday.options.timeout = 5
67
+ faraday.options.open_timeout = 5
68
+ faraday.headers["Authorization"] = @wf_token
73
69
  faraday.use CustomErrors
70
+ faraday.adapter Faraday.default_adapter
74
71
  end
75
72
  end
76
73
 
77
-
78
74
  def self.connection_multipart
79
75
  set_token
80
- return Faraday.new(:url => @api_url) do |faraday|
76
+ Faraday.new(url: @api_url) do |faraday|
81
77
  faraday.request :multipart
82
- faraday.headers['Authorization'] = @wf_token
83
- faraday.adapter Faraday.default_adapter
78
+ faraday.headers["Authorization"] = @wf_token
84
79
  faraday.use CustomErrors
80
+ faraday.adapter Faraday.default_adapter
85
81
  end
86
82
  end
87
83
 
88
-
89
- def self.set_token
90
- if @wf_token == nil
91
- @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
92
87
  @wf_client_secret = WealthForge.configuration.client_secret
93
- @api_url = WealthForge.configuration.api_url
94
- @token_url = WealthForge.configuration.token_url
95
- @wf_token = retrieve_token
88
+ @api_url = WealthForge.configuration.api_url
89
+ @token_url = WealthForge.configuration.token_url
90
+ @wf_token = retrieve_token
96
91
  end
97
92
 
98
93
  # test to see if token has expired
99
94
  t = @wf_token.reverse.chomp("Bearer ".reverse).reverse
100
95
  decoded_token = JWT.decode t, nil, false
101
- token_exp = decoded_token[0]['exp']
96
+ token_exp = decoded_token[0]["exp"]
102
97
  leeway = 60
103
- now = Time.now.to_i
104
- token_window = token_exp - leeway
98
+ now = Time.now.to_i
99
+ token_window = token_exp - leeway
105
100
  refresh_token = !(token_window > now)
106
-
101
+
107
102
  if refresh_token == true
108
- # makes a call to get a new token
103
+ # makes a call to get a new token
109
104
  @wf_token = retrieve_token
110
- end
111
- end
112
-
105
+ end
106
+ end
113
107
 
114
108
  def self.retrieve_token
115
109
  auth = Faraday.new.post(@token_url) do |faraday|
@@ -119,26 +113,21 @@ class WealthForge::Connection
119
113
  clientId: @wf_client_id,
120
114
  clientSecret: @wf_client_secret
121
115
  },
122
- type: 'token'
116
+ type: "token"
123
117
  }
124
118
  }.to_json
125
119
  end.body
126
- @wf_token = 'Bearer ' + JSON.parse(auth)['data']['attributes']['accessToken']
120
+ @wf_token = "Bearer " + JSON.parse(auth)["data"]["attributes"]["accessToken"]
127
121
  end
128
122
  end
129
123
 
130
-
131
124
  class CustomErrors < Faraday::Response::RaiseError
132
-
133
125
  def on_complete(env)
134
126
  case env[:status]
135
127
  when 400...600
136
- json_body = JSON.parse(env[:body])
137
- return json_body
128
+ JSON.parse(env[:body])
138
129
  else
139
130
  super
140
131
  end
141
132
  end
142
-
143
133
  end
144
-
@@ -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.6'
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.6
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: 2018-09-10 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,126 +16,176 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.12.0.1
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.12.0.1
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
+ - - ">="
46
61
  - !ruby/object:Gem::Version
47
- version: 2.1.0
62
+ version: 2.2.3
48
63
  type: :runtime
49
64
  prerelease: false
50
65
  version_requirements: !ruby/object:Gem::Requirement
51
66
  requirements:
52
- - - '='
67
+ - - "~>"
53
68
  - !ruby/object:Gem::Version
54
- version: 2.1.0
69
+ version: '2.2'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.2.3
55
73
  - !ruby/object:Gem::Dependency
56
- name: bundler
74
+ name: openssl
57
75
  requirement: !ruby/object:Gem::Requirement
58
76
  requirements:
59
77
  - - "~>"
60
78
  - !ruby/object:Gem::Version
61
- version: '1.13'
62
- type: :development
79
+ version: '2.2'
80
+ type: :runtime
63
81
  prerelease: false
64
82
  version_requirements: !ruby/object:Gem::Requirement
65
83
  requirements:
66
84
  - - "~>"
67
85
  - !ruby/object:Gem::Version
68
- version: '1.13'
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
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.5.1
97
+ type: :runtime
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.5'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.5.1
69
107
  - !ruby/object:Gem::Dependency
70
108
  name: rake
71
109
  requirement: !ruby/object:Gem::Requirement
72
110
  requirements:
73
111
  - - "~>"
74
112
  - !ruby/object:Gem::Version
75
- version: '10.0'
113
+ version: '13.0'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 13.0.6
76
117
  type: :development
77
118
  prerelease: false
78
119
  version_requirements: !ruby/object:Gem::Requirement
79
120
  requirements:
80
121
  - - "~>"
81
122
  - !ruby/object:Gem::Version
82
- version: '10.0'
123
+ version: '13.0'
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: 13.0.6
83
127
  - !ruby/object:Gem::Dependency
84
128
  name: rspec
85
129
  requirement: !ruby/object:Gem::Requirement
86
130
  requirements:
87
131
  - - "~>"
88
132
  - !ruby/object:Gem::Version
89
- version: '3.0'
133
+ version: '3.10'
90
134
  type: :development
91
135
  prerelease: false
92
136
  version_requirements: !ruby/object:Gem::Requirement
93
137
  requirements:
94
138
  - - "~>"
95
139
  - !ruby/object:Gem::Version
96
- version: '3.0'
140
+ version: '3.10'
97
141
  - !ruby/object:Gem::Dependency
98
142
  name: vcr
99
143
  requirement: !ruby/object:Gem::Requirement
100
144
  requirements:
101
145
  - - "~>"
102
146
  - !ruby/object:Gem::Version
103
- version: '3.0'
147
+ version: '6.0'
104
148
  type: :development
105
149
  prerelease: false
106
150
  version_requirements: !ruby/object:Gem::Requirement
107
151
  requirements:
108
152
  - - "~>"
109
153
  - !ruby/object:Gem::Version
110
- version: '3.0'
154
+ version: '6.0'
111
155
  - !ruby/object:Gem::Dependency
112
156
  name: webmock
113
157
  requirement: !ruby/object:Gem::Requirement
114
158
  requirements:
115
159
  - - "~>"
116
160
  - !ruby/object:Gem::Version
117
- version: '2.3'
161
+ version: '3.13'
118
162
  type: :development
119
163
  prerelease: false
120
164
  version_requirements: !ruby/object:Gem::Requirement
121
165
  requirements:
122
166
  - - "~>"
123
167
  - !ruby/object:Gem::Version
124
- version: '2.3'
168
+ version: '3.13'
125
169
  - !ruby/object:Gem::Dependency
126
- name: factory_girl
170
+ name: factory_bot
127
171
  requirement: !ruby/object:Gem::Requirement
128
172
  requirements:
129
173
  - - "~>"
130
174
  - !ruby/object:Gem::Version
131
- version: '4.0'
175
+ version: '4.8'
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: 4.8.2
132
179
  type: :development
133
180
  prerelease: false
134
181
  version_requirements: !ruby/object:Gem::Requirement
135
182
  requirements:
136
183
  - - "~>"
137
184
  - !ruby/object:Gem::Version
138
- version: '4.0'
185
+ version: '4.8'
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: 4.8.2
139
189
  description: The WealthForge API acts as a connection between WealthForge's back-end
140
190
  transaction engine, CapitalForge, and your front-end website.
141
191
  email:
@@ -162,7 +212,7 @@ homepage: https://github.com/dinosimone/wealthforge-ruby
162
212
  licenses:
163
213
  - MIT
164
214
  metadata: {}
165
- post_install_message:
215
+ post_install_message:
166
216
  rdoc_options: []
167
217
  require_paths:
168
218
  - lib
@@ -177,9 +227,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
227
  - !ruby/object:Gem::Version
178
228
  version: '0'
179
229
  requirements: []
180
- rubyforge_project:
181
- rubygems_version: 2.6.13
182
- signing_key:
230
+ rubygems_version: 3.0.3
231
+ signing_key:
183
232
  specification_version: 4
184
233
  summary: WealthForge API Client
185
234
  test_files: []