@tec.pet/tecpet-sdk 0.0.230 → 0.0.232
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domain/integrationShop/dto/pa.get-integration-shop-credentials.dto.d.ts +14 -0
- package/dist/domain/integrationShop/dto/pa.get-integration-shop-credentials.dto.js +17 -0
- package/dist/domain/integrationShop/dto/pa.get-shops-with-integration.dto.d.ts +6 -3
- package/dist/domain/integrationShop/index.d.ts +1 -0
- package/dist/domain/integrationShop/index.js +1 -0
- package/dist/domain/integrationShop/integrationShop.service.d.ts +6 -0
- package/dist/domain/integrationShop/integrationShop.service.js +8 -0
- package/dist/domain/notification/enum/notification-type.enum.d.ts +13 -1
- package/dist/domain/notification/enum/notification-type.enum.js +12 -0
- package/dist/domain/nps/dto/nps-survey-payload.dto.d.ts +11 -0
- package/dist/domain/nps/dto/nps-survey-payload.dto.js +2 -0
- package/dist/domain/nps/dto/pa.nps-answer.dto.d.ts +17 -0
- package/dist/domain/nps/dto/pa.nps-answer.dto.js +2 -0
- package/dist/domain/nps/dto/pa.nps-comment.dto.d.ts +7 -0
- package/dist/domain/nps/dto/pa.nps-comment.dto.js +2 -0
- package/dist/domain/nps/dto/pa.nps-reason.dto.d.ts +13 -0
- package/dist/domain/nps/dto/pa.nps-reason.dto.js +2 -0
- package/dist/domain/nps/enum/nps-answer-status.enum.d.ts +5 -0
- package/dist/domain/nps/enum/nps-answer-status.enum.js +9 -0
- package/dist/domain/nps/enum/nps-classification.enum.d.ts +5 -0
- package/dist/domain/nps/enum/nps-classification.enum.js +9 -0
- package/dist/domain/nps/enum/nps-detractor-reason.enum.d.ts +7 -0
- package/dist/domain/nps/enum/nps-detractor-reason.enum.js +11 -0
- package/dist/domain/nps/index.d.ts +8 -0
- package/dist/domain/nps/index.js +24 -0
- package/dist/domain/nps/nps.service.d.ts +11 -0
- package/dist/domain/nps/nps.service.js +22 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/infra/http/client.http.d.ts +9 -1
- package/dist/infra/http/client.http.js +10 -4
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApiIntegrationType } from './pa.get-integration-shop-by-login.dto';
|
|
2
|
+
export declare class PaGetIntegrationShopCredentialsResponse {
|
|
3
|
+
shopId: number;
|
|
4
|
+
integrationShopId: number;
|
|
5
|
+
integrationShopType: ApiIntegrationType;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
externId: string | null;
|
|
8
|
+
/** No Omie, a app_key. */
|
|
9
|
+
login: string | null;
|
|
10
|
+
/** No Omie, a app_secret. */
|
|
11
|
+
token: string | null;
|
|
12
|
+
password: string | null;
|
|
13
|
+
extraConfig: any;
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaGetIntegrationShopCredentialsResponse = void 0;
|
|
4
|
+
class PaGetIntegrationShopCredentialsResponse {
|
|
5
|
+
shopId;
|
|
6
|
+
integrationShopId;
|
|
7
|
+
integrationShopType;
|
|
8
|
+
enabled;
|
|
9
|
+
externId;
|
|
10
|
+
/** No Omie, a app_key. */
|
|
11
|
+
login;
|
|
12
|
+
/** No Omie, a app_secret. */
|
|
13
|
+
token;
|
|
14
|
+
password;
|
|
15
|
+
extraConfig;
|
|
16
|
+
}
|
|
17
|
+
exports.PaGetIntegrationShopCredentialsResponse = PaGetIntegrationShopCredentialsResponse;
|
|
@@ -2,9 +2,12 @@ export interface PaShopWithIntegrationResponse {
|
|
|
2
2
|
id: number;
|
|
3
3
|
name: string;
|
|
4
4
|
externId: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/** Não vem na listagem do Omie: ler `getIntegrationShopCredentials` da loja. */
|
|
6
|
+
login?: string;
|
|
7
|
+
/** Não vem na listagem do Omie. */
|
|
8
|
+
token?: string;
|
|
9
|
+
/** Não vem na listagem do Omie. */
|
|
10
|
+
password?: string;
|
|
8
11
|
extraConfig: any;
|
|
9
12
|
chainId: string;
|
|
10
13
|
integrationShopId: number;
|
|
@@ -2,3 +2,4 @@ export * from './integrationShop.service';
|
|
|
2
2
|
export * from './dto/pa.get-integration-shop-by-login.dto';
|
|
3
3
|
export * from './dto/pa.get-integration-shop-by-shop-id.dto';
|
|
4
4
|
export * from './dto/pa.edit-integration-shop.dto';
|
|
5
|
+
export * from './dto/pa.get-integration-shop-credentials.dto';
|
|
@@ -18,3 +18,4 @@ __exportStar(require("./integrationShop.service"), exports);
|
|
|
18
18
|
__exportStar(require("./dto/pa.get-integration-shop-by-login.dto"), exports);
|
|
19
19
|
__exportStar(require("./dto/pa.get-integration-shop-by-shop-id.dto"), exports);
|
|
20
20
|
__exportStar(require("./dto/pa.edit-integration-shop.dto"), exports);
|
|
21
|
+
__exportStar(require("./dto/pa.get-integration-shop-credentials.dto"), exports);
|
|
@@ -3,10 +3,16 @@ import { ApiIntegrationType, PaGetIntegrationShopByLoginResponse } from "./dto/p
|
|
|
3
3
|
import { PaEditIntegrationShopRequest, PaEditIntegrationShopResponse } from "./dto/pa.edit-integration-shop.dto";
|
|
4
4
|
import { PaShopWithIntegrationResponse } from "./dto/pa.get-shops-with-integration.dto";
|
|
5
5
|
import { PaGetIntegrationShopByShopIdResponse } from "./dto/pa.get-integration-shop-by-shop-id.dto";
|
|
6
|
+
import { PaGetIntegrationShopCredentialsResponse } from "./dto/pa.get-integration-shop-credentials.dto";
|
|
6
7
|
export declare class IntegrationShopService {
|
|
7
8
|
private readonly api;
|
|
8
9
|
constructor(api: HttpClient);
|
|
9
10
|
getIntegrationShopByShopId(shopId: number, integrationType: ApiIntegrationType | string): Promise<PaGetIntegrationShopByShopIdResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Credenciais da integração de uma loja (login, token, senha, externId, extraConfig). Só o
|
|
13
|
+
* token interno da tecpet tem acesso. O corpo da resposta não vai para o log.
|
|
14
|
+
*/
|
|
15
|
+
getIntegrationShopCredentials(shopId: number, integrationType: ApiIntegrationType | string): Promise<PaGetIntegrationShopCredentialsResponse>;
|
|
10
16
|
getIntegrationShopByLogin(type: ApiIntegrationType | string, login: string): Promise<PaGetIntegrationShopByLoginResponse>;
|
|
11
17
|
edit(body: PaEditIntegrationShopRequest, shopId: number): Promise<PaEditIntegrationShopResponse>;
|
|
12
18
|
getShopsWithIntegration(integrationType: string): Promise<PaShopWithIntegrationResponse[]>;
|
|
@@ -10,6 +10,14 @@ class IntegrationShopService {
|
|
|
10
10
|
const path = `/integrationShop/shop/type/${integrationType}`;
|
|
11
11
|
return await this.api.get(path, undefined, shopId);
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Credenciais da integração de uma loja (login, token, senha, externId, extraConfig). Só o
|
|
15
|
+
* token interno da tecpet tem acesso. O corpo da resposta não vai para o log.
|
|
16
|
+
*/
|
|
17
|
+
async getIntegrationShopCredentials(shopId, integrationType) {
|
|
18
|
+
const path = `/integrationShop/shop/type/${integrationType}/credentials`;
|
|
19
|
+
return await this.api.get(path, undefined, shopId, { sensitive: true });
|
|
20
|
+
}
|
|
13
21
|
async getIntegrationShopByLogin(type, login) {
|
|
14
22
|
const path = `/integrationShop/type/${type}/login/${login}`;
|
|
15
23
|
return await this.api.get(path);
|
|
@@ -14,7 +14,19 @@ export declare enum NotificationType {
|
|
|
14
14
|
SELECTED_INVOICES = "SELECTED_INVOICES",
|
|
15
15
|
CLIENT_REGISTER = "CLIENT_REGISTER",
|
|
16
16
|
PAY_INVOICE_VOUCHER = "PAY_INVOICE_VOUCHER",
|
|
17
|
+
QUOTE_SEND = "QUOTE_SEND",
|
|
17
18
|
AUTOMATION = "AUTOMATION",
|
|
18
19
|
PET_CARE_DOCUMENT = "PET_CARE_DOCUMENT",
|
|
19
|
-
CAMPAIGN = "CAMPAIGN"
|
|
20
|
+
CAMPAIGN = "CAMPAIGN",
|
|
21
|
+
NPS_SURVEY = "NPS_SURVEY",
|
|
22
|
+
NPS_GOOGLE_REVIEW = "NPS_GOOGLE_REVIEW",
|
|
23
|
+
NPS_DETRACTOR = "NPS_DETRACTOR",
|
|
24
|
+
CANCELED_NOT_REBOOKED = "CANCELED_NOT_REBOOKED",
|
|
25
|
+
INACTIVE_CLIENT = "INACTIVE_CLIENT",
|
|
26
|
+
WELCOME_NEW_CLIENT = "WELCOME_NEW_CLIENT",
|
|
27
|
+
VACCINE_DUE = "VACCINE_DUE",
|
|
28
|
+
CONSULTATION_RETURN = "CONSULTATION_RETURN",
|
|
29
|
+
PACKAGE_RUNNING_OUT = "PACKAGE_RUNNING_OUT",
|
|
30
|
+
PLAN_EXPIRING = "PLAN_EXPIRING",
|
|
31
|
+
CUSTOM = "CUSTOM"
|
|
20
32
|
}
|
|
@@ -18,7 +18,19 @@ var NotificationType;
|
|
|
18
18
|
NotificationType["SELECTED_INVOICES"] = "SELECTED_INVOICES";
|
|
19
19
|
NotificationType["CLIENT_REGISTER"] = "CLIENT_REGISTER";
|
|
20
20
|
NotificationType["PAY_INVOICE_VOUCHER"] = "PAY_INVOICE_VOUCHER";
|
|
21
|
+
NotificationType["QUOTE_SEND"] = "QUOTE_SEND";
|
|
21
22
|
NotificationType["AUTOMATION"] = "AUTOMATION";
|
|
22
23
|
NotificationType["PET_CARE_DOCUMENT"] = "PET_CARE_DOCUMENT";
|
|
23
24
|
NotificationType["CAMPAIGN"] = "CAMPAIGN";
|
|
25
|
+
NotificationType["NPS_SURVEY"] = "NPS_SURVEY";
|
|
26
|
+
NotificationType["NPS_GOOGLE_REVIEW"] = "NPS_GOOGLE_REVIEW";
|
|
27
|
+
NotificationType["NPS_DETRACTOR"] = "NPS_DETRACTOR";
|
|
28
|
+
NotificationType["CANCELED_NOT_REBOOKED"] = "CANCELED_NOT_REBOOKED";
|
|
29
|
+
NotificationType["INACTIVE_CLIENT"] = "INACTIVE_CLIENT";
|
|
30
|
+
NotificationType["WELCOME_NEW_CLIENT"] = "WELCOME_NEW_CLIENT";
|
|
31
|
+
NotificationType["VACCINE_DUE"] = "VACCINE_DUE";
|
|
32
|
+
NotificationType["CONSULTATION_RETURN"] = "CONSULTATION_RETURN";
|
|
33
|
+
NotificationType["PACKAGE_RUNNING_OUT"] = "PACKAGE_RUNNING_OUT";
|
|
34
|
+
NotificationType["PLAN_EXPIRING"] = "PLAN_EXPIRING";
|
|
35
|
+
NotificationType["CUSTOM"] = "CUSTOM";
|
|
24
36
|
})(NotificationType || (exports.NotificationType = NotificationType = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NpsAnswerStatus } from '../enum/nps-answer-status.enum';
|
|
2
|
+
import { NpsClassification } from '../enum/nps-classification.enum';
|
|
3
|
+
import { NpsReasonOption } from './pa.nps-reason.dto';
|
|
4
|
+
export type NpsAnswerSource = 'LIST' | 'TEXT';
|
|
5
|
+
export interface NpsAnswerInput {
|
|
6
|
+
score: number;
|
|
7
|
+
date: string;
|
|
8
|
+
source: NpsAnswerSource;
|
|
9
|
+
}
|
|
10
|
+
export interface NpsAnswerResponse {
|
|
11
|
+
status: NpsAnswerStatus;
|
|
12
|
+
classification: NpsClassification | null;
|
|
13
|
+
replyText: string;
|
|
14
|
+
awaitComment: boolean;
|
|
15
|
+
awaitReason: boolean;
|
|
16
|
+
reasonOptions: NpsReasonOption[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NpsDetractorReason } from '../enum/nps-detractor-reason.enum';
|
|
2
|
+
export interface NpsReasonOption {
|
|
3
|
+
reason: NpsDetractorReason;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export interface NpsReasonInput {
|
|
7
|
+
reason: NpsDetractorReason;
|
|
8
|
+
date: string;
|
|
9
|
+
}
|
|
10
|
+
export interface NpsReasonResponse {
|
|
11
|
+
replyText: string;
|
|
12
|
+
awaitComment: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NpsAnswerStatus = void 0;
|
|
4
|
+
var NpsAnswerStatus;
|
|
5
|
+
(function (NpsAnswerStatus) {
|
|
6
|
+
NpsAnswerStatus["RECORDED"] = "RECORDED";
|
|
7
|
+
NpsAnswerStatus["ALREADY_ANSWERED"] = "ALREADY_ANSWERED";
|
|
8
|
+
NpsAnswerStatus["EXPIRED"] = "EXPIRED";
|
|
9
|
+
})(NpsAnswerStatus || (exports.NpsAnswerStatus = NpsAnswerStatus = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NpsClassification = void 0;
|
|
4
|
+
var NpsClassification;
|
|
5
|
+
(function (NpsClassification) {
|
|
6
|
+
NpsClassification["PROMOTER"] = "PROMOTER";
|
|
7
|
+
NpsClassification["NEUTRAL"] = "NEUTRAL";
|
|
8
|
+
NpsClassification["DETRACTOR"] = "DETRACTOR";
|
|
9
|
+
})(NpsClassification || (exports.NpsClassification = NpsClassification = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NpsDetractorReason = void 0;
|
|
4
|
+
var NpsDetractorReason;
|
|
5
|
+
(function (NpsDetractorReason) {
|
|
6
|
+
NpsDetractorReason["SERVICE"] = "SERVICE";
|
|
7
|
+
NpsDetractorReason["PET_RESULT"] = "PET_RESULT";
|
|
8
|
+
NpsDetractorReason["DELAY"] = "DELAY";
|
|
9
|
+
NpsDetractorReason["PRICE"] = "PRICE";
|
|
10
|
+
NpsDetractorReason["OTHER"] = "OTHER";
|
|
11
|
+
})(NpsDetractorReason || (exports.NpsDetractorReason = NpsDetractorReason = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './dto/pa.nps-answer.dto';
|
|
2
|
+
export * from './dto/pa.nps-comment.dto';
|
|
3
|
+
export * from './dto/pa.nps-reason.dto';
|
|
4
|
+
export * from './dto/nps-survey-payload.dto';
|
|
5
|
+
export * from './enum/nps-answer-status.enum';
|
|
6
|
+
export * from './enum/nps-classification.enum';
|
|
7
|
+
export * from './enum/nps-detractor-reason.enum';
|
|
8
|
+
export * from './nps.service';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dto/pa.nps-answer.dto"), exports);
|
|
18
|
+
__exportStar(require("./dto/pa.nps-comment.dto"), exports);
|
|
19
|
+
__exportStar(require("./dto/pa.nps-reason.dto"), exports);
|
|
20
|
+
__exportStar(require("./dto/nps-survey-payload.dto"), exports);
|
|
21
|
+
__exportStar(require("./enum/nps-answer-status.enum"), exports);
|
|
22
|
+
__exportStar(require("./enum/nps-classification.enum"), exports);
|
|
23
|
+
__exportStar(require("./enum/nps-detractor-reason.enum"), exports);
|
|
24
|
+
__exportStar(require("./nps.service"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HttpClient } from "infra/http/client.http";
|
|
2
|
+
import { NpsAnswerInput, NpsAnswerResponse } from "./dto/pa.nps-answer.dto";
|
|
3
|
+
import { NpsCommentInput, NpsCommentResponse } from "./dto/pa.nps-comment.dto";
|
|
4
|
+
import { NpsReasonInput, NpsReasonResponse } from "./dto/pa.nps-reason.dto";
|
|
5
|
+
export declare class NpsService {
|
|
6
|
+
private readonly api;
|
|
7
|
+
constructor(api: HttpClient);
|
|
8
|
+
answer(surveyId: number, input: NpsAnswerInput): Promise<NpsAnswerResponse>;
|
|
9
|
+
comment(surveyId: number, input: NpsCommentInput): Promise<NpsCommentResponse>;
|
|
10
|
+
reason(surveyId: number, input: NpsReasonInput): Promise<NpsReasonResponse>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NpsService = void 0;
|
|
4
|
+
class NpsService {
|
|
5
|
+
api;
|
|
6
|
+
constructor(api) {
|
|
7
|
+
this.api = api;
|
|
8
|
+
}
|
|
9
|
+
async answer(surveyId, input) {
|
|
10
|
+
const response = await this.api.post(`/nps/survey/${surveyId}/answer`, input);
|
|
11
|
+
return response;
|
|
12
|
+
}
|
|
13
|
+
async comment(surveyId, input) {
|
|
14
|
+
const response = await this.api.post(`/nps/survey/${surveyId}/comment`, input);
|
|
15
|
+
return response;
|
|
16
|
+
}
|
|
17
|
+
async reason(surveyId, input) {
|
|
18
|
+
const response = await this.api.post(`/nps/survey/${surveyId}/reason`, input);
|
|
19
|
+
return response;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.NpsService = NpsService;
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { WhatsappEventService } from "./domain/whatsappEvent/whatsappEvent.servi
|
|
|
27
27
|
import { AISettingsService } from "./domain/aiSettings/aiSettings.service";
|
|
28
28
|
import { CampaignService } from "./domain/campaign/campaign.service";
|
|
29
29
|
import { PetPlanService } from "./domain/petPlan/petPlan.service";
|
|
30
|
+
import { NpsService } from "./domain/nps/nps.service";
|
|
30
31
|
export declare class TecpetSDK {
|
|
31
32
|
private api;
|
|
32
33
|
client: ClientService;
|
|
@@ -58,6 +59,7 @@ export declare class TecpetSDK {
|
|
|
58
59
|
aiSettings: AISettingsService;
|
|
59
60
|
campaign: CampaignService;
|
|
60
61
|
petPlan: PetPlanService;
|
|
62
|
+
nps: NpsService;
|
|
61
63
|
constructor(baseURL: string, apiKey?: string);
|
|
62
64
|
}
|
|
63
65
|
export * from './domain/availableTimes';
|
|
@@ -92,3 +94,4 @@ export * from './domain/whatsappEvent';
|
|
|
92
94
|
export * from './domain/aiSettings';
|
|
93
95
|
export * from './domain/campaign';
|
|
94
96
|
export * from './domain/notification';
|
|
97
|
+
export * from './domain/nps';
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,7 @@ const whatsappEvent_service_1 = require("./domain/whatsappEvent/whatsappEvent.se
|
|
|
45
45
|
const aiSettings_service_1 = require("./domain/aiSettings/aiSettings.service");
|
|
46
46
|
const campaign_service_1 = require("./domain/campaign/campaign.service");
|
|
47
47
|
const petPlan_service_1 = require("./domain/petPlan/petPlan.service");
|
|
48
|
+
const nps_service_1 = require("./domain/nps/nps.service");
|
|
48
49
|
class TecpetSDK {
|
|
49
50
|
api;
|
|
50
51
|
client;
|
|
@@ -76,6 +77,7 @@ class TecpetSDK {
|
|
|
76
77
|
aiSettings;
|
|
77
78
|
campaign;
|
|
78
79
|
petPlan;
|
|
80
|
+
nps;
|
|
79
81
|
constructor(baseURL, apiKey) {
|
|
80
82
|
this.api = new client_http_1.HttpClient(baseURL, apiKey);
|
|
81
83
|
this.client = new client_service_1.ClientService(this.api);
|
|
@@ -107,6 +109,7 @@ class TecpetSDK {
|
|
|
107
109
|
this.aiSettings = new aiSettings_service_1.AISettingsService(this.api);
|
|
108
110
|
this.campaign = new campaign_service_1.CampaignService(this.api);
|
|
109
111
|
this.petPlan = new petPlan_service_1.PetPlanService(this.api);
|
|
112
|
+
this.nps = new nps_service_1.NpsService(this.api);
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
exports.TecpetSDK = TecpetSDK;
|
|
@@ -142,3 +145,4 @@ __exportStar(require("./domain/whatsappEvent"), exports);
|
|
|
142
145
|
__exportStar(require("./domain/aiSettings"), exports);
|
|
143
146
|
__exportStar(require("./domain/campaign"), exports);
|
|
144
147
|
__exportStar(require("./domain/notification"), exports);
|
|
148
|
+
__exportStar(require("./domain/nps"), exports);
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opções de uma chamada. `sensitive` tira o corpo da resposta do log (sucesso e erro), para
|
|
3
|
+
* rotas que devolvem credenciais.
|
|
4
|
+
*/
|
|
5
|
+
export interface HttpRequestOptions {
|
|
6
|
+
sensitive?: boolean;
|
|
7
|
+
}
|
|
1
8
|
export declare class HttpClient {
|
|
2
9
|
private readonly apiUrl;
|
|
3
10
|
private readonly apiKey?;
|
|
4
11
|
private readonly client;
|
|
5
12
|
constructor(apiUrl: string, apiKey?: string | undefined);
|
|
6
|
-
get<T>(path: string, payload?: any, shopId?: number): Promise<T>;
|
|
13
|
+
get<T>(path: string, payload?: any, shopId?: number, options?: HttpRequestOptions): Promise<T>;
|
|
7
14
|
post<T>(path: string, payload?: any, shopId?: number): Promise<T>;
|
|
8
15
|
put<T>(path: string, payload?: any, shopId?: number): Promise<T>;
|
|
9
16
|
patch<T>(path: string, payload?: any, shopId?: number): Promise<T>;
|
|
10
17
|
delete<T>(path: string, shopId?: number): Promise<T>;
|
|
11
18
|
private headers;
|
|
19
|
+
private isSensitive;
|
|
12
20
|
private shop;
|
|
13
21
|
/**
|
|
14
22
|
* Repassa o corpo cru do erro da API. Sem resposta (timeout, falha de rede) ou com
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.HttpClient = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const stdout_logger_1 = require("../logger/stdout.logger");
|
|
9
|
+
const REDACTED = '[redacted]';
|
|
9
10
|
class HttpClient {
|
|
10
11
|
apiUrl;
|
|
11
12
|
apiKey;
|
|
@@ -26,19 +27,21 @@ class HttpClient {
|
|
|
26
27
|
return config;
|
|
27
28
|
});
|
|
28
29
|
this.client.interceptors.response.use((response) => {
|
|
29
|
-
|
|
30
|
+
const data = this.isSensitive(response.config) ? REDACTED : response?.data;
|
|
31
|
+
stdout_logger_1.logger.debug('tecpet-sdk', `[HTTP] ${this.shop(response.config.headers)} ← ${response.status} ${response.config.url}`, data);
|
|
30
32
|
return response;
|
|
31
33
|
}, (error) => {
|
|
32
34
|
stdout_logger_1.logger.error('tecpet-sdk', `[HTTP] ${this.shop(error?.config?.headers)} ← Error: ${error.message}`);
|
|
33
35
|
if (error.response) {
|
|
34
|
-
|
|
36
|
+
const data = this.isSensitive(error?.config) ? REDACTED : error?.response?.data;
|
|
37
|
+
stdout_logger_1.logger.error('tecpet-sdk', `[HTTP] ${this.shop(error?.config?.headers)} ← Response:`, data);
|
|
35
38
|
}
|
|
36
39
|
return Promise.reject(error);
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
|
-
async get(path, payload, shopId) {
|
|
42
|
+
async get(path, payload, shopId, options) {
|
|
40
43
|
try {
|
|
41
|
-
const response = await this.client.get(path, { params: payload, headers: this.headers({ shopId }) });
|
|
44
|
+
const response = await this.client.get(path, { params: payload, headers: this.headers({ shopId }), ...(options?.sensitive ? { sensitive: true } : {}) });
|
|
42
45
|
return response?.data;
|
|
43
46
|
}
|
|
44
47
|
catch (error) {
|
|
@@ -90,6 +93,9 @@ class HttpClient {
|
|
|
90
93
|
}
|
|
91
94
|
return this.client.defaults.headers.common;
|
|
92
95
|
}
|
|
96
|
+
isSensitive(config) {
|
|
97
|
+
return config?.sensitive === true;
|
|
98
|
+
}
|
|
93
99
|
shop(headers) {
|
|
94
100
|
const shop = headers?.['x-shop']?.toString();
|
|
95
101
|
return shop ? `shop=${shop}` : '';
|