-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from keisyd/feat/subaccounts
feat/subaccounts
- Loading branch information
Showing
5 changed files
with
486 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,191 @@ | ||
import { initContract } from '@ts-rest/core' | ||
import { initContract } from '@ts-rest/core'; | ||
import { z } from 'zod'; | ||
import { listMandatoryDocumentsResponseSchema, sendMandatoryDocumentsResponseSchema, sendMandatoryDocumentsCpfRequestSchema, listSubAccountsResponseSchema, listSubAccountsParamsSchema, createSubAccounResponseSchema, createSubAccountCpfBodySchema, createSubAccountCnpjBodySchema, updateSubAccountResponseSchema, updateSubAccountsBodySchema } from '../../schemas/companies/subaccounts.js'; | ||
|
||
const c = initContract() | ||
const c = initContract(); | ||
|
||
export const subaccounts = c.router( | ||
{ | ||
// Todo: Listar Subcontas | ||
// Todo: Obter Documentos Necessários | ||
// Todo: Criar Subconta CPF | ||
// Todo: Criar Subconta CNPJ | ||
// Todo: Enviar Documentos Necessários CPF | ||
// Todo: Enviar Documentos Necessários CNPJ | ||
// Todo: Editar Subconta | ||
// Todo: Reativar Subconta | ||
// Todo: Desativar Subconta | ||
}, | ||
{ | ||
pathPrefix: '/subaccounts', | ||
}, | ||
) | ||
/** | ||
* Defines the subaccounts router object. | ||
* | ||
* @example | ||
* ```ts | ||
* import { initClient } from '@ts-rest/core' | ||
* import { subaccounts } from '@cel_cash/core/contract' | ||
* | ||
* const client = initClient(subaccounts, { | ||
* baseUrl: 'https://api.celcoin.com.br' | ||
* }) | ||
* | ||
* const subaccountsList = await client.list({ ... }) | ||
* const createdSubaccount = await client.createWithCnpj({ ... }) | ||
* const updatedSubaccount = await client.update({ ... }) | ||
* const deletedSubaccount = await client.delete({ ... }) | ||
* ``` | ||
*/ | ||
export const subaccounts = c.router({ | ||
/** | ||
* Retrieves a list of mandatory documents. | ||
* Require access_token to have company.read scope. | ||
* | ||
* @method GET | ||
* @path /company/mandatory-documents | ||
* @responses 200 - The list of mandatory documents. | ||
*/ | ||
listMandatoryDocuments: { | ||
method: 'GET', | ||
path: '/mandatory-documents', | ||
responses: { | ||
200: listMandatoryDocumentsResponseSchema, | ||
}, | ||
}, | ||
/** | ||
* Sends mandatory documents with CPF. | ||
* Require access_token to have company.write scope. | ||
* | ||
* @method POST | ||
* @path /company/mandatory-documents | ||
* @responses 200 - If succeeded or not. | ||
* @body - The request body for sending mandatory documents. | ||
*/ | ||
sendMandatoryDocumentsCpf: { | ||
method: 'POST', | ||
path: '/mandatory-documents', | ||
responses: { | ||
200: sendMandatoryDocumentsResponseSchema, | ||
}, | ||
body: sendMandatoryDocumentsCpfRequestSchema, | ||
}, | ||
/** | ||
* Creates a new mandatory documents with CNPJ. | ||
* Require access_token to have company.write scope. | ||
* | ||
* @method POST | ||
* @path /company/mandatory-documents | ||
* @responses 200 - If succeeded or not. | ||
* @body - The request body for sending mandatory documents. | ||
*/ | ||
sendMandatoryDocumentsCnpj: { | ||
method: 'POST', | ||
path: '/mandatory-documents', | ||
responses: { | ||
200: sendMandatoryDocumentsResponseSchema, | ||
}, | ||
body: sendMandatoryDocumentsCpfRequestSchema, | ||
}, | ||
/** | ||
* Retrieves a list of subAccounts. | ||
* Require access_token to have company.read scope. | ||
* | ||
* @method GET | ||
* @path /company/subaccount | ||
* @responses 200 - The list of subAccounts. | ||
* @query - The query parameters for listing subAccounts. | ||
*/ | ||
list: { | ||
method: 'GET', | ||
path: '/subaccounts', | ||
responses: { | ||
200: listSubAccountsResponseSchema, | ||
}, | ||
query: listSubAccountsParamsSchema, | ||
}, | ||
/** | ||
* Creates a new subAccount with CPF. | ||
* Require access_token to have company.write scope. | ||
* | ||
* @method POST | ||
* @path /company/subaccount | ||
* @responses 200 - The created company subAccount. | ||
* @body - The request body for creating a subAccount. | ||
*/ | ||
createWithCpf: { | ||
method: 'POST', | ||
path: '/subaccount', | ||
responses: { | ||
200: createSubAccounResponseSchema, | ||
}, | ||
body: createSubAccountCpfBodySchema, | ||
}, | ||
/** | ||
* Creates a new subAccount with CNPJ. | ||
* Require access_token to have company.write scope. | ||
* | ||
* @method POST | ||
* @path /company/subaccount | ||
* @responses 200 - The created company subAccount. | ||
* @body - The request body for creating a subAccount. | ||
*/ | ||
createWithCnpj: { | ||
method: 'POST', | ||
path: '/subaccount', | ||
responses: { | ||
200: createSubAccounResponseSchema, | ||
}, | ||
body: createSubAccountCnpjBodySchema, | ||
}, | ||
/** | ||
* Updates a subAccount. | ||
* Require access_token to have company.write scope. | ||
* | ||
* @method PUT | ||
* @path /company/subaccount/:subAccountId/:typeId | ||
* @pathParams - The path parameters for updating a subAccount. | ||
* @responses 200 - The updated subAccount. | ||
* @body - The request body for updating a subAccount. | ||
*/ | ||
update: { | ||
method: 'PUT', | ||
path: '/subaccount/:subAccountId', | ||
pathParams: z.object({ | ||
subAccountId: z.union([z.coerce.number().positive(), z.coerce.string()]), | ||
}), | ||
responses: { | ||
200: updateSubAccountResponseSchema, | ||
}, | ||
body: updateSubAccountsBodySchema, | ||
}, | ||
/** | ||
* Reactivate a subAccount. | ||
* Require access_token to have company.write scope. | ||
* | ||
* @method PUT | ||
* @path /company/subaccount/active/:subAccountId | ||
* @pathParams - The path parameters for updating a subAccount. | ||
* @responses 200 - The updated subAccount. | ||
* @body - The request body for updating a subAccount. | ||
*/ | ||
active: { | ||
method: 'PUT', | ||
path: '/subaccount/active/:subAccountId', | ||
pathParams: z.object({ | ||
subAccountId: z.union([z.coerce.number().positive(), z.coerce.string()]), | ||
}), | ||
responses: { | ||
200: updateSubAccountResponseSchema, | ||
}, | ||
body: updateSubAccountsBodySchema, | ||
}, | ||
/** | ||
* Deletes a subAccount. | ||
* Require access_token to have company.write scope. | ||
* | ||
* @method DELETE | ||
* @path /company/subaccount/:subAccountId/:typeId | ||
* @pathParams - The path parameters for deleting a subAccount. | ||
* @responses 200 - The deletion status. | ||
* @body - An empty object. | ||
*/ | ||
delete: { | ||
method: 'DELETE', | ||
path: '/subaccount/:subAccountId', | ||
pathParams: z.object({ | ||
subAccountId: z.union([z.coerce.number().positive(), z.coerce.string()]), | ||
}), | ||
responses: { | ||
200: z.object({ | ||
type: z.boolean(), | ||
}), | ||
}, | ||
body: c.noBody(), | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { z } from 'zod'; | ||
import { addressSchema } from '../common.js'; | ||
|
||
export const professionalSchema = z.object({ | ||
internalName: z.enum([ | ||
'lawyer', | ||
'doctor', | ||
'accountant', | ||
'realtor', | ||
'broker', | ||
'physicalEducator', | ||
'physiotherapist', | ||
'others', | ||
]), | ||
street: z.string(), | ||
number: z.string(), | ||
complement: z.string().optional(), | ||
neighborhood: z.string(), | ||
city: z.string(), | ||
state: z.string(), | ||
}); | ||
|
||
export const apiAuthSchema = z.object({ | ||
galaxId: z.string(), | ||
galaxHash: z.string(), | ||
publicToken: z.string(), | ||
confirmHashWebhook: z.string(), | ||
}); | ||
|
||
export const verificationSchema = z.object({ | ||
status: z.string(), | ||
Reasons: z.array(z.string()), | ||
}); | ||
|
||
export const configBaseSchema = z.object({ | ||
confirmHashWebhook: z.string(), | ||
taxWithdraw: z.number(), | ||
taxPixDone: z.number(), | ||
taxPixBoleto: z.number(), | ||
taxPixReceived: z.number(), | ||
taxPixTransaction: z.number(), | ||
}); | ||
|
||
export const userBaseSchema = z.object({ | ||
galaxPayId: z.number(), | ||
master: z.boolean(), | ||
email: z.string(), | ||
name: z.string(), | ||
document: z.string(), | ||
phone: z.string(), | ||
}); | ||
|
||
export const companyBaseSchema = z.object({ | ||
galaxPayId: z.number(), | ||
name: z.string(), | ||
document: z.string(), | ||
nameDisplay: z.string(), | ||
active: z.boolean(), | ||
emailContact: z.string(), | ||
urlLogo: z.string(), | ||
createdAt: z.string(), | ||
canAccessPlatform: z.boolean(), | ||
updatedAt: z.string(), | ||
Address: addressSchema, | ||
Professional: professionalSchema, | ||
ApiAuth: apiAuthSchema, | ||
Verification: verificationSchema, | ||
}); |
Oops, something went wrong.