@accon/connect 0.2.0 → 0.3.1
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/core/types/integration-event.type.d.ts +1 -1
- package/dist/core/types/order.type.d.ts +1 -0
- package/dist/logistics/foody/foody.order-output.js +6 -5
- package/dist/logistics/foody/foody.order-output.js.map +1 -1
- package/dist/order/accon/accon-webhook.config.d.ts +25 -0
- package/dist/order/accon/accon-webhook.config.js +27 -0
- package/dist/order/accon/accon-webhook.config.js.map +1 -0
- package/dist/order/accon/accon-webhook.order-output.d.ts +34 -0
- package/dist/order/accon/accon-webhook.order-output.js +314 -0
- package/dist/order/accon/accon-webhook.order-output.js.map +1 -0
- package/dist/order/accon/dto/accon-webhook/index.d.ts +1 -0
- package/dist/order/accon/dto/accon-webhook/index.js +18 -0
- package/dist/order/accon/dto/accon-webhook/index.js.map +1 -0
- package/dist/order/accon/dto/accon-webhook/webhook-body.dto.d.ts +107 -0
- package/dist/order/accon/dto/accon-webhook/webhook-body.dto.js +107 -0
- package/dist/order/accon/dto/accon-webhook/webhook-body.dto.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ export type IntegrationEventType = 'INTEGRATION_INITIATED' | 'INTEGRATION_REQUES
|
|
|
3
3
|
export interface IntegrationEvent {
|
|
4
4
|
integrationName: string;
|
|
5
5
|
integrationType: IntegrationType;
|
|
6
|
-
orderId:
|
|
6
|
+
orderId: number;
|
|
7
7
|
eventType: IntegrationEventType;
|
|
8
8
|
externalId?: string;
|
|
9
9
|
description: string;
|
|
@@ -30,6 +30,7 @@ let FoodyOrderOutput = FoodyOrderOutput_1 = class FoodyOrderOutput {
|
|
|
30
30
|
}
|
|
31
31
|
async onOrderCreated(payload, config) {
|
|
32
32
|
const { order } = payload;
|
|
33
|
+
const orderId = parseInt(order.externalId);
|
|
33
34
|
this.logger.verbose('onOrderCreated: iniciando integração');
|
|
34
35
|
if (order.type != 'DELIVERY') {
|
|
35
36
|
this.logger.verbose('Ignorando pedido com tipo diferente de DELIVERY');
|
|
@@ -38,12 +39,12 @@ let FoodyOrderOutput = FoodyOrderOutput_1 = class FoodyOrderOutput {
|
|
|
38
39
|
try {
|
|
39
40
|
this.dispatchEvent({
|
|
40
41
|
eventType: 'INTEGRATION_INITIATED',
|
|
41
|
-
orderId
|
|
42
|
+
orderId,
|
|
42
43
|
});
|
|
43
44
|
this.logger.debug(`onOrderCreated: Transformando o pedido com id: ${order.id}`);
|
|
44
45
|
this.dispatchEvent({
|
|
45
46
|
eventType: 'INTEGRATION_PROCESSING',
|
|
46
|
-
orderId
|
|
47
|
+
orderId,
|
|
47
48
|
});
|
|
48
49
|
const body = this.transformOrder(order);
|
|
49
50
|
this.logger.debug('onOrderCreated: Pedido transformado', body);
|
|
@@ -54,7 +55,7 @@ let FoodyOrderOutput = FoodyOrderOutput_1 = class FoodyOrderOutput {
|
|
|
54
55
|
this.logger.debug('onOrderCreated: Resposta do Foody', data);
|
|
55
56
|
this.dispatchEvent({
|
|
56
57
|
eventType: 'INTEGRATION_COMPLETED',
|
|
57
|
-
orderId
|
|
58
|
+
orderId,
|
|
58
59
|
metadata: { data },
|
|
59
60
|
});
|
|
60
61
|
}
|
|
@@ -63,14 +64,14 @@ let FoodyOrderOutput = FoodyOrderOutput_1 = class FoodyOrderOutput {
|
|
|
63
64
|
this.logger.error('onOrderCreated: falha ao realizar requisição no Foody', JSON.stringify(error.response?.data));
|
|
64
65
|
this.dispatchEvent({
|
|
65
66
|
eventType: 'INTEGRATION_FAILED',
|
|
66
|
-
orderId
|
|
67
|
+
orderId,
|
|
67
68
|
metadata: { error: error.response?.data },
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
else {
|
|
71
72
|
this.dispatchEvent({
|
|
72
73
|
eventType: 'INTEGRATION_FAILED',
|
|
73
|
-
orderId
|
|
74
|
+
orderId,
|
|
74
75
|
metadata: { error },
|
|
75
76
|
});
|
|
76
77
|
this.logger.error('onOrderCreated: falha ao criar pedido no Foody', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"foody.order-output.js","sourceRoot":"","sources":["../../../lib/logistics/foody/foody.order-output.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,oCAQmB;AACnB,iDAAkE;AAElE,yCAA4C;AAC5C,+BAAsC;AAEtC,iCAAoD;AAe7C,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAMhB;IACQ;IANF,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAgB,CAAC,IAAI,CAAC,CAAC;IAC3C,QAAQ,GAAG,wCAAwC,CAAC;IACpD,aAAa,CAA6B;IAE3D,YACW,aAA4B,EACpB,WAAwB;QADhC,kBAAa,GAAb,aAAa,CAAe;QACpB,gBAAW,GAAX,WAAW,CAAa;QAEzC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,mBAAmB,CACpD,OAAO,EACP,aAAa,CACd,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,OAA2B,EAC3B,MAAmB;QAEnB,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC;QAC5D,IAAI,KAAK,CAAC,IAAI,IAAI,UAAU,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iDAAiD,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,IAAI,CAAC,aAAa,CAAC;gBACjB,SAAS,EAAE,uBAAuB;gBAClC,OAAO
|
|
1
|
+
{"version":3,"file":"foody.order-output.js","sourceRoot":"","sources":["../../../lib/logistics/foody/foody.order-output.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,oCAQmB;AACnB,iDAAkE;AAElE,yCAA4C;AAC5C,+BAAsC;AAEtC,iCAAo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AAA,mBAAU,GAAE;qCAOe,oBAAa;QACP,mBAAW;GAPhC,gBAAgB,CAkK5B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FromSchema } from 'json-schema-to-ts';
|
|
2
|
+
export declare const ACCON_WEBHOOK_CONFIG_SCHEMA: {
|
|
3
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
4
|
+
readonly title: "Accon Webhook Configuration";
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly onCreatedURL: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly title: "URL Pedido Criado";
|
|
10
|
+
readonly description: "URL para ser enviado a notificação de novo pedido";
|
|
11
|
+
};
|
|
12
|
+
readonly onUpdatedURL: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly title: "URL Pedido Atualizado";
|
|
15
|
+
readonly description: "URL para ser enviado a notificação de atualização do pedido";
|
|
16
|
+
};
|
|
17
|
+
readonly onCanceledURL: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly title: "URL Pedido Cancelado";
|
|
20
|
+
readonly description: "URL para ser enviado a notificação de cancelamento do pedido";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly required: readonly ["onCreatedURL"];
|
|
24
|
+
};
|
|
25
|
+
export type AcconWebhookConfig = FromSchema<typeof ACCON_WEBHOOK_CONFIG_SCHEMA>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ACCON_WEBHOOK_CONFIG_SCHEMA = void 0;
|
|
4
|
+
exports.ACCON_WEBHOOK_CONFIG_SCHEMA = {
|
|
5
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
6
|
+
title: 'Accon Webhook Configuration',
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
onCreatedURL: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
title: 'URL Pedido Criado',
|
|
12
|
+
description: 'URL para ser enviado a notificação de novo pedido',
|
|
13
|
+
},
|
|
14
|
+
onUpdatedURL: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
title: 'URL Pedido Atualizado',
|
|
17
|
+
description: 'URL para ser enviado a notificação de atualização do pedido',
|
|
18
|
+
},
|
|
19
|
+
onCanceledURL: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
title: 'URL Pedido Cancelado',
|
|
22
|
+
description: 'URL para ser enviado a notificação de cancelamento do pedido',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
required: ['onCreatedURL'],
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=accon-webhook.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accon-webhook.config.js","sourceRoot":"","sources":["../../../lib/order/accon/accon-webhook.config.ts"],"names":[],"mappings":";;;AAEa,QAAA,2BAA2B,GAAG;IACzC,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,6BAA6B;IACpC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,mBAAmB;YAC1B,WAAW,EAAE,mDAAmD;SACjE;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EACT,6DAA6D;SAChE;QACD,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EACT,8DAA8D;SACjE;KACF;IACD,QAAQ,EAAE,CAAC,cAAc,CAAC;CACG,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Order, OrderOutputIntegration, IntegrationPayload, EventsService } from '../../core/index.js';
|
|
2
|
+
import { AcconWebhookConfig } from './accon-webhook.config';
|
|
3
|
+
import { PaymentDto, ProductDto, StatusDto, WebhookBodyDto } from './dto/accon-webhook';
|
|
4
|
+
import { HttpService } from '@nestjs/axios';
|
|
5
|
+
import { OrderEvent } from '../../core/types/order-event.type';
|
|
6
|
+
type HookType = 'onOrderCreated' | 'onOrderUpdated' | 'onOrderCanceled';
|
|
7
|
+
export declare class AcconWebhookOrderOutput implements OrderOutputIntegration<AcconWebhookConfig> {
|
|
8
|
+
private readonly httpService;
|
|
9
|
+
readonly eventsService: EventsService;
|
|
10
|
+
private readonly dispatchEvent;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
constructor(httpService: HttpService, eventsService: EventsService);
|
|
13
|
+
onOrderCreated(payload: IntegrationPayload, config: AcconWebhookConfig): Promise<void>;
|
|
14
|
+
onOrderUpdated?(payload: IntegrationPayload, config: AcconWebhookConfig): Promise<void>;
|
|
15
|
+
onOrderCanceled?(payload: IntegrationPayload, config: AcconWebhookConfig): Promise<void>;
|
|
16
|
+
callHook(type: HookType, payload: IntegrationPayload, config: AcconWebhookConfig): Promise<void>;
|
|
17
|
+
transformOrder(payload: IntegrationPayload): WebhookBodyDto;
|
|
18
|
+
transformProducts(order: Order): ProductDto[];
|
|
19
|
+
transformVoucher(order: Order): {
|
|
20
|
+
rede: string;
|
|
21
|
+
stores: string[];
|
|
22
|
+
fidelity: boolean;
|
|
23
|
+
name: string;
|
|
24
|
+
text: string;
|
|
25
|
+
products: never[];
|
|
26
|
+
is_active: boolean;
|
|
27
|
+
value: number;
|
|
28
|
+
percent: boolean;
|
|
29
|
+
recurrent: boolean;
|
|
30
|
+
}[];
|
|
31
|
+
transformEvents(events: OrderEvent[]): StatusDto[];
|
|
32
|
+
transformPayment(order: Order): PaymentDto;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var AcconWebhookOrderOutput_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AcconWebhookOrderOutput = void 0;
|
|
14
|
+
const core_1 = require("../../core/index.js");
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
const accon_webhook_config_1 = require("./accon-webhook.config");
|
|
17
|
+
const invalid_payload_exception_1 = require("../../core/exceptions/invalid-payload.exception");
|
|
18
|
+
const axios_1 = require("@nestjs/axios");
|
|
19
|
+
const rxjs_1 = require("rxjs");
|
|
20
|
+
const axios_2 = require("axios");
|
|
21
|
+
const order_event_type_1 = require("../../core/types/order-event.type");
|
|
22
|
+
let AcconWebhookOrderOutput = AcconWebhookOrderOutput_1 = class AcconWebhookOrderOutput {
|
|
23
|
+
httpService;
|
|
24
|
+
eventsService;
|
|
25
|
+
dispatchEvent;
|
|
26
|
+
logger = new common_1.Logger(AcconWebhookOrderOutput_1.name);
|
|
27
|
+
constructor(httpService, eventsService) {
|
|
28
|
+
this.httpService = httpService;
|
|
29
|
+
this.eventsService = eventsService;
|
|
30
|
+
this.dispatchEvent = eventsService.createDispatcherFor('Accon Webhook', 'OrderOutput');
|
|
31
|
+
}
|
|
32
|
+
onOrderCreated(payload, config) {
|
|
33
|
+
return this.callHook('onOrderCreated', payload, config);
|
|
34
|
+
}
|
|
35
|
+
onOrderUpdated(payload, config) {
|
|
36
|
+
return this.callHook('onOrderUpdated', payload, config);
|
|
37
|
+
}
|
|
38
|
+
onOrderCanceled(payload, config) {
|
|
39
|
+
return this.callHook('onOrderCanceled', payload, config);
|
|
40
|
+
}
|
|
41
|
+
async callHook(type, payload, config) {
|
|
42
|
+
const key = {
|
|
43
|
+
onOrderCreated: 'onCreatedURL',
|
|
44
|
+
onOrderUpdated: 'onUpdatedURL',
|
|
45
|
+
onOrderCanceled: 'onCanceledURL',
|
|
46
|
+
};
|
|
47
|
+
const url = config[key[type]];
|
|
48
|
+
if (typeof url !== 'string') {
|
|
49
|
+
this.logger.warn(`${type}: Configuração de URL ausente`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const { order } = payload;
|
|
53
|
+
const orderId = parseInt(order.externalId);
|
|
54
|
+
this.dispatchEvent({
|
|
55
|
+
eventType: 'INTEGRATION_INITIATED',
|
|
56
|
+
orderId,
|
|
57
|
+
});
|
|
58
|
+
this.logger.debug(`${type}: Transformando o pedido com id: ${order.id}`);
|
|
59
|
+
this.dispatchEvent({
|
|
60
|
+
eventType: 'INTEGRATION_PROCESSING',
|
|
61
|
+
orderId,
|
|
62
|
+
});
|
|
63
|
+
const body = this.transformOrder(payload);
|
|
64
|
+
this.logger.debug(`${type}: Pedido transformado`, body);
|
|
65
|
+
try {
|
|
66
|
+
const { status, data } = await (0, rxjs_1.firstValueFrom)(this.httpService.post(url, body, { timeout: 5000 }));
|
|
67
|
+
this.dispatchEvent({
|
|
68
|
+
eventType: 'INTEGRATION_COMPLETED',
|
|
69
|
+
orderId,
|
|
70
|
+
metadata: { data, status },
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if ((0, axios_2.isAxiosError)(error)) {
|
|
75
|
+
const errorData = error.response?.data ?? error.message;
|
|
76
|
+
this.logger.error(`${type}: falha ao enviar para ${url}`, errorData);
|
|
77
|
+
this.dispatchEvent({
|
|
78
|
+
eventType: 'INTEGRATION_FAILED',
|
|
79
|
+
orderId,
|
|
80
|
+
metadata: { error: error.response?.data },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.dispatchEvent({
|
|
85
|
+
eventType: 'INTEGRATION_FAILED',
|
|
86
|
+
orderId,
|
|
87
|
+
metadata: { error },
|
|
88
|
+
});
|
|
89
|
+
this.logger.error(`${type}: ${error.message}`, error);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
transformOrder(payload) {
|
|
94
|
+
const { order, merchant, events } = payload;
|
|
95
|
+
if (!merchant) {
|
|
96
|
+
throw new invalid_payload_exception_1.InvalidPayloadException('Os dados do estabelecimento são obrigatórios para integração', 'merchant');
|
|
97
|
+
}
|
|
98
|
+
if (!order.customer) {
|
|
99
|
+
throw new core_1.InvalidOrderException('O pedido não possui cliente', 'customer');
|
|
100
|
+
}
|
|
101
|
+
const deliveryFee = order.otherFees.find(({ type }) => type === 'DELIVERY_FEE');
|
|
102
|
+
const { delivery } = order;
|
|
103
|
+
const changeFor = order.payments.methods?.reduce((acc, method) => {
|
|
104
|
+
return acc + (method.changeFor ?? 0);
|
|
105
|
+
}, 0);
|
|
106
|
+
return {
|
|
107
|
+
_id: order.id,
|
|
108
|
+
delivery: order.type === 'DELIVERY',
|
|
109
|
+
canceled: events?.some(({ eventType }) => eventType === order_event_type_1.OrderEventType.CANCELLED) || false,
|
|
110
|
+
scheduled: order.orderTiming === 'SCHEDULED',
|
|
111
|
+
sequential: order.displayId,
|
|
112
|
+
store: {
|
|
113
|
+
_id: order.merchant.id,
|
|
114
|
+
name: order.merchant.name,
|
|
115
|
+
address: {
|
|
116
|
+
address: merchant.address.street,
|
|
117
|
+
number: merchant.address.number,
|
|
118
|
+
complement: merchant.address.complement ?? undefined,
|
|
119
|
+
city: merchant.address.city,
|
|
120
|
+
state: merchant.address.state,
|
|
121
|
+
zip: merchant.address.postalCode,
|
|
122
|
+
latlng: {
|
|
123
|
+
lat: parseFloat(merchant.address.latitude.toString()),
|
|
124
|
+
lng: parseFloat(merchant.address.longitude.toString()),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
details: {
|
|
128
|
+
document: merchant.document,
|
|
129
|
+
email: merchant.contactEmails[0],
|
|
130
|
+
phone: merchant.commercialNumber,
|
|
131
|
+
socialName: merchant.corporateName,
|
|
132
|
+
storePhone: merchant.commercialNumber,
|
|
133
|
+
},
|
|
134
|
+
deliveryTime: '40',
|
|
135
|
+
toGoTime: '30',
|
|
136
|
+
},
|
|
137
|
+
deliveryTax: deliveryFee?.price?.value || 0,
|
|
138
|
+
address: delivery?.deliveryAddress
|
|
139
|
+
? {
|
|
140
|
+
address: delivery.deliveryAddress.street,
|
|
141
|
+
number: delivery.deliveryAddress.number,
|
|
142
|
+
complement: delivery.deliveryAddress.complement,
|
|
143
|
+
city: delivery.deliveryAddress.city,
|
|
144
|
+
state: delivery.deliveryAddress.state,
|
|
145
|
+
zip: delivery.deliveryAddress.postalCode,
|
|
146
|
+
latlng: {
|
|
147
|
+
lat: parseFloat(delivery.deliveryAddress.coordinates.latitude.toString()),
|
|
148
|
+
lng: parseFloat(delivery.deliveryAddress.coordinates.longitude.toString()),
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
: undefined,
|
|
152
|
+
date: order.createdAt,
|
|
153
|
+
scheduledDate: order.schedule?.scheduledDateTimeStart,
|
|
154
|
+
subtotal: order.total.itemsPrice.value,
|
|
155
|
+
discount: order.total.discount.value,
|
|
156
|
+
total: order.total.orderAmount.value,
|
|
157
|
+
status: this.transformEvents(events ?? []),
|
|
158
|
+
user: {
|
|
159
|
+
_id: order.customer.id,
|
|
160
|
+
name: order.customer.name,
|
|
161
|
+
phone: order.customer.phone.number,
|
|
162
|
+
email: order.customer.email,
|
|
163
|
+
document: order.customer.documentNumber,
|
|
164
|
+
totalOrders: order.customer.ordersCountOnMerchant,
|
|
165
|
+
},
|
|
166
|
+
notes: order.extraInfo,
|
|
167
|
+
change: changeFor,
|
|
168
|
+
source: order.salesChannel ?? 'ecommerce',
|
|
169
|
+
network: '000000000000000000000000',
|
|
170
|
+
payment: this.transformPayment(order),
|
|
171
|
+
voucher: this.transformVoucher(order),
|
|
172
|
+
products: this.transformProducts(order),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
transformProducts(order) {
|
|
176
|
+
return order.items.map((item, index) => ({
|
|
177
|
+
id: item.id,
|
|
178
|
+
name: item.name,
|
|
179
|
+
notes: item.specialInstructions ?? '',
|
|
180
|
+
quantity: item.quantity,
|
|
181
|
+
total: item.totalPrice.value,
|
|
182
|
+
modifiers: (item.options ?? []).map((modifier) => ({
|
|
183
|
+
id: modifier.id,
|
|
184
|
+
name: modifier.name,
|
|
185
|
+
price: {
|
|
186
|
+
actualPrice: modifier.unitPrice.value,
|
|
187
|
+
originalPrice: 0,
|
|
188
|
+
starterPrice: 0,
|
|
189
|
+
},
|
|
190
|
+
quantity: modifier.quantity,
|
|
191
|
+
group: index.toString(),
|
|
192
|
+
externalVendorCode: modifier.externalCode,
|
|
193
|
+
})),
|
|
194
|
+
group: index.toString(),
|
|
195
|
+
externalVendorCode: item.externalCode,
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
transformVoucher(order) {
|
|
199
|
+
return order.discounts
|
|
200
|
+
.filter((discount) => discount.sponsorshipValues.length > 0)
|
|
201
|
+
.map((discount) => {
|
|
202
|
+
const sponsorship = discount.sponsorshipValues[0];
|
|
203
|
+
return {
|
|
204
|
+
rede: '000000000000000000000000',
|
|
205
|
+
stores: [order.merchant.id],
|
|
206
|
+
fidelity: sponsorship?.discountCode === 'CASHBACK',
|
|
207
|
+
name: sponsorship?.name ?? '',
|
|
208
|
+
text: sponsorship?.discountCode ?? '',
|
|
209
|
+
products: [],
|
|
210
|
+
is_active: true,
|
|
211
|
+
value: discount.amount.value,
|
|
212
|
+
percent: false,
|
|
213
|
+
recurrent: false,
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
transformEvents(events) {
|
|
218
|
+
if (!events.length) {
|
|
219
|
+
return [
|
|
220
|
+
{
|
|
221
|
+
name: 'Realizado',
|
|
222
|
+
obs: '',
|
|
223
|
+
date: new Date().toISOString(),
|
|
224
|
+
},
|
|
225
|
+
];
|
|
226
|
+
}
|
|
227
|
+
const ACCON_ALLOWED_STATUS = [
|
|
228
|
+
order_event_type_1.OrderEventType.CREATED,
|
|
229
|
+
order_event_type_1.OrderEventType.CONFIRMED,
|
|
230
|
+
order_event_type_1.OrderEventType.READY_FOR_PICKUP,
|
|
231
|
+
order_event_type_1.OrderEventType.DISPATCHED,
|
|
232
|
+
order_event_type_1.OrderEventType.CONCLUDED,
|
|
233
|
+
order_event_type_1.OrderEventType.CANCELLED,
|
|
234
|
+
];
|
|
235
|
+
const allowedEvents = events.filter((event) => ACCON_ALLOWED_STATUS.includes(event.eventType));
|
|
236
|
+
return allowedEvents
|
|
237
|
+
.map((event) => ({
|
|
238
|
+
date: new Date(event.createdAt).toISOString(),
|
|
239
|
+
obs: '',
|
|
240
|
+
name: ((eventType) => {
|
|
241
|
+
switch (eventType) {
|
|
242
|
+
case order_event_type_1.OrderEventType.CREATED:
|
|
243
|
+
return 'Realizado';
|
|
244
|
+
case order_event_type_1.OrderEventType.CONFIRMED:
|
|
245
|
+
return 'confirmado';
|
|
246
|
+
case order_event_type_1.OrderEventType.DISPATCHED:
|
|
247
|
+
case order_event_type_1.OrderEventType.READY_FOR_PICKUP:
|
|
248
|
+
return 'pronto';
|
|
249
|
+
case order_event_type_1.OrderEventType.DELIVERED:
|
|
250
|
+
case order_event_type_1.OrderEventType.CONCLUDED:
|
|
251
|
+
return 'finalizado';
|
|
252
|
+
case order_event_type_1.OrderEventType.CANCELLED:
|
|
253
|
+
return 'cancelado';
|
|
254
|
+
default:
|
|
255
|
+
throw new Error(`Invalid status eventType: ${eventType}`);
|
|
256
|
+
}
|
|
257
|
+
})(event.eventType),
|
|
258
|
+
}))
|
|
259
|
+
.sort((a, b) => a.date.localeCompare(b.date));
|
|
260
|
+
}
|
|
261
|
+
transformPayment(order) {
|
|
262
|
+
if (order.payments.methods.length !== 1) {
|
|
263
|
+
throw new core_1.InvalidOrderException('O pedido deve possuír apenas um método de pagamento', 'payments');
|
|
264
|
+
}
|
|
265
|
+
const { type, method, brand, transaction } = order.payments.methods[0];
|
|
266
|
+
const online = type === 'PREPAID';
|
|
267
|
+
const METHOD_NAMES = new Map([
|
|
268
|
+
['PIX', 'Pix'],
|
|
269
|
+
['CASH', 'Dinheiro'],
|
|
270
|
+
['CREDIT', 'Crédito'],
|
|
271
|
+
['DEBIT', 'Débito'],
|
|
272
|
+
['MEAL_VOUCHER', 'Voucher'],
|
|
273
|
+
['FOOD_VOUCHER', 'Carteira Digital'],
|
|
274
|
+
['DIGITAL_WALLET', 'Carteira Digital'],
|
|
275
|
+
['CREDIT_DEBIT', 'Cartão de Crédito/Débito'],
|
|
276
|
+
['COUPON', 'Cupom'],
|
|
277
|
+
['REDEEM', 'Outros'],
|
|
278
|
+
['PREPAID_REDEEM', 'Outros'],
|
|
279
|
+
['OTHER', 'Outros'],
|
|
280
|
+
]);
|
|
281
|
+
const CARD_METHODS = [
|
|
282
|
+
'CREDIT',
|
|
283
|
+
'CREDIT_DEBIT',
|
|
284
|
+
'DEBIT',
|
|
285
|
+
];
|
|
286
|
+
return {
|
|
287
|
+
cod: online ? '5c51aeba22c5d6596c5ac4b0' : '64554e3809a8eead82e2d4f2',
|
|
288
|
+
online,
|
|
289
|
+
pix: online && method === 'PIX',
|
|
290
|
+
tid: transaction?.authorizationCode,
|
|
291
|
+
authorizationCode: transaction?.authorizationCode,
|
|
292
|
+
name: CARD_METHODS.includes(method) && brand
|
|
293
|
+
? brand
|
|
294
|
+
: (METHOD_NAMES.get(method) ?? 'Outros'),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
exports.AcconWebhookOrderOutput = AcconWebhookOrderOutput;
|
|
299
|
+
exports.AcconWebhookOrderOutput = AcconWebhookOrderOutput = AcconWebhookOrderOutput_1 = __decorate([
|
|
300
|
+
(0, core_1.RegistryIntegration)({
|
|
301
|
+
id: 'accon-webhook',
|
|
302
|
+
type: 'OrderOutput',
|
|
303
|
+
title: 'Accon 1.0 Webhook',
|
|
304
|
+
category: 'POS',
|
|
305
|
+
description: 'Integre pedidos via Webhook utilizando o formato da Accon 1.0',
|
|
306
|
+
logoUrl: 'https://accon.com.br/wp-content/uploads/2024/08/Accon-Logo-Roxa.webp',
|
|
307
|
+
websiteUrl: 'https://accon.com.br/',
|
|
308
|
+
configSchema: accon_webhook_config_1.ACCON_WEBHOOK_CONFIG_SCHEMA,
|
|
309
|
+
}),
|
|
310
|
+
(0, common_1.Injectable)(),
|
|
311
|
+
__metadata("design:paramtypes", [axios_1.HttpService,
|
|
312
|
+
core_1.EventsService])
|
|
313
|
+
], AcconWebhookOrderOutput);
|
|
314
|
+
//# sourceMappingURL=accon-webhook.order-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accon-webhook.order-output.js","sourceRoot":"","sources":["../../../lib/order/accon/accon-webhook.order-output.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,oCASmB;AACnB,2CAAoD;AACpD,iEAGgC;AAOhC,8FAAyF;AACzF,yCAA4C;AAC5C,+BAAsC;AACtC,iCAAqC;AACrC,uEAA8E;AAgBvE,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IAMf;IACR;IAJM,aAAa,CAA6B;IAC1C,MAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;IACnE,YACmB,WAAwB,EAChC,aAA4B;QADpB,gBAAW,GAAX,WAAW,CAAa;QAChC,kBAAa,GAAb,aAAa,CAAe;QAErC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,mBAAmB,CACpD,eAAe,EACf,aAAa,CACd,CAAC;IACJ,CAAC;IAED,cAAc,CACZ,OAA2B,EAC3B,MAA0B;Q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AC;YACtC,CAAC,cAAc,EAAE,0BAA0B,CAAC;YAC5C,CAAC,QAAQ,EAAE,OAAO,CAAC;YACnB,CAAC,QAAQ,EAAE,QAAQ,CAAC;YACpB,CAAC,gBAAgB,EAAE,QAAQ,CAAC;YAC5B,CAAC,OAAO,EAAE,QAAQ,CAAC;SACpB,CAAC,CAAC;QAEH,MAAM,YAAY,GAAyB;YACzC,QAAQ;YACR,cAAc;YACd,OAAO;SACR,CAAC;QAEF,OAAO;YACL,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,0BAA0B;YACrE,MAAM;YACN,GAAG,EAAE,MAAM,IAAI,MAAM,KAAK,KAAK;YAC/B,GAAG,EAAE,WAAW,EAAE,iBAAiB;YACnC,iBAAiB,EAAE,WAAW,EAAE,iBAAiB;YACjD,IAAI,EACF,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK;gBACpC,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC;SAC7C,CAAC;IACJ,CAAC;CACF,CAAA;AA9UY,0DAAuB;kCAAvB,uBAAuB;IAZnC,IAAA,0BAAmB,EAAC;QACnB,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,mBAAmB;QAC1B,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,+DAA+D;QAC5E,OAAO,EACL,sEAAsE;QACxE,UAAU,EAAE,uBAAuB;QACnC,YAAY,EAAE,kDAA2B;KAC1C,CAAC;IACD,IAAA,mBAAU,GAAE;qCAOqB,mBAAW;QACjB,oBAAa;GAP5B,uBAAuB,CA8UnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './webhook-body.dto';
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./webhook-body.dto"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../lib/order/accon/dto/accon-webhook/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export declare class AddressDto {
|
|
2
|
+
address: string;
|
|
3
|
+
number: string;
|
|
4
|
+
complement?: string;
|
|
5
|
+
city: string;
|
|
6
|
+
state: string;
|
|
7
|
+
zip: string;
|
|
8
|
+
latlng: {
|
|
9
|
+
lat: number;
|
|
10
|
+
lng: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare class StoreDto {
|
|
14
|
+
_id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
address: AddressDto;
|
|
17
|
+
deliveryTime: string;
|
|
18
|
+
toGoTime: string;
|
|
19
|
+
details: {
|
|
20
|
+
email: string;
|
|
21
|
+
phone: string;
|
|
22
|
+
socialName: string;
|
|
23
|
+
storePhone: string;
|
|
24
|
+
document: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare class UserDto {
|
|
28
|
+
_id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
document?: string;
|
|
31
|
+
email?: string;
|
|
32
|
+
phone: string;
|
|
33
|
+
totalOrders: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class PaymentDto {
|
|
36
|
+
type?: 'credit_card' | 'voucher' | 'ticket' | 'pix';
|
|
37
|
+
online: boolean;
|
|
38
|
+
name: string;
|
|
39
|
+
cod: string;
|
|
40
|
+
pix: boolean;
|
|
41
|
+
externalVendorCode?: string;
|
|
42
|
+
authorizationCode?: string;
|
|
43
|
+
tid?: string;
|
|
44
|
+
card?: string;
|
|
45
|
+
operator?: string;
|
|
46
|
+
refunded?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class RatingDto {
|
|
49
|
+
stars: number;
|
|
50
|
+
improvements: string[];
|
|
51
|
+
notes?: string;
|
|
52
|
+
reply?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare class StatusDto {
|
|
55
|
+
name: string;
|
|
56
|
+
date: string;
|
|
57
|
+
obs?: string;
|
|
58
|
+
}
|
|
59
|
+
export declare class ModifierDto {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
price: {
|
|
63
|
+
actualPrice: number;
|
|
64
|
+
originalPrice: number;
|
|
65
|
+
starterPrice: number;
|
|
66
|
+
};
|
|
67
|
+
quantity: number;
|
|
68
|
+
group: string;
|
|
69
|
+
externalVendorCode?: string;
|
|
70
|
+
}
|
|
71
|
+
export declare class ProductDto {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
quantity: number;
|
|
75
|
+
modifiers: ModifierDto[];
|
|
76
|
+
notes: string;
|
|
77
|
+
total: number;
|
|
78
|
+
externalVendorCode?: string;
|
|
79
|
+
}
|
|
80
|
+
export declare class WebhookBodyDto {
|
|
81
|
+
_id: string;
|
|
82
|
+
network: string;
|
|
83
|
+
session_id?: string;
|
|
84
|
+
sequential: string;
|
|
85
|
+
store: StoreDto;
|
|
86
|
+
user: UserDto;
|
|
87
|
+
address?: AddressDto;
|
|
88
|
+
delivery: boolean;
|
|
89
|
+
date: string;
|
|
90
|
+
deliveryTax: number;
|
|
91
|
+
discount: number;
|
|
92
|
+
subtotal: number;
|
|
93
|
+
total: number;
|
|
94
|
+
change: number;
|
|
95
|
+
payment: PaymentDto;
|
|
96
|
+
voucher?: {};
|
|
97
|
+
status: StatusDto[];
|
|
98
|
+
canceled: boolean;
|
|
99
|
+
scheduled: boolean;
|
|
100
|
+
scheduledDate?: string;
|
|
101
|
+
ip?: string;
|
|
102
|
+
source: string;
|
|
103
|
+
rating?: RatingDto;
|
|
104
|
+
notes?: string;
|
|
105
|
+
document?: string;
|
|
106
|
+
products: ProductDto[];
|
|
107
|
+
}
|