Class: SVBClient::Onboarding
- Inherits:
-
Object
- Object
- SVBClient::Onboarding
- Defined in:
- lib/svbclient.rb
Defined Under Namespace
Classes: Address, Company, Document, File, GovIdent, Login, ParentCompany, Person, Resource
Instance Method Summary collapse
- #address(id: nil, street_line1: nil, street_line2: nil, street_line3: nil, city: nil, state: nil, postal_code: nil, country: nil) ⇒ Object
- #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
- #document(id: nil, document_type: nil, file_id: -1,, metadata: nil, number: nil, file: nil) ⇒ Object
- #file(id: nil, file: nil, mimetype: nil) ⇒ Object
- #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
-
#initialize(client) ⇒ Onboarding
constructor
A new instance of Onboarding.
- #login(id: nil, login_name: nil, reservation_expires: nil) ⇒ Object
- #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
- #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
Constructor Details
#initialize(client) ⇒ Onboarding
Returns a new instance of Onboarding.
119 120 121 122 |
# File 'lib/svbclient.rb', line 119 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
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/svbclient.rb', line 124 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
145 146 147 148 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 |
# File 'lib/svbclient.rb', line 145 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: , 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
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/svbclient.rb', line 201 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
222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/svbclient.rb', line 222 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
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/svbclient.rb', line 235 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
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/svbclient.rb', line 261 def login(id: nil, login_name: nil, reservation_expires: nil) if id.nil? # generate this address resource = @client.post('/v1/logins', { login_name: 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
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/svbclient.rb', line 277 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
302 303 304 305 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 |
# File 'lib/svbclient.rb', line 302 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? login_id = login.id unless login.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: 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 |