Skip to content

Commit

Permalink
📝 Udpated swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jun 20, 2024
1 parent c5c308c commit 8feffaa
Show file tree
Hide file tree
Showing 89 changed files with 524 additions and 3,659 deletions.
59 changes: 8 additions & 51 deletions packages/api/scripts/commonObject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private connectionUtils: ConnectionUtils
}
@ApiOperation({
operationId: 'get${ObjectCap}s',
operationId: 'list',
summary: 'List a batch of ${ObjectCap}s',
})
@ApiHeader({
Expand All @@ -325,7 +325,7 @@ private connectionUtils: ConnectionUtils
@ApiCustomResponse(Unified${ObjectCap}Output)
//@UseGuards(ApiKeyAuthGuard)
@Get()
async get${ObjectCap}s(
async list(
@Headers('x-connection-token') connection_token: string,
@Query('remote_data') remote_data?: boolean,
) {
Expand All @@ -345,7 +345,7 @@ private connectionUtils: ConnectionUtils
}
@ApiOperation({
operationId: 'get${ObjectCap}',
operationId: 'retrieve',
summary: 'Retrieve a ${ObjectCap}',
description: 'Retrieve a ${objectType} from any connected ${VerticalCap} software',
})
Expand All @@ -365,15 +365,15 @@ private connectionUtils: ConnectionUtils
@ApiCustomResponse(Unified${ObjectCap}Output)
//@UseGuards(ApiKeyAuthGuard)
@Get(':id')
get${ObjectCap}(
retrieve(
@Param('id') id: string,
@Query('remote_data') remote_data?: boolean,
) {
return this.${objectType}Service.get${ObjectCap}(id, remote_data);
}
@ApiOperation({
operationId: 'add${ObjectCap}',
operationId: 'create',
summary: 'Create a ${ObjectCap}',
description: 'Create a ${objectType} in any supported ${VerticalCap} software',
})
Expand All @@ -394,7 +394,7 @@ private connectionUtils: ConnectionUtils
@ApiCustomResponse(Unified${ObjectCap}Output)
//@UseGuards(ApiKeyAuthGuard)
@Post()
async add${ObjectCap}(
async create(
@Body() unified${ObjectCap}Data: Unified${ObjectCap}Input,
@Headers('x-connection-token') connection_token: string,
@Query('remote_data') remote_data?: boolean,
Expand All @@ -416,56 +416,13 @@ private connectionUtils: ConnectionUtils
}
@ApiOperation({
operationId: 'add${ObjectCap}s',
summary: 'Add a batch of ${ObjectCap}s',
})
@ApiHeader({
name: 'x-connection-token',
required: true,
description: 'The connection token',
example: 'b008e199-eda9-4629-bd41-a01b6195864a',
})
@ApiQuery({
name: 'remote_data',
required: false,
type: Boolean,
description:
'Set to true to include data from the original ${VerticalCap} software.',
})
@ApiBody({ type: Unified${ObjectCap}Input, isArray: true })
@ApiCustomResponse(Unified${ObjectCap}Output)
//@UseGuards(ApiKeyAuthGuard)
@Post('batch')
async add${ObjectCap}s(
@Body() unfied${ObjectCap}Data: Unified${ObjectCap}Input[],
@Headers('connection_token') connection_token: string,
@Query('remote_data') remote_data?: boolean,
) {
try{
const { linkedUserId, remoteSource } =
await this.connectionUtils.getConnectionMetadataFromConnectionToken(
connection_token,
);
return this.${objectType}Service.batchAdd${ObjectCap}s(
unfied${ObjectCap}Data,
remoteSource,
linkedUserId,
remote_data,
);
}catch(error){
throw new Error(error);
}
}
@ApiOperation({
operationId: 'update${ObjectCap}',
operationId: 'update',
summary: 'Update a ${ObjectCap}',
})
@ApiCustomResponse(Unified${ObjectCap}Output)
//@UseGuards(ApiKeyAuthGuard)
@Patch()
update${ObjectCap}(
update$(
@Query('id') id: string,
@Body() update${ObjectCap}Data: Partial<Unified${ObjectCap}Input>,
) {
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/@core/connections/connections.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ export class ConnectionsController {
}

@ApiOperation({
operationId: 'getConnections',
operationId: 'list',
summary: 'List Connections',
})
@ApiResponse({ status: 200 })
@UseGuards(JwtAuthGuard)
@Get()
async getConnections(@Request() req: any) {
async list(@Request() req: any) {
try {
const { id_project } = req.user;
console.log('Req data is:', req.user);
Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/@core/magic-link/magic-link.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ export class MagicLinkController {
}

@ApiOperation({
operationId: 'getMagicLinks',
operationId: 'list',
summary: 'Retrieve Magic Links',
})
@ApiResponse({ status: 200 })
@Get()
getMagicLinks() {
list() {
return this.magicLinkService.getMagicLinks();
}

@ApiOperation({
operationId: 'getMagicLink',
operationId: 'retrieve',
summary: 'Retrieve a Magic Link',
})
@ApiQuery({ name: 'id', required: true, type: String })
@ApiResponse({ status: 200 })
@Get('single')
getMagicLink(@Query('id') id: string) {
retrieve(@Query('id') id: string) {
return this.magicLinkService.getMagicLink(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ export class ManagedWebhooksController {
}

@ApiOperation({
operationId: 'getManagedWebhooks',
operationId: 'retrieve',
summary: 'Retrieve managed webhooks',
})
@ApiResponse({ status: 200 })
@UseGuards(JwtAuthGuard)
@Get(':id_connection')
getManagedWebhook(@Param('id_connection') id_connection: string) {
retrieve(@Param('id_connection') id_connection: string) {
return this.managedWebhookService.getManagedWebhook(id_connection);
}

@ApiOperation({
operationId: 'updateManagedWebhooksStatus',
operationId: 'update',
summary: 'Update managed webhook status',
})
@UseGuards(JwtAuthGuard)
@Put(':id_connection')
async updateManagedWebhooksStatus(
async update(
@Param('id_connection') id_connection: string,
@Body('active') active: boolean,
) {
Expand All @@ -53,14 +53,14 @@ export class ManagedWebhooksController {
}

@ApiOperation({
operationId: 'createManagedWebhook',
operationId: 'create',
summary: 'Create managed webhook',
})
@ApiBody({ type: ManagedWebhooksDto })
@ApiResponse({ status: 201 })
@UseGuards(JwtAuthGuard)
@Post()
async addManagedWebhook(@Body() data: ManagedWebhooksDto) {
async create(@Body() data: ManagedWebhooksDto) {
return this.managedWebhookService.createManagedWebhook(data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export class OrganisationsController {
}

@ApiOperation({
operationId: 'getOrganisations',
operationId: 'list',
summary: 'Retrieve Organisations',
})
@Get()
getOragnisations() {
list() {
return; //this.organizationsService.getOrganisations();
}

Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/@core/webhook/webhook.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export class WebhookController {
}

@ApiOperation({
operationId: 'getWebhooksMetadata',
operationId: 'list',
summary: 'Retrieve webhooks metadata ',
})
@ApiResponse({ status: 200 })
@UseGuards(JwtAuthGuard)
@Get()
getWebhooks(@Request() req: any) {
list(@Request() req: any) {
const { id_project } = req.user;
return this.webhookService.getWebhookEndpoints(id_project);
}
Expand Down
54 changes: 6 additions & 48 deletions packages/api/src/accounting/account/account.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class AccountController {
}

@ApiOperation({
operationId: 'getAccountingAccounts',
operationId: 'list',
summary: 'List a batch of Accounts',
})
@ApiHeader({
Expand All @@ -56,7 +56,7 @@ export class AccountController {
@ApiCustomResponse(UnifiedAccountOutput)
//@UseGuards(ApiKeyAuthGuard)
@Get()
async getAccounts(
async list(
@Headers('x-connection-token') connection_token: string,
@Query('remote_data') remote_data?: boolean,
) {
Expand All @@ -76,7 +76,7 @@ export class AccountController {
}

@ApiOperation({
operationId: 'getAccountingAccount',
operationId: 'retrieve',
summary: 'Retrieve a Account',
description: 'Retrieve a account from any connected Accounting software',
})
Expand All @@ -96,15 +96,15 @@ export class AccountController {
@ApiCustomResponse(UnifiedAccountOutput)
//@UseGuards(ApiKeyAuthGuard)
@Get(':id')
getAccount(
retrieve(
@Param('id') id: string,
@Query('remote_data') remote_data?: boolean,
) {
return this.accountService.getAccount(id, remote_data);
}

@ApiOperation({
operationId: 'addAccount',
operationId: 'create',
summary: 'Create a Account',
description: 'Create a account in any supported Accounting software',
})
Expand All @@ -125,7 +125,7 @@ export class AccountController {
@ApiCustomResponse(UnifiedAccountOutput)
//@UseGuards(ApiKeyAuthGuard)
@Post()
async addAccount(
async create(
@Body() unifiedAccountData: UnifiedAccountInput,
@Headers('x-connection-token') connection_token: string,
@Query('remote_data') remote_data?: boolean,
Expand All @@ -145,46 +145,4 @@ export class AccountController {
throw new Error(error);
}
}

@ApiOperation({
operationId: 'addAccounts',
summary: 'Add a batch of Accounts',
})
@ApiHeader({
name: 'x-connection-token',
required: true,
description: 'The connection token',
example: 'b008e199-eda9-4629-bd41-a01b6195864a',
})
@ApiQuery({
name: 'remote_data',
required: false,
type: Boolean,
description:
'Set to true to include data from the original Accounting software.',
})
@ApiBody({ type: UnifiedAccountInput, isArray: true })
@ApiCustomResponse(UnifiedAccountOutput)
//@UseGuards(ApiKeyAuthGuard)
@Post('batch')
async addAccounts(
@Body() unfiedAccountData: UnifiedAccountInput[],
@Headers('connection_token') connection_token: string,
@Query('remote_data') remote_data?: boolean,
) {
try {
const { linkedUserId, remoteSource } =
await this.connectionUtils.getConnectionMetadataFromConnectionToken(
connection_token,
);
return this.accountService.batchAddAccounts(
unfiedAccountData,
remoteSource,
linkedUserId,
remote_data,
);
} catch (error) {
throw new Error(error);
}
}
}
Loading

0 comments on commit 8feffaa

Please sign in to comment.