From 4faf422d3f46f1c76d5f80ab3774d5f6b758a3fa Mon Sep 17 00:00:00 2001 From: isra el Date: Mon, 25 Nov 2024 10:46:19 +0300 Subject: [PATCH] feat(api): depricate camelCase endpoints infavor of kebab-case --- README.md | 8 ++++---- api/src/gateway/gateway.controller.ts | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ae6ff4b..ed23f98 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ from their application via a REST API. It utilizes android phones as SMS gateway const API_KEY = 'YOUR_API_KEY'; const DEVICE_ID = 'YOUR_DEVICE_ID'; -await axios.post(`https://api.textbee.dev/api/v1/gateway/devices/${DEVICE_ID}/sendSMS`, { +await axios.post(`https://api.textbee.dev/api/v1/gateway/devices/${DEVICE_ID}/send-sms`, { recipients: [ '+251912345678' ], message: 'Hello World!', }, { @@ -37,7 +37,7 @@ await axios.post(`https://api.textbee.dev/api/v1/gateway/devices/${DEVICE_ID}/se **Code Snippet**: Curl command to send an SMS message via the REST API ```bash -curl -X POST "https://api.textbee.dev/api/v1/gateway/devices/YOUR_DEVICE_ID/sendSMS" \ +curl -X POST "https://api.textbee.dev/api/v1/gateway/devices/YOUR_DEVICE_ID/send-sms" \ -H 'x-api-key: YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ @@ -56,7 +56,7 @@ To receive SMS messages, you can enable the feature from the mobile app. You can const API_KEY = 'YOUR_API_KEY'; const DEVICE_ID = 'YOUR_DEVICE_ID'; -await axios.get(`https://api.textbee.dev/api/v1/gateway/devices/${DEVICE_ID}/getReceivedSMS`, { +await axios.get(`https://api.textbee.dev/api/v1/gateway/devices/${DEVICE_ID}/get-received-sms`, { headers: { 'x-api-key': API_KEY, }, @@ -67,7 +67,7 @@ await axios.get(`https://api.textbee.dev/api/v1/gateway/devices/${DEVICE_ID}/get **Code Snippet**: Curl command to fetch received SMS messages ```bash -curl -X GET "https://api.textbee.dev/api/v1/gateway/devices/YOUR_DEVICE_ID/getReceivedSMS"\ +curl -X GET "https://api.textbee.dev/api/v1/gateway/devices/YOUR_DEVICE_ID/get-received-sms"\ -H "x-api-key: YOUR_API_KEY" ``` diff --git a/api/src/gateway/gateway.controller.ts b/api/src/gateway/gateway.controller.ts index 9b4a3c3..5a6f43e 100644 --- a/api/src/gateway/gateway.controller.ts +++ b/api/src/gateway/gateway.controller.ts @@ -78,7 +78,8 @@ export class GatewayController { @ApiOperation({ summary: 'Send SMS to a device' }) @UseGuards(AuthGuard, CanModifyDevice) - @Post('/devices/:id/sendSMS') + // deprecate sendSMS route in favor of send-sms, but allow both to prevent breaking changes + @Post(['/devices/:id/sendSMS', '/devices/:id/send-sms']) async sendSMS( @Param('id') deviceId: string, @Body() smsData: SendSMSInputDTO, @@ -89,7 +90,8 @@ export class GatewayController { @ApiOperation({ summary: 'Received SMS from a device' }) @HttpCode(HttpStatus.OK) - @Post('/devices/:id/receiveSMS') + // deprecate receiveSMS route in favor of receive-sms + @Post(['/devices/:id/receiveSMS', '/devices/:id/receive-sms']) @UseGuards(AuthGuard, CanModifyDevice) async receiveSMS(@Param('id') deviceId: string, @Body() dto: ReceivedSMSDTO) { const data = await this.gatewayService.receiveSMS(deviceId, dto) @@ -99,7 +101,8 @@ export class GatewayController { @ApiOperation({ summary: 'Get received SMS from a device' }) @ApiResponse({ status: 200, type: RetrieveSMSResponseDTO }) @UseGuards(AuthGuard, CanModifyDevice) - @Get('/devices/:id/getReceivedSMS') + // deprecate getReceivedSMS route in favor of get-received-sms + @Get(['/devices/:id/getReceivedSMS', '/devices/:id/get-received-sms']) async getReceivedSMS( @Param('id') deviceId: string, ): Promise {