Browse Source

feat(api): depricate camelCase endpoints infavor of kebab-case

legacy-ui
isra el 1 year ago
parent
commit
4faf422d3f
  1. 8
      README.md
  2. 9
      api/src/gateway/gateway.controller.ts

8
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 API_KEY = 'YOUR_API_KEY';
const DEVICE_ID = 'YOUR_DEVICE_ID'; 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' ], recipients: [ '+251912345678' ],
message: 'Hello World!', 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 **Code Snippet**: Curl command to send an SMS message via the REST API
```bash ```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 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{ -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 API_KEY = 'YOUR_API_KEY';
const DEVICE_ID = 'YOUR_DEVICE_ID'; 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: { headers: {
'x-api-key': API_KEY, '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 **Code Snippet**: Curl command to fetch received SMS messages
```bash ```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" -H "x-api-key: YOUR_API_KEY"
``` ```

9
api/src/gateway/gateway.controller.ts

@ -78,7 +78,8 @@ export class GatewayController {
@ApiOperation({ summary: 'Send SMS to a device' }) @ApiOperation({ summary: 'Send SMS to a device' })
@UseGuards(AuthGuard, CanModifyDevice) @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( async sendSMS(
@Param('id') deviceId: string, @Param('id') deviceId: string,
@Body() smsData: SendSMSInputDTO, @Body() smsData: SendSMSInputDTO,
@ -89,7 +90,8 @@ export class GatewayController {
@ApiOperation({ summary: 'Received SMS from a device' }) @ApiOperation({ summary: 'Received SMS from a device' })
@HttpCode(HttpStatus.OK) @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) @UseGuards(AuthGuard, CanModifyDevice)
async receiveSMS(@Param('id') deviceId: string, @Body() dto: ReceivedSMSDTO) { async receiveSMS(@Param('id') deviceId: string, @Body() dto: ReceivedSMSDTO) {
const data = await this.gatewayService.receiveSMS(deviceId, dto) const data = await this.gatewayService.receiveSMS(deviceId, dto)
@ -99,7 +101,8 @@ export class GatewayController {
@ApiOperation({ summary: 'Get received SMS from a device' }) @ApiOperation({ summary: 'Get received SMS from a device' })
@ApiResponse({ status: 200, type: RetrieveSMSResponseDTO }) @ApiResponse({ status: 200, type: RetrieveSMSResponseDTO })
@UseGuards(AuthGuard, CanModifyDevice) @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( async getReceivedSMS(
@Param('id') deviceId: string, @Param('id') deviceId: string,
): Promise<RetrieveSMSResponseDTO> { ): Promise<RetrieveSMSResponseDTO> {

Loading…
Cancel
Save