diff --git a/README.md b/README.md index cee4ce3..f37b9c9 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,14 @@ 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?apiKey=${API_KEY}`, { - receivers: [ '+251912345678' ], - smsBody: 'Hello World!', -}) +await axios.post(`https://api.textbee.dev/api/v1/gateway/devices/${DEVICE_ID}/sendSMS`, { + recipients: [ '+251912345678' ], + message: 'Hello World!', +}, { + headers: { + 'x-api-key': API_KEY, + }, +}); ``` diff --git a/api/src/auth/auth.controller.ts b/api/src/auth/auth.controller.ts index c5a39f7..7d1b4c4 100644 --- a/api/src/auth/auth.controller.ts +++ b/api/src/auth/auth.controller.ts @@ -50,11 +50,6 @@ export class AuthController { } @ApiOperation({ summary: 'Get current logged in user' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @ApiBearerAuth() @UseGuards(AuthGuard) @Get('/who-am-i') @@ -64,11 +59,6 @@ export class AuthController { @UseGuards(AuthGuard) @ApiOperation({ summary: 'Generate Api Key' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @ApiBearerAuth() @Post('/api-keys') async generateApiKey(@Request() req) { @@ -78,11 +68,6 @@ export class AuthController { @UseGuards(AuthGuard) @ApiOperation({ summary: 'Get Api Key List (masked***)' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @ApiBearerAuth() @Get('/api-keys') async getApiKey(@Request() req) { diff --git a/api/src/gateway/gateway.controller.ts b/api/src/gateway/gateway.controller.ts index b1e464d..9b4a3c3 100644 --- a/api/src/gateway/gateway.controller.ts +++ b/api/src/gateway/gateway.controller.ts @@ -43,11 +43,6 @@ export class GatewayController { @UseGuards(AuthGuard) @ApiOperation({ summary: 'Register device' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @Post('/devices') async registerDevice(@Body() input: RegisterDeviceInputDTO, @Request() req) { const data = await this.gatewayService.registerDevice(input, req.user) @@ -56,11 +51,6 @@ export class GatewayController { @UseGuards(AuthGuard) @ApiOperation({ summary: 'List of registered devices' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @Get('/devices') async getDevices(@Request() req) { const data = await this.gatewayService.getDevicesForUser(req.user) @@ -68,11 +58,6 @@ export class GatewayController { } @ApiOperation({ summary: 'Update device' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @UseGuards(AuthGuard, CanModifyDevice) @Patch('/devices/:id') async updateDevice( @@ -84,11 +69,6 @@ export class GatewayController { } @ApiOperation({ summary: 'Delete device' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @UseGuards(AuthGuard, CanModifyDevice) @Delete('/devices/:id') async deleteDevice(@Param('id') deviceId: string) { @@ -97,11 +77,6 @@ export class GatewayController { } @ApiOperation({ summary: 'Send SMS to a device' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @UseGuards(AuthGuard, CanModifyDevice) @Post('/devices/:id/sendSMS') async sendSMS( @@ -113,11 +88,6 @@ export class GatewayController { } @ApiOperation({ summary: 'Received SMS from a device' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @HttpCode(HttpStatus.OK) @Post('/devices/:id/receiveSMS') @UseGuards(AuthGuard, CanModifyDevice) @@ -127,11 +97,6 @@ export class GatewayController { } @ApiOperation({ summary: 'Get received SMS from a device' }) - @ApiQuery({ - name: 'apiKey', - required: false, - description: 'Required if jwt bearer token not provided', - }) @ApiResponse({ status: 200, type: RetrieveSMSResponseDTO }) @UseGuards(AuthGuard, CanModifyDevice) @Get('/devices/:id/getReceivedSMS') diff --git a/web/components/landing/CodeSnippetSection.tsx b/web/components/landing/CodeSnippetSection.tsx index 8f14eb1..6116afc 100644 --- a/web/components/landing/CodeSnippetSection.tsx +++ b/web/components/landing/CodeSnippetSection.tsx @@ -10,9 +10,13 @@ export default function CodeSnippetSection() { const API_KEY = 'YOUR_API_KEY' const DEVICE_ID = 'YOUR_DEVICE_ID' - await axios.post(\`\$\{BASE_URL\}/gateway/devices/\$\{DEVICE_ID}/sendSMS?apiKey=\$\{API_KEY\}\`, { - receivers: [ '+251912345678' ], - smsBody: 'Hello World!', + await axios.post(\`\$\{BASE_URL\}/gateway/devices/\$\{DEVICE_ID}/sendSMS\`, { + recipients: [ '+251912345678' ], + message: 'Hello World!', + }, { + headers: { + 'x-api-key': API_KEY, + }, }) `