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.



123
124
125
126
# File 'lib/svbclient.rb', line 123

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



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/svbclient.rb', line 128

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



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/svbclient.rb', line 149

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



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/svbclient.rb', line 205

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



226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/svbclient.rb', line 226

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



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/svbclient.rb', line 239

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



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/svbclient.rb', line 265

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::.new(@client, body["data"]["id"])
  else
    # verify that the resource exists
    @client.get("/v1/logins/#{id}")
    SVBClient::Onboarding::.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



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/svbclient.rb', line 281

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



306
307
308
309
310
311
312
313
314
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
# File 'lib/svbclient.rb', line 306

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