Skip to content

Commit

Permalink
docs: improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vernu committed Apr 20, 2024
1 parent dd4e9f8 commit 7e6c490
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 57 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});

```

Expand Down
15 changes: 0 additions & 15 deletions api/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
35 changes: 0 additions & 35 deletions api/src/gateway/gateway.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -56,23 +51,13 @@ 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)
return { data }
}

@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(
Expand All @@ -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) {
Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -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')
Expand Down
10 changes: 7 additions & 3 deletions web/components/landing/CodeSnippetSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
})
`
Expand Down

0 comments on commit 7e6c490

Please sign in to comment.