From 071a3b58cb085501811e1c1a0cc20247ffbead40 Mon Sep 17 00:00:00 2001 From: Jose Marchant Date: Mon, 24 Aug 2026 16:09:12 -0400 Subject: [PATCH] feat(v2): expose onboarding type and nest create payload under data The public API now requires a `type` on entity onboarding creation (`account_holder` or `settlement_recipient`) and takes the company information, legal representatives, transactional profile and shareholders nested under `data` instead of at the top level. Expose the `type` the API returns on the onboarding object, and move the docs and specs to the current request shape. --- README.md | 76 ++++++++++--------- lib/fintoc/v2/resources/onboarding.rb | 7 +- .../v2/managers/onboardings_manager_spec.rb | 13 +++- spec/lib/fintoc/v2/onboarding_spec.rb | 6 +- 4 files changed, 59 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 0954096..dff39cb 100644 --- a/README.md +++ b/README.md @@ -411,47 +411,51 @@ onboardings = entity.onboardings.list # shareholders and documents) onboarding = entity.onboardings.get('onboarding_id') puts onboarding # 📋 Onboarding onbprc_0ujs... (in_progress) +onboarding.type # => 'account_holder' onboarding.legal_representatives # => array of legal representative hashes onboarding.shareholders # => array of shareholder hashes onboarding.documents # => array of document hashes -# Create an onboarding. The nested structures are passed through as-is and -# validated by the API. +# Create an onboarding. `type` selects the onboarding to run (`account_holder` or +# `settlement_recipient`) and `data` holds the nested structures, which are passed +# through as-is and validated by the API. onboarding = entity.onboardings.create( - company_information: { - incorporation_date: '2020-01-01', - business_activity: 'Software', - legal_name: 'ACME Inc.', - fiscal_address: 'Av. Siempre Viva 123', - business_address: 'Av. Siempre Viva 123', - settlement_account: '1234567890', - phone: '+56912345678' - }, - legal_representatives: [ - { - first_name: 'Jane', - last_name: 'Doe', - email: 'jane@acme.com', - nationality: 'CL', - identification_number: '12345678-9', - position: 'CEO' - } - ], - transactional_profile: { - resource_origins: ['sales'], - monthly_amount_range: '0-1000000', - monthly_operations_range: '0-100' - }, - shareholders: [ - { - type: 'natural_person', - name: 'Jane', - last_name: 'Doe', - holder_id: '12345678-9', - nationality: 'CL', - percentage: 100 - } - ] + type: 'account_holder', + data: { + company_information: { + incorporation_date: '2020-01-15', + business_activity: 'Servicios financieros', + fiscal_address: 'Av. Reforma 123, CDMX', + business_address: 'Av. Insurgentes 456, CDMX', + settlement_account: '646180357600000013', + phone: '+521111111111' + }, + legal_representatives: [ + { + first_name: 'Jane', + last_name: 'Doe', + email: 'jane@acme.com', + nationality: 'mx', + identification_number: 'AAAA010101HDFAAA01', + position: 'Director General' + } + ], + transactional_profile: { + resource_origins: %w[trusts investments], + monthly_amount_range: '1_500000', + monthly_operations_range: '1_15000' + }, + shareholders: [ + { + type: 'natural_person', + name: 'Jane', + last_name: 'Doe', + holder_id: 'AAAA010101AAA', + nationality: 'mx', + percentage: 100 + } + ] + } ) # Upload a document for a given slot (multipart). `file:` accepts a path or an IO. diff --git a/lib/fintoc/v2/resources/onboarding.rb b/lib/fintoc/v2/resources/onboarding.rb index 4757460..2497860 100644 --- a/lib/fintoc/v2/resources/onboarding.rb +++ b/lib/fintoc/v2/resources/onboarding.rb @@ -1,13 +1,15 @@ module Fintoc module V2 class Onboarding - attr_reader :object, :id, :entity_id, :status, :source, :submitted_at, :reviewed_at, - :submittable, :data, :legal_representatives, :shareholders, :documents + attr_reader :object, :id, :entity_id, :type, :status, :source, :submitted_at, + :reviewed_at, :submittable, :data, :legal_representatives, :shareholders, + :documents def initialize( object:, id:, entity_id: nil, + type: nil, status: nil, source: nil, submitted_at: nil, @@ -23,6 +25,7 @@ def initialize( @object = object @id = id @entity_id = entity_id + @type = type @status = status @source = source @submitted_at = submitted_at diff --git a/spec/lib/fintoc/v2/managers/onboardings_manager_spec.rb b/spec/lib/fintoc/v2/managers/onboardings_manager_spec.rb index 2bb6e81..f7eb3be 100644 --- a/spec/lib/fintoc/v2/managers/onboardings_manager_spec.rb +++ b/spec/lib/fintoc/v2/managers/onboardings_manager_spec.rb @@ -17,6 +17,7 @@ id: onboarding_id, object: 'onboarding', entity_id: entity_id, + type: 'account_holder', status: 'in_progress', source: 'api', submitted_at: nil, @@ -29,6 +30,7 @@ id: 'onbprc_other', object: 'onboarding', entity_id: entity_id, + type: 'settlement_recipient', status: 'submitted', source: 'dashboard', submitted_at: '2026-06-22T00:00:00Z', @@ -48,10 +50,13 @@ let(:create_params) do { - company_information: { legal_name: 'ACME Inc.' }, - legal_representatives: [{ first_name: 'Jane', last_name: 'Doe' }], - transactional_profile: { monthly_amount_range: '0-1000' }, - shareholders: [{ type: 'natural_person', name: 'Jane', percentage: 100 }] + type: 'account_holder', + data: { + company_information: { business_activity: 'Servicios financieros' }, + legal_representatives: [{ first_name: 'Jane', last_name: 'Doe' }], + transactional_profile: { monthly_amount_range: '1_500000' }, + shareholders: [{ type: 'natural_person', name: 'Jane', percentage: 100 }] + } } end diff --git a/spec/lib/fintoc/v2/onboarding_spec.rb b/spec/lib/fintoc/v2/onboarding_spec.rb index 59ab1b6..5a81f89 100644 --- a/spec/lib/fintoc/v2/onboarding_spec.rb +++ b/spec/lib/fintoc/v2/onboarding_spec.rb @@ -54,6 +54,7 @@ id: 'onbprc_0ujs', object: 'onboarding', entity_id: 'ent_12345', + type: 'account_holder', status: 'in_progress', source: 'api', submitted_at: nil, @@ -79,6 +80,7 @@ id: 'onbprc_0ujs', object: 'onboarding', entity_id: 'ent_12345', + type: 'account_holder', status: 'in_progress', source: 'api', submitted_at: nil, @@ -110,6 +112,7 @@ id: 'onbprc_0ujs', object: 'onboarding', entity_id: 'ent_12345', + type: 'account_holder', status: 'pending', source: 'dashboard', submitted_at: nil, @@ -119,9 +122,10 @@ let(:light_onboarding) { described_class.new(**light_data) } - it 'builds without full attributes' do + it 'builds without full attributes' do # rubocop:disable RSpec/ExampleLength expect(light_onboarding).to have_attributes( id: 'onbprc_0ujs', + type: 'account_holder', status: 'pending', source: 'dashboard', submittable: nil,