svbclient 1.0.2 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/svbclient.rb +325 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28bcbda2d8863c0d081c969715c8019f20ab2c0e
|
4
|
+
data.tar.gz: a2a0f99f9e42c2d3e6121b897dcde768b28dfbc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a065ff86fbc9e0b877a489b93d160a6f4ed76519c82808d3e623bffe71589cdd1a7e196331616e7e4dd2b310dad37fceca336a4a02d9f966be41d110500e8fa5
|
7
|
+
data.tar.gz: 7b7218fe93eb95147699d0a00be8b411878f57223f0c041a757b2cf22002ef4a283106b1384c9d6b565cc9bd770d86c0c712baf115878cb036b5396bbd114b4a
|
data/lib/svbclient.rb
CHANGED
@@ -63,13 +63,15 @@ class SVBClient
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def patch(path, jsonbody)
|
66
|
-
|
67
|
-
|
66
|
+
jsonbody = { data: jsonbody } unless jsonbody.key? 'data'
|
67
|
+
hs = headers('PATCH', path, '', jsonbody.to_json)
|
68
|
+
RestClient.patch(@BASE_URL + path, jsonbody.to_json, headers=hs)
|
68
69
|
end
|
69
70
|
|
70
71
|
def post(path, jsonbody)
|
71
|
-
|
72
|
-
|
72
|
+
jsonbody = { data: jsonbody } unless jsonbody.key? 'data'
|
73
|
+
hs = headers('POST', path, '', jsonbody.to_json)
|
74
|
+
RestClient.post(@BASE_URL + path, jsonbody.to_json, headers=hs)
|
73
75
|
end
|
74
76
|
|
75
77
|
def upload(path, filesrc, mimetype)
|
@@ -82,3 +84,322 @@ class SVBClient
|
|
82
84
|
RestClient.post(@BASE_URL + path, { :file => filesrc, :multipart => true, 'Content-Type': mimetype }, headers=hs)
|
83
85
|
end
|
84
86
|
end
|
87
|
+
|
88
|
+
class SVBClient::Onboarding
|
89
|
+
def initialize(client)
|
90
|
+
raise 'provide an API client' if client.nil?
|
91
|
+
@client = client
|
92
|
+
end
|
93
|
+
|
94
|
+
def address(id: nil, street_line1: nil, street_line2: nil, street_line3: nil, city: nil, state: nil, postal_code: nil, country: nil)
|
95
|
+
if id.nil?
|
96
|
+
# generate this address
|
97
|
+
add = @client.post('/v1/addresses', {
|
98
|
+
street_line1: street_line1,
|
99
|
+
street_line2: street_line2,
|
100
|
+
street_line3: street_line3,
|
101
|
+
city: city,
|
102
|
+
state: state,
|
103
|
+
postal_code: postal_code,
|
104
|
+
country: country
|
105
|
+
})
|
106
|
+
body = JSON.parse(add.body)
|
107
|
+
SVBClient::Onboarding::Address.new(@client, body["data"]["id"])
|
108
|
+
else
|
109
|
+
# verify that the address exists
|
110
|
+
@client.get("/v1/addresses/#{id}")
|
111
|
+
SVBClient::Onboarding::Address.new(@client, id)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def company(id: nil, description: nil, document_ids: [], email_address: nil, incorporation_address_id: -1,
|
116
|
+
mailing_address_id: -1, metadata: nil, mcc: -1, name: nil, options: nil, parent_company_id: -1, person_ids: [],
|
117
|
+
phone_number: nil, physical_address_id: -1, product_description: nil, products: [], referral_source: nil,
|
118
|
+
risk_commentary: nil, source_of_funds: nil, state: nil, website_url: nil,
|
119
|
+
documents: nil, incorporation_address: nil, mailing_address: nil, parent_company: nil,
|
120
|
+
persons: nil, physical_address: nil)
|
121
|
+
|
122
|
+
if id.nil?
|
123
|
+
# generate this address
|
124
|
+
|
125
|
+
unless documents.nil?
|
126
|
+
document_ids = documents.map do |document|
|
127
|
+
document.id
|
128
|
+
end
|
129
|
+
end
|
130
|
+
unless persons.nil?
|
131
|
+
person_ids = persons.map do |person|
|
132
|
+
person.id
|
133
|
+
end
|
134
|
+
end
|
135
|
+
incorporation_address_id = incorporation_address.id unless incorporation_address.nil?
|
136
|
+
mailing_address_id = mailing_address.id unless mailing_address.nil?
|
137
|
+
physical_address_id = physical_address.id unless physical_address.nil?
|
138
|
+
parent_company_id = parent_company.id unless parent_company.nil?
|
139
|
+
|
140
|
+
resource = @client.post('/v1/companies', {
|
141
|
+
description: description,
|
142
|
+
document_ids: document_ids,
|
143
|
+
email_address: email_address,
|
144
|
+
incorporation_address_id: incorporation_address_id,
|
145
|
+
mailing_address_id: mailing_address_id,
|
146
|
+
metadata: metadata,
|
147
|
+
mcc: mcc,
|
148
|
+
name: name,
|
149
|
+
options: options,
|
150
|
+
parent_company_id: parent_company_id,
|
151
|
+
person_ids: person_ids,
|
152
|
+
phone_number: phone_number,
|
153
|
+
physical_address_id: physical_address_id,
|
154
|
+
product_description: product_description,
|
155
|
+
products: products,
|
156
|
+
referral_source: referral_source,
|
157
|
+
risk_commentary: risk_commentary,
|
158
|
+
source_of_funds: source_of_funds,
|
159
|
+
state: state,
|
160
|
+
website_url: website_url
|
161
|
+
})
|
162
|
+
body = JSON.parse(resource.body)
|
163
|
+
SVBClient::Onboarding::Company.new(@client, body["data"]["id"])
|
164
|
+
else
|
165
|
+
# verify that the resource exists
|
166
|
+
@client.get("/v1/companies/#{id}")
|
167
|
+
SVBClient::Onboarding::Company.new(@client, id)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def document(id: nil, document_type: nil, file_id: -1, metadata: nil, number: nil, file: nil)
|
172
|
+
|
173
|
+
if id.nil?
|
174
|
+
# generate this address
|
175
|
+
file_id = file.id unless file.nil?
|
176
|
+
|
177
|
+
resource = @client.post('/v1/documents', {
|
178
|
+
document_type: document_type,
|
179
|
+
file_id: file_id,
|
180
|
+
metadata: metadata,
|
181
|
+
number: number
|
182
|
+
})
|
183
|
+
body = JSON.parse(resource.body)
|
184
|
+
SVBClient::Onboarding::Document.new(@client, body["data"]["id"])
|
185
|
+
else
|
186
|
+
# verify that the resource exists
|
187
|
+
@client.get("/v1/documents/#{id}")
|
188
|
+
SVBClient::Onboarding::Document.new(@client, id)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def file(id: nil, file: nil, metadata: nil, mimetype: nil)
|
193
|
+
if id.nil?
|
194
|
+
# upload this file
|
195
|
+
resource = @client.upload("/v1/files", file, mimetype)
|
196
|
+
else
|
197
|
+
# verify that the resource exists
|
198
|
+
@client.get("/v1/files/#{id}")
|
199
|
+
SVBClient::Onboarding::File.new(@client, id)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def gov_ident(id: nil, country: nil, document_type: nil, expires_on: nil, file_id: -1,
|
204
|
+
first_name: nil, last_name: nil, middle_name: nil, number: nil, file: nil)
|
205
|
+
|
206
|
+
if id.nil?
|
207
|
+
# generate this address
|
208
|
+
file_id = file.id unless file.nil?
|
209
|
+
|
210
|
+
resource = @client.post('/v1/gov_idents', {
|
211
|
+
country: country,
|
212
|
+
document_type: document_type,
|
213
|
+
expires_on: expires_on,
|
214
|
+
file_id: file_id,
|
215
|
+
first_name: first_name,
|
216
|
+
last_name: last_name,
|
217
|
+
middle_name: middle_name,
|
218
|
+
number: number
|
219
|
+
})
|
220
|
+
body = JSON.parse(resource.body)
|
221
|
+
SVBClient::Onboarding::GovIdent.new(@client, body["data"]["id"])
|
222
|
+
else
|
223
|
+
# verify that the resource exists
|
224
|
+
@client.get("/v1/gov_idents/#{id}")
|
225
|
+
SVBClient::Onboarding::GovIdent.new(@client, id)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def login(id: nil, login_name: nil, reservation_expires: nil)
|
230
|
+
if id.nil?
|
231
|
+
# generate this address
|
232
|
+
resource = @client.post('/v1/logins', {
|
233
|
+
login_name: login_name,
|
234
|
+
reservation_expires: reservation_expires
|
235
|
+
})
|
236
|
+
body = JSON.parse(resource.body)
|
237
|
+
SVBClient::Onboarding::Login.new(@client, body["data"]["id"])
|
238
|
+
else
|
239
|
+
# verify that the resource exists
|
240
|
+
@client.get("/v1/logins/#{id}")
|
241
|
+
SVBClient::Onboarding::Login.new(@client, id)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def parent_company(id: nil, address_id: -1, address: nil, country: nil, description: nil,
|
246
|
+
name: nil, metadata: nil, percent_ownership: -1, source_of_funds: nil)
|
247
|
+
|
248
|
+
if id.nil?
|
249
|
+
# generate this address
|
250
|
+
address_id = address.id unless address.nil?
|
251
|
+
|
252
|
+
resource = @client.post('/v1/parent_companies', {
|
253
|
+
address_id: address_id,
|
254
|
+
country: country,
|
255
|
+
description: description,
|
256
|
+
name: name,
|
257
|
+
metadata: metadata,
|
258
|
+
percent_ownership: percent_ownership,
|
259
|
+
source_of_funds: source_of_funds
|
260
|
+
})
|
261
|
+
body = JSON.parse(resource.body)
|
262
|
+
SVBClient::Onboarding::ParentCompany.new(@client, body["data"]["id"])
|
263
|
+
else
|
264
|
+
# verify that the resource exists
|
265
|
+
@client.get("/v1/parent_companies/#{id}")
|
266
|
+
SVBClient::Onboarding::ParentCompany.new(@client, id)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def person(id: nil, address_id: -1, address: nil, date_of_birth: nil, email_address: nil,
|
271
|
+
first_name: nil, gov_idents: [], gov_ident_ids: [], last_name: nil, login_id: -1, login: nil,
|
272
|
+
metadata: nil, middle_name: nil, percent_ownership: -1, phone_number: nil, risk_commentary: nil,
|
273
|
+
roles: [], title: nil)
|
274
|
+
|
275
|
+
if id.nil?
|
276
|
+
# generate this address
|
277
|
+
unless gov_idents.nil?
|
278
|
+
gov_ident_ids = gov_idents.map do |gov_ident|
|
279
|
+
gov_ident.id
|
280
|
+
end
|
281
|
+
end
|
282
|
+
address_id = address.id unless address.nil?
|
283
|
+
login_id = login.id unless login.nil?
|
284
|
+
|
285
|
+
resource = @client.post('/v1/persons', {
|
286
|
+
address_id: address_id,
|
287
|
+
date_of_birth: date_of_birth,
|
288
|
+
email_address: email_address,
|
289
|
+
first_name: first_name,
|
290
|
+
gov_ident_ids: gov_ident_ids,
|
291
|
+
last_name: last_name,
|
292
|
+
login_id: login_id,
|
293
|
+
metadata: metadata,
|
294
|
+
middle_name: middle_name,
|
295
|
+
percent_ownership: percent_ownership,
|
296
|
+
phone_number: phone_number,
|
297
|
+
risk_commentary: risk_commentary,
|
298
|
+
roles: roles,
|
299
|
+
title: title
|
300
|
+
})
|
301
|
+
body = JSON.parse(resource.body)
|
302
|
+
SVBClient::Onboarding::Person.new(@client, body["data"]["id"])
|
303
|
+
else
|
304
|
+
# verify that the resource exists
|
305
|
+
@client.get("/v1/persons/#{id}")
|
306
|
+
SVBClient::Onboarding::Person.new(@client, id)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
class SVBClient::Onboarding::Resource
|
312
|
+
def initialize(client, id)
|
313
|
+
@client = client
|
314
|
+
@id = id
|
315
|
+
@type = 'thing'
|
316
|
+
end
|
317
|
+
|
318
|
+
def id
|
319
|
+
@id
|
320
|
+
end
|
321
|
+
|
322
|
+
def data
|
323
|
+
JSON.parse(@client.get("/v1/#{@type}/#{@id}").body)["data"]
|
324
|
+
end
|
325
|
+
|
326
|
+
def update(jsonbody)
|
327
|
+
@client.patch("/v1/#{@type}/#{@id}", jsonbody)
|
328
|
+
end
|
329
|
+
|
330
|
+
def delete
|
331
|
+
@client.delete("/v1/#{@type}/#{@id}")
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
class SVBClient::Onboarding::Address < SVBClient::Onboarding::Resource
|
336
|
+
def initialize(client, id)
|
337
|
+
@client = client
|
338
|
+
@id = id
|
339
|
+
@type = 'addresses'
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
class SVBClient::Onboarding::Company < SVBClient::Onboarding::Resource
|
344
|
+
def initialize(client, id)
|
345
|
+
@client = client
|
346
|
+
@id = id
|
347
|
+
@type = 'companies'
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
class SVBClient::Onboarding::Document < SVBClient::Onboarding::Resource
|
352
|
+
def initialize(client, id)
|
353
|
+
@client = client
|
354
|
+
@id = id
|
355
|
+
@type = 'documents'
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
class SVBClient::Onboarding::File < SVBClient::Onboarding::Resource
|
360
|
+
def initialize(client, id)
|
361
|
+
@client = client
|
362
|
+
@id = id
|
363
|
+
@type = 'files'
|
364
|
+
end
|
365
|
+
|
366
|
+
def update
|
367
|
+
raise 'unsupported'
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
class SVBClient::Onboarding::GovIdent < SVBClient::Onboarding::Resource
|
372
|
+
def initialize(client, id)
|
373
|
+
@client = client
|
374
|
+
@id = id
|
375
|
+
@type = 'gov_idents'
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
class SVBClient::Onboarding::Login < SVBClient::Onboarding::Resource
|
380
|
+
def initialize(client, id)
|
381
|
+
@client = client
|
382
|
+
@id = id
|
383
|
+
@type = 'logins'
|
384
|
+
end
|
385
|
+
|
386
|
+
def update
|
387
|
+
raise 'unsupported'
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
class SVBClient::Onboarding::ParentCompany < SVBClient::Onboarding::Resource
|
392
|
+
def initialize(client, id)
|
393
|
+
@client = client
|
394
|
+
@id = id
|
395
|
+
@type = 'parent_companies'
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
class SVBClient::Onboarding::Person < SVBClient::Onboarding::Resource
|
400
|
+
def initialize(client, id)
|
401
|
+
@client = client
|
402
|
+
@id = id
|
403
|
+
@type = 'persons'
|
404
|
+
end
|
405
|
+
end
|