[TRNF-7286] Feat(v2): Add entity onboardings and multipart uploads#100
Conversation
2a7e94f to
5a5f717
Compare
Add a `form` request option and a `resourceUpload` handler so managers can send multipart bodies via FormData, letting form-data set the Content-Type boundary. JWS signing is skipped for multipart requests. Declares the form-data dependency explicitly.
Onboarding, OnboardingShareholder and OnboardingDocument resources for the v2 entity onboarding response.
Onboardings are nested under entities (fintoc.v2.entities.onboardings), mirroring account_statements: list, get, create, submit, and slot + shareholder document uploads (via resourceUpload, errors mapped to typed Fintoc errors). Also enables fintoc.v2.entities.create.
5a5f717 to
a83c195
Compare
| }); | ||
| const data = await client.request({ path, method: 'put', form }); | ||
| return objetize( | ||
| klass, |
There was a problem hiding this comment.
que sea con k es a propósito? jajaja
There was a problem hiding this comment.
Seguí el patrón que estaba en las otras clases nomás jeje, según yo igual es común para evitar el clash con class que es un keyword
| const innerParams = Object.fromEntries(query.map((x) => x.split('='))); | ||
| const completeParams = { ...innerParams, ...(params === undefined ? {} : params) }; | ||
| const usableURL = url?.split('//').slice(-1)[0].split('/').slice(1).join('/').split('?')[0] || ''; | ||
| const isMultipart = data !== undefined && typeof data !== 'string'; |
There was a problem hiding this comment.
esta es la forma real de definir si algo es multipart? si es una imagen esto también sería true y no necesariamente sería multipart
There was a problem hiding this comment.
damn, no se me ocurrió
There was a problem hiding this comment.
voy a ver otra forma
| @@ -1,4 +1,5 @@ | |||
| import { Method } from 'axios'; | |||
| import FormData from 'form-data'; | |||
There was a problem hiding this comment.
necesitamos esta librería? creo que usar el soporte nativo de Javascript sería mejor opción
There was a problem hiding this comment.
pucha si, estamos con node-10 como min requirement del SDK
| return this.uploadFile(path, file); | ||
| } | ||
|
|
||
| @canRaiseHTTPError |
There was a problem hiding this comment.
este necesita esto vs los otros por alguna razón específica?
There was a problem hiding this comment.
con el refactor queda gucci
| const klass = await getResourceClass( | ||
| (this.constructor as typeof OnboardingsManager).resource, | ||
| ); | ||
| return resourceUpload<Onboarding>(this._client, path, klass, file); |
There was a problem hiding this comment.
no estoy seguro como se podría hacer, pero me tinca que uno podría extender el manager y que esto sea un método miembro de la clase, para poder hacer this.uploadResource(path, klass, file). Creo que quedaría más nice de ser posible. Si se enreda mucho la cosa lo podemos dejar así. Siento que pasarle el this._client es medio hacky y se podría evitar
There was a problem hiding this comment.
Voy con esto, es un buen refactor
|
@tlarrain moví el upload a manager mixin y ahora valido el tipo de |
tlarrain
left a comment
There was a problem hiding this comment.
Quedó mucho más nice, congrats!
Contexto
Soporte en el SDK para el nuevo flujo de onboarding de entities de la API pública v2 (
/v2/entities/{id}/onboardings).Qué hay de nuevo?
POST /v2/entitiesPOST /v2/entities/{id}/onboardingsPUT /v2/entities/{id}/onboardings/{id}/shareholders/{id}/documentPUT /v2/entities/{id}/onboardings/{id}/documents/{slot_key}POST /v2/entities/{id}/onboardings/{id}/submitmultipart/form-dataen el cliente HTTP.Tests
Unitarios para el cliente multipart, los recursos y el manager (incluyendo las subidas de documentos). Probado end-to-end localmente contra fintoc-rails + pacioli (crear onboarding → subir documentos → submit).
Consideraciones
Las subidas multipart no se firman con JWS.
Rollback
¿Es seguro hacer rollback?
Sí
¿Cuáles son los pasos para hacer rollback?
Normal