Class: SVBClient::Onboarding

Inherits:
Object
  • Object
show all
Defined in:
lib/svbclient.rb

Defined Under Namespace

Classes: Address, Company, Document, File, GovIdent, Login, ParentCompany, Person, Resource

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Onboarding

Returns a new instance of Onboarding.



289
290
291
292
# File 'lib/svbclient.rb', line 289

def initialize(client)
  raise 'provide an API client' if client.nil?
  @client = client
end

Instance Method Details

#address(id: nil, street_line1: nil, street_line2: nil, street_line3: nil, city: nil, state: nil, postal_code: nil, country: nil) ⇒ Object



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/svbclient.rb', line 294

def address(id: nil, street_line1: nil, street_line2: nil, street_line3: nil, city: nil, state: nil, postal_code: nil, country: nil)
  if id.nil?
    # generate this address
    add = @client.post('/v1/addresses', {
      street_line1: street_line1,
      street_line2: street_line2,
      street_line3: street_line3,
      city: city,
      state: state,
      postal_code: postal_code,
      country: country
    })
    body = JSON.parse(add.body)
    SVBClient::Onboarding::Address.new(@client, body["data"]["id"])
  else
    # verify that the address exists
    @client.get("/v1/addresses/#{id}")
    SVBClient::Onboarding::Address.new(@client, id)
  end
end

#company(id: nil, description: nil, document_ids: [], email_address: nil, incorporation_address_id: -1,, mailing_address_id: -1,, metadata: nil, mcc: -1,, name: nil, options: nil, parent_company_id: -1,, person_ids: [], phone_number: nil, physical_address_id: -1,, product_description: nil, products: [], referral_source: nil, risk_commentary: nil, source_of_funds: nil, state: nil, website_url: nil, documents: nil, incorporation_address: nil, mailing_address: nil, parent_company: nil, persons: nil, physical_address: nil) ⇒ Object



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/svbclient.rb', line 315

def company(id: nil, description: nil, document_ids: [], email_address: nil, incorporation_address_id: -1,
  mailing_address_id: -1, metadata: nil, mcc: -1, name: nil, options: nil, parent_company_id: -1, person_ids: [],
  phone_number: nil, physical_address_id: -1, product_description: nil, products: [], referral_source: nil,
  risk_commentary: nil, source_of_funds: nil, state: nil, website_url: nil,
  documents: nil, incorporation_address: nil, mailing_address: nil, parent_company: nil,
  persons: nil, physical_address: nil)

  if id.nil?
    # generate this address

    unless documents.nil?
      document_ids = documents.map do |document|
        document.id
      end
    end
    unless persons.nil?
      person_ids = persons.map do |person|
        person.id
      end
    end
    incorporation_address_id = incorporation_address.id unless incorporation_address.nil?
    mailing_address_id = mailing_address.id unless mailing_address.nil?
    physical_address_id = physical_address.id unless physical_address.nil?
    parent_company_id = parent_company.id unless parent_company.nil?

    resource = @client.post('/v1/companies', {
      description: description,
      document_ids: document_ids,
      email_address: email_address,
      incorporation_address_id: incorporation_address_id,
      mailing_address_id: mailing_address_id,
      metadata: ,
      mcc: mcc,
      name: name,
      options: options,
      parent_company_id: parent_company_id,
      person_ids: person_ids,
      phone_number: phone_number,
      physical_address_id: physical_address_id,
      product_description: product_description,
      products: products,
      referral_source: referral_source,
      risk_commentary: risk_commentary,
      source_of_funds: source_of_funds,
      state: state,
      website_url: website_url
    })
    body = JSON.parse(resource.body)
    SVBClient::Onboarding::Company.new(@client, body["data"]["id"])
  else
    # verify that the resource exists
    @client.get("/v1/companies/#{id}")
    SVBClient::Onboarding::Company.new(@client, id)
  end
end

#document(id: nil, document_type: nil, file_id: -1,, metadata: nil, number: nil, file: nil) ⇒ Object



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/svbclient.rb', line 371

def document(id: nil, document_type: nil, file_id: -1, metadata: nil, number: nil, file: nil)

  if id.nil?
    # generate this address
    file_id = file.id unless file.nil?

    resource = @client.post('/v1/documents', {
      document_type: document_type,
      file_id: file_id,
      metadata: ,
      number: number
    })
    body = JSON.parse(resource.body)
    SVBClient::Onboarding::Document.new(@client, body["data"]["id"])
  else
    # verify that the resource exists
    @client.get("/v1/documents/#{id}")
    SVBClient::Onboarding::Document.new(@client, id)
  end
end

#file(id: nil, file: nil, mimetype: nil) ⇒ Object



392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/svbclient.rb', line 392

