mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-19 11:39:09 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a722fc6c86 |
+47
-9
@@ -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": {
|
"/roles": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "RolesController_searchRoles",
|
"operationId": "RolesController_searchRoles",
|
||||||
@@ -4923,14 +4968,7 @@
|
|||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"201": {
|
"201": {
|
||||||
"description": "",
|
"description": ""
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"type": "object"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -5041,7 +5079,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Maestro - feature/customer-links",
|
"title": "Maestro - main",
|
||||||
"description": "This is the Maestro API",
|
"description": "This is the Maestro API",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"contact": {}
|
"contact": {}
|
||||||
|
|||||||
@@ -14,42 +14,44 @@ import { INote } from './dtos';
|
|||||||
export class ProductboardController {
|
export class ProductboardController {
|
||||||
@Post('notes')
|
@Post('notes')
|
||||||
async sendNote(@Body() note: INote, @User() user: RequestUser) {
|
async sendNote(@Body() note: INote, @User() user: RequestUser) {
|
||||||
const { title, content, tags } = note;
|
const [request_type, urgency, connector_name = 'Não informado'] = note.tags;
|
||||||
const { username, customer_name } = user;
|
|
||||||
|
|
||||||
const email = username.includes('@')
|
const { title, content } = note;
|
||||||
? username
|
// const { username, customer_name } = user;
|
||||||
: username + `@${customer_name}.default`;
|
|
||||||
|
|
||||||
const path = process.env.PB_TOKEN_PATH;
|
// const email = username.includes('@')
|
||||||
const token = await getSecretFromSecretsManager(path);
|
// ? username
|
||||||
|
// : username + `@${customer_name}.default`;
|
||||||
|
|
||||||
const response = await axios
|
// const path = process.env.PB_TOKEN_PATH;
|
||||||
.post(
|
// const token = await getSecretFromSecretsManager(path);
|
||||||
`https://api.productboard.com/notes`,
|
|
||||||
{
|
|
||||||
title,
|
|
||||||
content,
|
|
||||||
tags,
|
|
||||||
user: {
|
|
||||||
email,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: 'Bearer ' + token,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.catch(() => null);
|
|
||||||
|
|
||||||
if (!response) {
|
// const response = await axios
|
||||||
throw new HttpException(
|
// .post(
|
||||||
'Your request could not be submitted, please try again in a few moments or contact support.',
|
// `https://api.productboard.com/notes`,
|
||||||
502,
|
// {
|
||||||
);
|
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,4 +263,17 @@ export class UsersController {
|
|||||||
this.logger.info('synchronizeUser', { user });
|
this.logger.info('synchronizeUser', { user });
|
||||||
return await this.userService.synchronizeUser(id);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,4 +243,17 @@ export class UsersService implements OnModuleInit {
|
|||||||
this.usersClientService.INTERNAL_UserSynchronize({ userId }),
|
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),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user