Compare commits

...
Author SHA1 Message Date
Gabriel Amorim a722fc6c86 WIP: new logic for feature request 2023-05-05 12:12:59 -03:00
4 changed files with 107 additions and 41 deletions
+47 -9
View File
@@ -1412,6 +1412,51 @@
]
}
},
"/users/connector_request": {
"post": {
"operationId": "UsersController_sendConnectorRequest",
"parameters": [
{
"name": "dadosfera-lang",
"in": "header",
"required": false,
"schema": {
"enum": [
"pt-br",
"en-us"
],
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateUserRes"
}
}
}
},
"201": {
"description": ""
}
},
"tags": [
"Users"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/roles": {
"get": {
"operationId": "RolesController_searchRoles",
@@ -4923,14 +4968,7 @@
},
"responses": {
"201": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
"description": ""
}
},
"tags": [
@@ -5041,7 +5079,7 @@
}
},
"info": {
"title": "Maestro - feature/customer-links",
"title": "Maestro - main",
"description": "This is the Maestro API",
"version": "1.0.0",
"contact": {}
@@ -14,42 +14,44 @@ import { INote } from './dtos';
export class ProductboardController {
@Post('notes')
async sendNote(@Body() note: INote, @User() user: RequestUser) {
const { title, content, tags } = note;
const { username, customer_name } = user;
const [request_type, urgency, connector_name = 'Não informado'] = note.tags;
const email = username.includes('@')
? username
: username + `@${customer_name}.default`;
const { title, content } = note;
// const { username, customer_name } = user;
const path = process.env.PB_TOKEN_PATH;
const token = await getSecretFromSecretsManager(path);
// const email = username.includes('@')
// ? username
// : username + `@${customer_name}.default`;
const response = await axios
.post(
`https://api.productboard.com/notes`,
{
title,
content,
tags,
user: {
email,
},
},
{
headers: {
Authorization: 'Bearer ' + token,
},
},
)
.catch(() => null);
// const path = process.env.PB_TOKEN_PATH;
// const token = await getSecretFromSecretsManager(path);
if (!response) {
throw new HttpException(
'Your request could not be submitted, please try again in a few moments or contact support.',
502,
);
}
// const response = await axios
// .post(
// `https://api.productboard.com/notes`,
// {
// title,
// content,
// tags,
// user: {
// email,
// },
// },
// {
// headers: {
// Authorization: 'Bearer ' + token,
// },
// },
// )
// .catch(() => null);
return response.data;
// if (!response) {
// throw new HttpException(
// 'Your request could not be submitted, please try again in a few moments or contact support.',
// 502,
// );
// }
// return response.data;
}
}
+13
View File
@@ -263,4 +263,17 @@ export class UsersController {
this.logger.info('synchronizeUser', { user });
return await this.userService.synchronizeUser(id);
}
@Post('connector_request')
@RequireAllPermissions(PERMISSIONS_GROUPS.DADOSFERA.permissions.SYNC_USER)
@ApiOkResponse({ type: UpdateUserRes })
async sendConnectorRequest(@User() user: RequestUser, request) {
const metadata = PackTheMetadata({
customer_name: user.customer_name,
customer_id: user.customer_id,
user_id: user.user_id,
username: user.username,
});
this.userService.sendUserConnectorRequest(request, metadata);
}
}
+13
View File
@@ -243,4 +243,17 @@ export class UsersService implements OnModuleInit {
this.usersClientService.INTERNAL_UserSynchronize({ userId }),
);
}
async sendUserConnectorRequest(
request: {
connector_name: string;
description: string;
title: string;
urgency: string;
},
metadata: Metadata,
) {
return await lastValueFrom(
this.usersClientService.UserConnectorRequest({ request }, metadata),
);
}
}