def file(id: nil, file: nil, mimetype: nil)
  if id.nil?
    # upload this file
    resource = @client.upload("/v1/files", file, mimetype)
    body = JSON.parse(resource.body)
    SVBClient::Onboarding::File.new(@client, id)
  else
    # verify that the resource exists
    @client.get("/v1/files/#{id}")
    SVBClient::Onboarding::File.new(@client, id)
  end
end

#gov_ident(id: nil, country: nil, document_type: nil, expires_on: nil, file_id: -1,, first_name: nil, last_name: nil, middle_name: nil, number: nil, file: nil) ⇒ Object



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/svbclient.rb', line 405

def gov_ident(id: nil, country: nil, document_type: nil, expires_on: nil, file_id: -1,
  first_name: nil, last_name: nil, middle_name: nil, number: nil, file: nil)

  if id.nil?
    # generate this address
    file_id = file.id unless file.nil?

    resource = @client.post('/v1/gov_idents', {
      country: country,
      document_type: document_type,
      expires_on: expires_on,
      file_id: file_id,
      first_name: first_name,
      last_name: last_name,
      middle_name: middle_name,
      number: number
    })
    body = JSON.parse(resource.body)
    SVBClient::Onboarding::GovIdent.new(@client, body["data"]["id"])
  else
    # verify that the resource exists
    @client.get("/v1/gov_idents/#{id}")
    SVBClient::Onboarding::GovIdent.new(@client, id)
  end
end

#login(id: nil, login_name: nil, reservation_expires: nil) ⇒ Object



431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/svbclient.rb', line 431

def (id: nil, login_name: nil, reservation_expires: nil)
  if id.nil?
    # generate this address
    resource = @client.post('/v1/logins', {
      login_name: ,
      reservation_expires: reservation_expires
    })
    body = JSON.parse(resource.body)
    SVBClient::Onboarding::Login.new(@client, body["data"]["id"])
  else
    # verify that the resource exists
    @client.get("/v1/logins/#{id}")
    SVBClient::Onboarding::Login.new(@client, id)
  end
end

#parent_company(id: nil, address_id: -1,, address: nil, country: nil, description: nil, name: nil, metadata: nil, percent_ownership: -1,, source_of_funds: nil) ⇒ Object



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/svbclient.rb', line 447

def parent_company(id: nil, address_id: -1, address: nil, country: nil, description: nil,
  name: nil, metadata: nil, percent_ownership: -1, source_of_funds: nil)

  if id.nil?
    # generate this address
    address_id = address.id unless address.nil?

    resource = @client.post('/v1/parent_companies', {
      address_id: address_id,
      country: country,
      description: description,
      name: name,
      metadata: ,
      percent_ownership: percent_ownership,
      source_of_funds: source_of_funds
    })
    body = JSON.parse(resource.body)
    SVBClient::Onboarding::ParentCompany.new(@client, body["data"]["id"])
  else
    # verify that the resource exists
    @client.get("/v1/parent_companies/#{id}")
    SVBClient::Onboarding::ParentCompany.new(@client, id)
  end
end

#person(id: nil, address_id: -1,, address: nil, date_of_birth: nil, email_address: nil, first_name: nil, gov_idents: [], gov_ident_ids: [], last_name: nil, login_id: -1,, login: nil, metadata: nil, middle_name: nil, percent_ownership: -1,, phone_number: nil, risk_commentary: nil, roles: [], title: nil) ⇒ Object



472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/svbclient.rb', line 472

def person(id: nil, address_id: -1, address: nil, date_of_birth: nil, email_address: nil,
  first_name: nil, gov_idents: [], gov_ident_ids: [], last_name: nil, login_id: -1, login: nil,
  metadata: nil, middle_name: nil, percent_ownership: -1, phone_number: nil, risk_commentary: nil,
  roles: [], title: nil)

  if id.nil?
    # generate this address
    unless gov_idents.nil?
      gov_ident_ids = gov_idents.map do |gov_ident|
        gov_ident.id
      end
    end
    address_id = address.id unless address.nil?
     = .id unless .nil?

    resource = @client.post('/v1/persons', {
      address_id: address_id,
      date_of_birth: date_of_birth,
      email_address: email_address,
      first_name: first_name,
      gov_ident_ids: gov_ident_ids,
      last_name: last_name,
      login_id: ,
      metadata: ,
      middle_name: middle_name,
      percent_ownership: percent_ownership,
      phone_number: phone_number,
      risk_commentary: risk_commentary,
      roles: roles,
      title: title
    })
    body = JSON.parse(resource.body)
    SVBClient::Onboarding::Person.new(@client, body["data"]["id"])
  else
    # verify that the resource exists
    @client.get("/v1/persons/#{id}")
    SVBClient::Onboarding::Person.new(@client, id)
  end
end