Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Documentation for verify phone number endpoint. #53

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion brints-estate-api/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AuthController {
@ApiResponse(InternalServerErrorResponse)
@Post('register')
@Auth(AuthType.None)
@UseInterceptors(FileInterceptor('file'))
@UseInterceptors(FileInterceptor('image_url'))
@UseInterceptors(ClassSerializerInterceptor)
@UseFilters(HttpExceptionFilter)
async registerUser(
Expand Down
110 changes: 110 additions & 0 deletions brints-estate-api/src/users/swagger_docs/verify-phone-response.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,113 @@ export const VerifyPhoneResponse = {
},
},
};

export const NotFoundPhoneNumberResponse = {
description: 'Phone number does not exist',
status: HttpStatus.NOT_FOUND,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.NOT_FOUND,
},
message: {
type: 'string',
example: 'Phone number does not exist.',
},
},
},
};

export const IncorrectPhoneNumberResponse = {
description: 'Incorrect phone number',
status: HttpStatus.BAD_REQUEST,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.BAD_REQUEST,
},
message: {
type: 'string',
example: 'Incorrect phone number.',
},
},
},
};

export const ForbiddenAccountVerifiedResponse = {
description: 'This account is already verified',
status: HttpStatus.FORBIDDEN,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.FORBIDDEN,
},
message: {
type: 'string',
example: 'This account is already verified.',
},
},
},
};

export const InvalidOTPResponse = {
description: 'Invalid OTP. Try again.',
status: HttpStatus.BAD_REQUEST,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.BAD_REQUEST,
},
message: {
type: 'string',
example: 'Invalid OTP. Try again.',
},
},
},
};

export const OTPExpiredResponse = {
description: 'OTP has expired. Please, generate a new one.',
status: HttpStatus.BAD_REQUEST,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.BAD_REQUEST,
},
message: {
type: 'string',
example: 'OTP has expired. Please, generate a new one.',
},
},
},
};
17 changes: 16 additions & 1 deletion brints-estate-api/src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import {
Put,
} from '@nestjs/common';
import {
ApiBadRequestResponse,
ApiBearerAuth,
ApiForbiddenResponse,
ApiInternalServerErrorResponse,
ApiNotFoundResponse,
ApiOkResponse,
ApiOperation,
ApiResponse,
Expand Down Expand Up @@ -45,7 +48,14 @@ import {
InternalServerErrorResponse,
UnauthorizedUserVerifiedResponse,
} from './swagger_docs/common-reponses.doc';
import { VerifyPhoneResponse } from './swagger_docs/verify-phone-response.doc';
import {
ForbiddenAccountVerifiedResponse,
IncorrectPhoneNumberResponse,
InvalidOTPResponse,
NotFoundPhoneNumberResponse,
OTPExpiredResponse,
VerifyPhoneResponse,
} from './swagger_docs/verify-phone-response.doc';

@Controller('user')
@ApiTags('User Management')
Expand Down Expand Up @@ -78,6 +88,11 @@ export class UsersController {
summary: 'Verify registered user phone number.',
})
@ApiOkResponse(VerifyPhoneResponse)
@ApiNotFoundResponse(NotFoundPhoneNumberResponse)
@ApiBadRequestResponse(IncorrectPhoneNumberResponse)
@ApiForbiddenResponse(ForbiddenAccountVerifiedResponse)
@ApiBadRequestResponse(InvalidOTPResponse)
@ApiBadRequestResponse(OTPExpiredResponse)
@ApiInternalServerErrorResponse(InternalServerErrorResponse)
@Post('verify-phone')
@Auth(AuthType.None)
Expand Down
Loading