@orchesty/connector-authentica 1.0.0
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/CHANGELOG.md +12 -0
- package/LICENSE +190 -0
- package/coverage/clover.xml +413 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +161 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/AuthenticaApplication.ts.html +496 -0
- package/coverage/lcov-report/src/Batch/AuthenticaGetStock.ts.html +316 -0
- package/coverage/lcov-report/src/Batch/AuthenticaGetStockAvailable.ts.html +262 -0
- package/coverage/lcov-report/src/Batch/index.html +131 -0
- package/coverage/lcov-report/src/Connector/AuthenticaCreateOrder.ts.html +244 -0
- package/coverage/lcov-report/src/Connector/AuthenticaCreateProduct.ts.html +247 -0
- package/coverage/lcov-report/src/Connector/AuthenticaCreateReceipt.ts.html +244 -0
- package/coverage/lcov-report/src/Connector/AuthenticaGetCarriersConnector.ts.html +205 -0
- package/coverage/lcov-report/src/Connector/AuthenticaGetOrder.ts.html +259 -0
- package/coverage/lcov-report/src/Connector/AuthenticaGetOrderStatus.ts.html +199 -0
- package/coverage/lcov-report/src/Connector/AuthenticaGetReceipt.ts.html +259 -0
- package/coverage/lcov-report/src/Connector/AuthenticaGetShippingMethods.ts.html +208 -0
- package/coverage/lcov-report/src/Connector/AuthenticaPostLabel.ts.html +196 -0
- package/coverage/lcov-report/src/Connector/AuthenticaPutOrders.ts.html +334 -0
- package/coverage/lcov-report/src/Connector/AuthenticaPutProducts.ts.html +250 -0
- package/coverage/lcov-report/src/Connector/AuthenticaUpdateOrder.ts.html +256 -0
- package/coverage/lcov-report/src/Connector/AuthenticaUpdateProduct.ts.html +259 -0
- package/coverage/lcov-report/src/Connector/AuthenticaUpdateReceipt.ts.html +193 -0
- package/coverage/lcov-report/src/Connector/index.html +311 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/test/dataProvider.ts.html +325 -0
- package/coverage/lcov-report/test/index.html +116 -0
- package/coverage/lcov.info +676 -0
- package/dist/AuthenticaApplication.d.ts +29 -0
- package/dist/AuthenticaApplication.js +128 -0
- package/dist/Batch/AuthenticaGetStock.d.ts +20 -0
- package/dist/Batch/AuthenticaGetStock.js +45 -0
- package/dist/Batch/AuthenticaGetStockAvailable.d.ts +13 -0
- package/dist/Batch/AuthenticaGetStockAvailable.js +36 -0
- package/dist/Connector/AuthenticaCreateOrder.d.ts +12 -0
- package/dist/Connector/AuthenticaCreateOrder.js +37 -0
- package/dist/Connector/AuthenticaCreateProduct.d.ts +12 -0
- package/dist/Connector/AuthenticaCreateProduct.js +37 -0
- package/dist/Connector/AuthenticaCreateReceipt.d.ts +11 -0
- package/dist/Connector/AuthenticaCreateReceipt.js +37 -0
- package/dist/Connector/AuthenticaGetCarriersConnector.d.ts +15 -0
- package/dist/Connector/AuthenticaGetCarriersConnector.js +23 -0
- package/dist/Connector/AuthenticaGetOrder.d.ts +14 -0
- package/dist/Connector/AuthenticaGetOrder.js +38 -0
- package/dist/Connector/AuthenticaGetOrderStatus.d.ts +11 -0
- package/dist/Connector/AuthenticaGetOrderStatus.js +20 -0
- package/dist/Connector/AuthenticaGetReceipt.d.ts +13 -0
- package/dist/Connector/AuthenticaGetReceipt.js +38 -0
- package/dist/Connector/AuthenticaGetShippingMethods.d.ts +14 -0
- package/dist/Connector/AuthenticaGetShippingMethods.js +20 -0
- package/dist/Connector/AuthenticaPostLabel.d.ts +12 -0
- package/dist/Connector/AuthenticaPostLabel.js +22 -0
- package/dist/Connector/AuthenticaPutOrders.d.ts +52 -0
- package/dist/Connector/AuthenticaPutOrders.js +22 -0
- package/dist/Connector/AuthenticaPutProducts.d.ts +24 -0
- package/dist/Connector/AuthenticaPutProducts.js +22 -0
- package/dist/Connector/AuthenticaUpdateOrder.d.ts +12 -0
- package/dist/Connector/AuthenticaUpdateOrder.js +39 -0
- package/dist/Connector/AuthenticaUpdateProduct.d.ts +12 -0
- package/dist/Connector/AuthenticaUpdateProduct.js +39 -0
- package/dist/Connector/AuthenticaUpdateReceipt.d.ts +9 -0
- package/dist/Connector/AuthenticaUpdateReceipt.js +22 -0
- package/dist/package.json +24 -0
- package/dist/types/order.d.ts +39 -0
- package/dist/types/order.js +2 -0
- package/dist/types/product.d.ts +20 -0
- package/dist/types/product.js +2 -0
- package/dist/types/receipt.d.ts +29 -0
- package/dist/types/receipt.js +1 -0
- package/jest.config.js +13 -0
- package/package.json +24 -0
- package/src/AuthenticaApplication.ts +137 -0
- package/src/Batch/AuthenticaGetStock.ts +77 -0
- package/src/Batch/AuthenticaGetStockAvailable.ts +59 -0
- package/src/Batch/__tests__/AuthenticaGetStock.ts +26 -0
- package/src/Batch/__tests__/AuthenticaGetStockAvailable.ts +22 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStock/input.json +6 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStock/mock.json +23 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStock/nok-input.json +6 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStock/nok-mock.json +20 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStock/nok-output.json +13 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStock/output.json +11 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/1-mock.json +20 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/input.json +6 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/mock.json +21 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/output.json +14 -0
- package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/output1.json +12 -0
- package/src/Connector/AuthenticaCreateOrder.ts +53 -0
- package/src/Connector/AuthenticaCreateProduct.ts +54 -0
- package/src/Connector/AuthenticaCreateReceipt.ts +53 -0
- package/src/Connector/AuthenticaGetCarriersConnector.ts +40 -0
- package/src/Connector/AuthenticaGetOrder.ts +58 -0
- package/src/Connector/AuthenticaGetOrderStatus.ts +38 -0
- package/src/Connector/AuthenticaGetReceipt.ts +58 -0
- package/src/Connector/AuthenticaGetShippingMethods.ts +41 -0
- package/src/Connector/AuthenticaPostLabel.ts +37 -0
- package/src/Connector/AuthenticaPutOrders.ts +83 -0
- package/src/Connector/AuthenticaPutProducts.ts +55 -0
- package/src/Connector/AuthenticaUpdateOrder.ts +57 -0
- package/src/Connector/AuthenticaUpdateProduct.ts +58 -0
- package/src/Connector/AuthenticaUpdateReceipt.ts +36 -0
- package/src/Connector/__tests__/AuthenticaCreateOrder.ts +22 -0
- package/src/Connector/__tests__/AuthenticaCreateProduct.ts +22 -0
- package/src/Connector/__tests__/AuthenticaCreateReceipt.ts +22 -0
- package/src/Connector/__tests__/AuthenticaGetCarriers.ts +22 -0
- package/src/Connector/__tests__/AuthenticaGetOrder.ts +22 -0
- package/src/Connector/__tests__/AuthenticaGetOrderStatus.ts +36 -0
- package/src/Connector/__tests__/AuthenticaGetReceipt.ts +22 -0
- package/src/Connector/__tests__/AuthenticaGetShippingMethods.ts +22 -0
- package/src/Connector/__tests__/AuthenticaPostLabel.ts +36 -0
- package/src/Connector/__tests__/AuthenticaPutOrders.ts +36 -0
- package/src/Connector/__tests__/AuthenticaPutProducts.ts +36 -0
- package/src/Connector/__tests__/AuthenticaUpdateOrder.ts +22 -0
- package/src/Connector/__tests__/AuthenticaUpdateProduct.ts +22 -0
- package/src/Connector/__tests__/AuthenticaUpdateReceipt.ts +22 -0
- package/src/Connector/__tests__/Data/AuthenticaCreateOrder/input.json +67 -0
- package/src/Connector/__tests__/Data/AuthenticaCreateOrder/mock.json +70 -0
- package/src/Connector/__tests__/Data/AuthenticaCreateOrder/output.json +71 -0
- package/src/Connector/__tests__/Data/AuthenticaCreateProduct/input.json +28 -0
- package/src/Connector/__tests__/Data/AuthenticaCreateProduct/mock.json +28 -0
- package/src/Connector/__tests__/Data/AuthenticaCreateProduct/output.json +29 -0
- package/src/Connector/__tests__/Data/AuthenticaCreateReceipt/input.json +47 -0
- package/src/Connector/__tests__/Data/AuthenticaCreateReceipt/mock.json +51 -0
- package/src/Connector/__tests__/Data/AuthenticaCreateReceipt/output.json +52 -0
- package/src/Connector/__tests__/Data/AuthenticaGetCarriers/input.json +6 -0
- package/src/Connector/__tests__/Data/AuthenticaGetCarriers/mock.json +18 -0
- package/src/Connector/__tests__/Data/AuthenticaGetCarriers/output.json +19 -0
- package/src/Connector/__tests__/Data/AuthenticaGetOrder/input.json +8 -0
- package/src/Connector/__tests__/Data/AuthenticaGetOrder/mock.json +63 -0
- package/src/Connector/__tests__/Data/AuthenticaGetOrder/output.json +64 -0
- package/src/Connector/__tests__/Data/AuthenticaGetOrderStatus/input.json +6 -0
- package/src/Connector/__tests__/Data/AuthenticaGetOrderStatus/mock.json +12 -0
- package/src/Connector/__tests__/Data/AuthenticaGetOrderStatus/output.json +11 -0
- package/src/Connector/__tests__/Data/AuthenticaGetReceipt/input.json +8 -0
- package/src/Connector/__tests__/Data/AuthenticaGetReceipt/mock.json +54 -0
- package/src/Connector/__tests__/Data/AuthenticaGetReceipt/output.json +55 -0
- package/src/Connector/__tests__/Data/AuthenticaGetShippingMethods/input.json +6 -0
- package/src/Connector/__tests__/Data/AuthenticaGetShippingMethods/mock.json +404 -0
- package/src/Connector/__tests__/Data/AuthenticaGetShippingMethods/output.json +403 -0
- package/src/Connector/__tests__/Data/AuthenticaPostLabel/input.json +10 -0
- package/src/Connector/__tests__/Data/AuthenticaPostLabel/mock.json +5 -0
- package/src/Connector/__tests__/Data/AuthenticaPostLabel/output.json +10 -0
- package/src/Connector/__tests__/Data/AuthenticaPutOrders/input.json +43 -0
- package/src/Connector/__tests__/Data/AuthenticaPutOrders/mock.json +44 -0
- package/src/Connector/__tests__/Data/AuthenticaPutOrders/output.json +43 -0
- package/src/Connector/__tests__/Data/AuthenticaPutProducts/input.json +19 -0
- package/src/Connector/__tests__/Data/AuthenticaPutProducts/mock.json +20 -0
- package/src/Connector/__tests__/Data/AuthenticaPutProducts/output.json +19 -0
- package/src/Connector/__tests__/Data/AuthenticaUpdateOrder/input.json +68 -0
- package/src/Connector/__tests__/Data/AuthenticaUpdateOrder/mock.json +70 -0
- package/src/Connector/__tests__/Data/AuthenticaUpdateOrder/output.json +71 -0
- package/src/Connector/__tests__/Data/AuthenticaUpdateProduct/input.json +32 -0
- package/src/Connector/__tests__/Data/AuthenticaUpdateProduct/mock.json +28 -0
- package/src/Connector/__tests__/Data/AuthenticaUpdateProduct/output.json +31 -0
- package/src/Connector/__tests__/Data/AuthenticaUpdateReceipt/input.json +45 -0
- package/src/Connector/__tests__/Data/AuthenticaUpdateReceipt/mock.json +51 -0
- package/src/Connector/__tests__/Data/AuthenticaUpdateReceipt/output.json +52 -0
- package/src/__tests__/AuthenticaApplication.ts +41 -0
- package/src/types/order.ts +40 -0
- package/src/types/product.ts +21 -0
- package/src/types/receipt.ts +30 -0
- package/test/dataProvider.ts +80 -0
- package/tsconfig.json +8 -0
- package/tsconfig.prod.json +13 -0
- package/tsconfig.prod.tsbuildinfo +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NAME = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
exports.NAME = 'authentica-post-label';
|
|
10
|
+
class AuthenticaPostLabel extends AConnector_1.default {
|
|
11
|
+
getName() {
|
|
12
|
+
return exports.NAME;
|
|
13
|
+
}
|
|
14
|
+
async processAction(dto) {
|
|
15
|
+
const label = dto.getJsonData();
|
|
16
|
+
const requestDto = await this.getApplication().getRequestDto(dto, await this.getApplicationInstallFromProcess(dto), HttpMethods_1.HttpMethods.POST, 'applinth/label', label);
|
|
17
|
+
await this.getSender().send(requestDto);
|
|
18
|
+
dto.setNewJsonData(label);
|
|
19
|
+
return dto;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = AuthenticaPostLabel;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
3
|
+
export declare const NAME = "authentica-post-orders";
|
|
4
|
+
export default class AuthenticaPutOrders extends AConnector {
|
|
5
|
+
getName(): string;
|
|
6
|
+
processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>>;
|
|
7
|
+
}
|
|
8
|
+
export interface IOrder {
|
|
9
|
+
id: string;
|
|
10
|
+
orderNumber: string;
|
|
11
|
+
destination: {
|
|
12
|
+
firstName: string;
|
|
13
|
+
lastName: string;
|
|
14
|
+
phone: string;
|
|
15
|
+
email: string;
|
|
16
|
+
company: string;
|
|
17
|
+
address1: string;
|
|
18
|
+
address2: string;
|
|
19
|
+
city: string;
|
|
20
|
+
province: string;
|
|
21
|
+
country: string;
|
|
22
|
+
zip: string;
|
|
23
|
+
};
|
|
24
|
+
deliveryMethod: {
|
|
25
|
+
id: number;
|
|
26
|
+
branchId: string;
|
|
27
|
+
} | null;
|
|
28
|
+
paymentMethod: {
|
|
29
|
+
codAmount: number;
|
|
30
|
+
codCurrency: string;
|
|
31
|
+
} | null;
|
|
32
|
+
price: {
|
|
33
|
+
totalPrice: number;
|
|
34
|
+
currency: string;
|
|
35
|
+
};
|
|
36
|
+
items: {
|
|
37
|
+
sku: string;
|
|
38
|
+
quantity: number;
|
|
39
|
+
unitPrice: number | null;
|
|
40
|
+
}[];
|
|
41
|
+
variableSymbol: string | null;
|
|
42
|
+
application: string;
|
|
43
|
+
orderTags: string[];
|
|
44
|
+
packagingType?: string;
|
|
45
|
+
printDeliveryNote?: boolean;
|
|
46
|
+
packagingInstructions?: {
|
|
47
|
+
message: string;
|
|
48
|
+
packagingInstructionType: string;
|
|
49
|
+
}[];
|
|
50
|
+
}
|
|
51
|
+
export type IInput = IOrder[];
|
|
52
|
+
export type IOutput = IInput;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NAME = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
exports.NAME = 'authentica-post-orders';
|
|
10
|
+
class AuthenticaPutOrders extends AConnector_1.default {
|
|
11
|
+
getName() {
|
|
12
|
+
return exports.NAME;
|
|
13
|
+
}
|
|
14
|
+
async processAction(dto) {
|
|
15
|
+
const orders = dto.getJsonData();
|
|
16
|
+
const requestDto = await this.getApplication().getRequestDto(dto, await this.getApplicationInstallFromProcess(dto), HttpMethods_1.HttpMethods.PUT, 'applinth/orders', orders);
|
|
17
|
+
await this.getSender().send(requestDto, { success: 200, stopAndFail: '300-499' });
|
|
18
|
+
dto.setNewJsonData(orders);
|
|
19
|
+
return dto;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = AuthenticaPutOrders;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
3
|
+
export declare const NAME = "authentica-put-products";
|
|
4
|
+
export default class AuthenticaPutProducts extends AConnector {
|
|
5
|
+
getName(): string;
|
|
6
|
+
processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>>;
|
|
7
|
+
}
|
|
8
|
+
export interface IProduct {
|
|
9
|
+
productId: string;
|
|
10
|
+
sku: string;
|
|
11
|
+
name: string;
|
|
12
|
+
englishName: string | null;
|
|
13
|
+
ean: string;
|
|
14
|
+
width: number | null;
|
|
15
|
+
widthUnit: string | null;
|
|
16
|
+
height: number | null;
|
|
17
|
+
heightUnit: string | null;
|
|
18
|
+
length: number | null;
|
|
19
|
+
lengthUnit: string | null;
|
|
20
|
+
weight: number | null;
|
|
21
|
+
weightUnit: string | null;
|
|
22
|
+
}
|
|
23
|
+
export type IInput = IProduct[];
|
|
24
|
+
export type IOutput = IInput;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NAME = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
exports.NAME = 'authentica-put-products';
|
|
10
|
+
class AuthenticaPutProducts extends AConnector_1.default {
|
|
11
|
+
getName() {
|
|
12
|
+
return exports.NAME;
|
|
13
|
+
}
|
|
14
|
+
async processAction(dto) {
|
|
15
|
+
const products = dto.getJsonData();
|
|
16
|
+
const requestDto = await this.getApplication().getRequestDto(dto, await this.getApplicationInstallFromProcess(dto), HttpMethods_1.HttpMethods.PUT, 'applinth/products', products);
|
|
17
|
+
const response = await this.getSender().send(requestDto, { stopAndFail: '300-499' });
|
|
18
|
+
dto.setNewJsonData(response.getJsonBody().data);
|
|
19
|
+
return dto;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = AuthenticaPutProducts;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
3
|
+
import { AuthenticaOrder } from '../types/order';
|
|
4
|
+
export declare const AUTHENTICA_UPDATE_ORDER = "authentica-update-order";
|
|
5
|
+
export default class AuthenticaUpdateOrder extends AConnector {
|
|
6
|
+
protected dataKey: string | null;
|
|
7
|
+
constructor(dataKey?: string | null);
|
|
8
|
+
getName(): string;
|
|
9
|
+
processAction(dto: ProcessDto<AuthenticaUpdateOrderInput>): Promise<ProcessDto<AuthenticaUpdateOrderOutput>>;
|
|
10
|
+
}
|
|
11
|
+
export type AuthenticaUpdateOrderInput = Omit<AuthenticaOrder, 'status' | 'trackingNumbers' | 'trackingUrls'>;
|
|
12
|
+
export type AuthenticaUpdateOrderOutput = AuthenticaOrder;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AUTHENTICA_UPDATE_ORDER = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
exports.AUTHENTICA_UPDATE_ORDER = 'authentica-update-order';
|
|
10
|
+
class AuthenticaUpdateOrder extends AConnector_1.default {
|
|
11
|
+
dataKey;
|
|
12
|
+
constructor(dataKey = null) {
|
|
13
|
+
super();
|
|
14
|
+
this.dataKey = dataKey;
|
|
15
|
+
}
|
|
16
|
+
getName() {
|
|
17
|
+
return exports.AUTHENTICA_UPDATE_ORDER;
|
|
18
|
+
}
|
|
19
|
+
async processAction(dto) {
|
|
20
|
+
let order = dto.getJsonData();
|
|
21
|
+
if (this.dataKey) {
|
|
22
|
+
order = order[this.dataKey];
|
|
23
|
+
}
|
|
24
|
+
const url = `order/${order.id}`;
|
|
25
|
+
delete order.id;
|
|
26
|
+
const req = await this.getApplication().getRequestDto(dto, await this.getApplicationInstallFromProcess(dto), HttpMethods_1.HttpMethods.PUT, url, order);
|
|
27
|
+
const resp = (await this.getSender().send(req)).getJsonBody();
|
|
28
|
+
if (this.dataKey) {
|
|
29
|
+
const data = dto.getJsonData();
|
|
30
|
+
data[this.dataKey] = resp;
|
|
31
|
+
dto.setNewJsonData(data);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
dto.setNewJsonData(resp);
|
|
35
|
+
}
|
|
36
|
+
return dto;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = AuthenticaUpdateOrder;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
3
|
+
import { AuthenticaProduct } from '../types/product';
|
|
4
|
+
export declare const AUTHENTICA_UPDATE_PRODUCT = "authentica-update-product";
|
|
5
|
+
export default class AuthenticaUpdateProduct extends AConnector {
|
|
6
|
+
protected dataKey: string | null;
|
|
7
|
+
constructor(dataKey?: string | null);
|
|
8
|
+
getName(): string;
|
|
9
|
+
processAction(dto: ProcessDto<AuthenticaUpdateProductInput>): Promise<ProcessDto<AuthenticaUpdateProductOutput>>;
|
|
10
|
+
}
|
|
11
|
+
export type AuthenticaUpdateProductInput = Omit<AuthenticaProduct, 'hasImei' | 'hasLot' | 'hasLotExpiration'>;
|
|
12
|
+
export type AuthenticaUpdateProductOutput = AuthenticaProduct;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AUTHENTICA_UPDATE_PRODUCT = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
exports.AUTHENTICA_UPDATE_PRODUCT = 'authentica-update-product';
|
|
10
|
+
class AuthenticaUpdateProduct extends AConnector_1.default {
|
|
11
|
+
dataKey;
|
|
12
|
+
constructor(dataKey = null) {
|
|
13
|
+
super();
|
|
14
|
+
this.dataKey = dataKey;
|
|
15
|
+
}
|
|
16
|
+
getName() {
|
|
17
|
+
return exports.AUTHENTICA_UPDATE_PRODUCT;
|
|
18
|
+
}
|
|
19
|
+
async processAction(dto) {
|
|
20
|
+
let product = dto.getJsonData();
|
|
21
|
+
if (this.dataKey) {
|
|
22
|
+
product = product[this.dataKey];
|
|
23
|
+
}
|
|
24
|
+
const url = `product/${product.id}`;
|
|
25
|
+
delete product.id;
|
|
26
|
+
const req = await this.getApplication().getRequestDto(dto, await this.getApplicationInstallFromProcess(dto), HttpMethods_1.HttpMethods.PUT, url, product);
|
|
27
|
+
const resp = (await this.getSender().send(req)).getJsonBody();
|
|
28
|
+
if (this.dataKey) {
|
|
29
|
+
const data = dto.getJsonData();
|
|
30
|
+
data[this.dataKey] = resp;
|
|
31
|
+
dto.setNewJsonData(data);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
dto.setNewJsonData(resp);
|
|
35
|
+
}
|
|
36
|
+
return dto;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = AuthenticaUpdateProduct;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
3
|
+
export declare const AUTHENTICA_UPDATE_RECEIPT = "authentica-update-receipt";
|
|
4
|
+
export default class AuthenticaUpdateReceipt extends AConnector {
|
|
5
|
+
getName(): string;
|
|
6
|
+
processAction(dto: ProcessDto<AuthenticaUpdateReceiptInput>): Promise<ProcessDto<AuthenticaUpdateReceiptOutput>>;
|
|
7
|
+
}
|
|
8
|
+
export type AuthenticaUpdateReceiptInput = Omit<AuthenticaReceipt, 'status' | 'trackingNumbers' | 'shipments'>;
|
|
9
|
+
export type AuthenticaUpdateReceiptOutput = AuthenticaReceipt;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AUTHENTICA_UPDATE_RECEIPT = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
exports.AUTHENTICA_UPDATE_RECEIPT = 'authentica-update-receipt';
|
|
10
|
+
class AuthenticaUpdateReceipt extends AConnector_1.default {
|
|
11
|
+
getName() {
|
|
12
|
+
return exports.AUTHENTICA_UPDATE_RECEIPT;
|
|
13
|
+
}
|
|
14
|
+
async processAction(dto) {
|
|
15
|
+
const receipt = dto.getJsonData();
|
|
16
|
+
const req = await this.getApplication().getRequestDto(dto, await this.getApplicationInstallFromProcess(dto), HttpMethods_1.HttpMethods.PUT, `receipt/${receipt.id}`, receipt);
|
|
17
|
+
const resp = (await this.getSender().send(req)).getJsonBody();
|
|
18
|
+
dto.setNewJsonData(resp);
|
|
19
|
+
return dto;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = AuthenticaUpdateReceipt;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orchesty/connector-authentica",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"url": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
7
|
+
"repository": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rm -rf dist && rm -rf tsconfig.prod.tsbuildinfo && tsc -d -p tsconfig.prod.json && cp package.json ./dist/package.json",
|
|
10
|
+
"test": "jest --coverage --forceExit --passWithNoTests",
|
|
11
|
+
"lint": "eslint src test --fix",
|
|
12
|
+
"lint-ci": "eslint src test"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "info@hanaboso.com",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@orchesty/connector-git-hub": "workspace:*",
|
|
18
|
+
"@orchesty/nodejs-sdk": "^4.3.6",
|
|
19
|
+
"http-status-codes": "^2.3.0"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=24"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface AuthenticaOrder {
|
|
2
|
+
id: number;
|
|
3
|
+
status: string;
|
|
4
|
+
externalId: string;
|
|
5
|
+
carrierId: number;
|
|
6
|
+
branchId: unknown | null;
|
|
7
|
+
price: string;
|
|
8
|
+
priceCurrency: string;
|
|
9
|
+
cod: boolean;
|
|
10
|
+
codValue: unknown | null;
|
|
11
|
+
codValueCurrency: unknown | null;
|
|
12
|
+
vs: unknown | null;
|
|
13
|
+
companyName: string;
|
|
14
|
+
firstName: unknown | null;
|
|
15
|
+
lastName: unknown | null;
|
|
16
|
+
addressLine1: string;
|
|
17
|
+
addressLine2: string;
|
|
18
|
+
addressLine3: unknown | null;
|
|
19
|
+
city: string;
|
|
20
|
+
zip: string;
|
|
21
|
+
country: string;
|
|
22
|
+
state: unknown | null;
|
|
23
|
+
phone: string;
|
|
24
|
+
email: string;
|
|
25
|
+
processingDate: string;
|
|
26
|
+
printDeliveryNote: boolean;
|
|
27
|
+
orderNumber: unknown | null;
|
|
28
|
+
orderTags: string[];
|
|
29
|
+
packagingInstructions: {
|
|
30
|
+
message: string;
|
|
31
|
+
packagingInstructionType: string;
|
|
32
|
+
}[];
|
|
33
|
+
items: {
|
|
34
|
+
productId: number;
|
|
35
|
+
amount: number;
|
|
36
|
+
}[];
|
|
37
|
+
trackingNumbers: unknown[];
|
|
38
|
+
trackingUrls: string[];
|
|
39
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface AuthenticaProduct {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
declarationName: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
note?: string;
|
|
7
|
+
length?: string;
|
|
8
|
+
width?: string;
|
|
9
|
+
height?: string;
|
|
10
|
+
weight?: string;
|
|
11
|
+
hsCode?: string;
|
|
12
|
+
fdaCode?: string;
|
|
13
|
+
inspectionMethod?: string;
|
|
14
|
+
countryOfOrigin?: string;
|
|
15
|
+
hasLot: boolean;
|
|
16
|
+
hasImei: boolean;
|
|
17
|
+
hasLotExpiration: boolean;
|
|
18
|
+
skus: string[];
|
|
19
|
+
barcodes: string[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface AuthenticaReceipt {
|
|
2
|
+
id: number;
|
|
3
|
+
status: string;
|
|
4
|
+
externalId: string;
|
|
5
|
+
incomingDate: number;
|
|
6
|
+
customerNote: string | null;
|
|
7
|
+
customerType: string | null;
|
|
8
|
+
supplier: {
|
|
9
|
+
firstName: string | null;
|
|
10
|
+
lastName: string | null;
|
|
11
|
+
companyName: string;
|
|
12
|
+
addressLine1: string;
|
|
13
|
+
addressLine2: string | null;
|
|
14
|
+
addressLine3: string | null;
|
|
15
|
+
city: string;
|
|
16
|
+
zip: string;
|
|
17
|
+
country: string;
|
|
18
|
+
state: string | null;
|
|
19
|
+
};
|
|
20
|
+
items: {
|
|
21
|
+
productId: number;
|
|
22
|
+
receivedAmount: number | null;
|
|
23
|
+
expectedAmount: number;
|
|
24
|
+
expectedLot: unknown | null;
|
|
25
|
+
expectedExpirationDate: unknown | null;
|
|
26
|
+
}[];
|
|
27
|
+
trackingNumbers: string[];
|
|
28
|
+
shipments: number[];
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const baseConfig = require('../../jest.config.js');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
...baseConfig,
|
|
5
|
+
roots: ["<rootDir>/src"],
|
|
6
|
+
setupFiles: ["<rootDir>/../../.jest/testEnvs.ts"],
|
|
7
|
+
setupFilesAfterEnv: ["<rootDir>/../../.jest/testLifecycle.ts"],
|
|
8
|
+
globalSetup: "<rootDir>/../../.jest/globalSetup.ts",
|
|
9
|
+
moduleNameMapper: {
|
|
10
|
+
"^@orchesty/nodejs-connectors/test/(.*)$": "<rootDir>/../../test/$1",
|
|
11
|
+
"^@orchesty/nodejs-connectors/lib/(.*)$": "<rootDir>/../../lib/$1",
|
|
12
|
+
},
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orchesty/connector-authentica",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"url": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
7
|
+
"repository": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "info@hanaboso.com",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@orchesty/nodejs-sdk": "^4.3.6",
|
|
12
|
+
"http-status-codes": "^2.3.0",
|
|
13
|
+
"@orchesty/connector-git-hub": "1.0.0"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=24"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rm -rf dist && rm -rf tsconfig.prod.tsbuildinfo && tsc -d -p tsconfig.prod.json && cp package.json ./dist/package.json",
|
|
20
|
+
"test": "jest --coverage --forceExit --passWithNoTests",
|
|
21
|
+
"lint": "eslint src test --fix",
|
|
22
|
+
"lint-ci": "eslint src test"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import CoreFormsEnum, { getFormName } from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
|
|
2
|
+
import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
|
|
3
|
+
import Field from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Field';
|
|
4
|
+
import FieldType from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FieldType';
|
|
5
|
+
import Form from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Form';
|
|
6
|
+
import FormStack from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack';
|
|
7
|
+
import { ABasicApplication } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/Basic/ABasicApplication';
|
|
8
|
+
import { CLIENT_ID, CLIENT_SECRET } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application';
|
|
9
|
+
import CacheService, { ICacheCallback } from '@orchesty/nodejs-sdk/dist/lib/Cache/CacheService';
|
|
10
|
+
import RequestDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto';
|
|
11
|
+
import ResponseDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/ResponseDto';
|
|
12
|
+
import { defaultRanges } from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/ResultCodeRange';
|
|
13
|
+
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
14
|
+
import AProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/AProcessDto';
|
|
15
|
+
import { CommonHeaders, JSON_TYPE } from '@orchesty/nodejs-sdk/dist/lib/Utils/Headers';
|
|
16
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
17
|
+
|
|
18
|
+
export const NAME = 'authentica';
|
|
19
|
+
const AUTHENTICA_SHOP_ID = 'authentica-shop-id';
|
|
20
|
+
const CACHE_KEY = 'authentica_cache_key';
|
|
21
|
+
const LOCK_KEY = 'authentica_lock_key';
|
|
22
|
+
|
|
23
|
+
export default class AuthenticaApplication extends ABasicApplication {
|
|
24
|
+
|
|
25
|
+
public constructor(private readonly cacheService: CacheService) {
|
|
26
|
+
super();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public getName(): string {
|
|
30
|
+
return NAME;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public getPublicName(): string {
|
|
34
|
+
return 'Authentica Fulfillment';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public getDescription(): string {
|
|
38
|
+
return 'Simple solution for outsourcing logistics. In a few simple steps, connect your current e-commerce or accounting solution for automated order processing';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public getLogo(): string {
|
|
42
|
+
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KAAAACXBIWXMAAAsSAAAL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ABoQ6ADQgEAHgAYEOgA0INABoAGBDgANCHQAaECgA0ADAh0AGhDoANCAQAeABgQ6ADQg0AGgAYEOAA0IdABoQKADQAMCHQAaEOgA0IBAB4AGBDoANCDQAaABgQ4ADQh0AGhAoANAAwIdABoQ6ADQgEAHgAYEOgA0INABoAGBDgANCHQAaECgA0ADAh0AGhDoANCAQAeABgQ6ADQg0AGgAYEOAA0IdABoQKADQAMCHQAaEOgA0IBAB4AGBDoANCDQAaABgQ4ADQh0AGhAoANAAwIdABoQ6ADQgEAHgAYEOgA0INABoAGBDgANCHQAaECgA0ADAh0AGhDoANCAQAeABgQ6ADQg0AGgAYEOAA0IdABoQKADQAMCHQAaEOgA0IBAB4AGBDoANCDQAaABgQ4ADQh0AGhAoANAAwIdABoQ6ADQgEAHgAYEOgA0INABoAGBDgANCHQAaECgA0ADAh0AGhDoANCAQAeABgQ6ADQg0AGgAYEOAA0IdABoQKADQAMCHQAaEOgA0IBAB4AGBDoANCDQAaABgQ4ADQh0AGhAoANAAwIdABoQ6ADQgEAHgAYEOgA0INABoAGBDgANCHQAaECgA0ADAh0AGhDoANCAQAeABgQ6ADQg0AGgAYEOAA0IdABoQKADQAMCHQAaEOgA0IBAB4AGBDoANCDQAaABgQ4A1U3T9BfhFEHh3pA/0gAAAABJRU5ErkJggg==';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public getFormStack(): FormStack {
|
|
46
|
+
const settingsForm = new Form(CoreFormsEnum.AUTHORIZATION_FORM, getFormName(CoreFormsEnum.AUTHORIZATION_FORM));
|
|
47
|
+
const clientId = new Field(FieldType.TEXT, CLIENT_ID, 'Client id');
|
|
48
|
+
const clientSecret = new Field(FieldType.PASSWORD, CLIENT_SECRET, 'Client secret');
|
|
49
|
+
const shopId = new Field(FieldType.TEXT, AUTHENTICA_SHOP_ID, 'Shop ID', undefined, false);
|
|
50
|
+
|
|
51
|
+
settingsForm
|
|
52
|
+
.addField(clientId)
|
|
53
|
+
.addField(clientSecret)
|
|
54
|
+
.addField(shopId);
|
|
55
|
+
return new FormStack().addForm(settingsForm);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public isAuthorized(applicationInstall: ApplicationInstall): boolean {
|
|
59
|
+
const authorizationForm = applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM];
|
|
60
|
+
return authorizationForm?.[CLIENT_ID] && authorizationForm?.[CLIENT_SECRET];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public async getRequestDto(
|
|
64
|
+
dto: ProcessDto,
|
|
65
|
+
applicationInstall: ApplicationInstall,
|
|
66
|
+
method: HttpMethods,
|
|
67
|
+
_url?: string,
|
|
68
|
+
data?: unknown,
|
|
69
|
+
): Promise<RequestDto> {
|
|
70
|
+
const headers = {
|
|
71
|
+
[CommonHeaders.CONTENT_TYPE]: JSON_TYPE,
|
|
72
|
+
[CommonHeaders.ACCEPT]: JSON_TYPE,
|
|
73
|
+
[AUTHENTICA_SHOP_ID]: applicationInstall.getUser(),
|
|
74
|
+
[CommonHeaders.AUTHORIZATION]: await this.getAccessToken(dto, applicationInstall),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
let url = _url;
|
|
78
|
+
if (!url?.includes('applinth')) {
|
|
79
|
+
const shopId = applicationInstall.getUser();
|
|
80
|
+
url = `shop/${shopId}/${url}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const req = new RequestDto(`${this.getBaseUrl()}/${url}`, method, dto);
|
|
84
|
+
req.setHeaders(headers);
|
|
85
|
+
|
|
86
|
+
if (data) {
|
|
87
|
+
req.setJsonBody(data);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return req;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected getBaseUrl(): string {
|
|
94
|
+
return 'https://app.authentica.cz/api';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
protected async getAccessToken(processDto: AProcessDto, applicationInstall: ApplicationInstall): Promise<string> {
|
|
98
|
+
const url = `${this.getBaseUrl()}/token`;
|
|
99
|
+
|
|
100
|
+
const clientId = applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM][CLIENT_ID];
|
|
101
|
+
const clientSecret = applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM][CLIENT_SECRET];
|
|
102
|
+
|
|
103
|
+
const request = new RequestDto(
|
|
104
|
+
url,
|
|
105
|
+
HttpMethods.POST,
|
|
106
|
+
processDto,
|
|
107
|
+
`grant_type=client_credentials&client_id=${clientId}&client_secret=${clientSecret}&scopes=default applinth`,
|
|
108
|
+
{
|
|
109
|
+
[CommonHeaders.CONTENT_TYPE]: 'application/x-www-form-urlencoded',
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const storedAccessToken = await this.cacheService.entryWithLock<IAccessToken>(
|
|
114
|
+
CACHE_KEY,
|
|
115
|
+
LOCK_KEY,
|
|
116
|
+
request,
|
|
117
|
+
this.accessCallBack.bind(this),
|
|
118
|
+
defaultRanges,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return `Bearer ${storedAccessToken.access_token}`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
protected accessCallBack(res: ResponseDto): ICacheCallback<IAccessToken> {
|
|
125
|
+
const token = res.getJsonBody() as IAccessToken;
|
|
126
|
+
return {
|
|
127
|
+
dataToStore: token,
|
|
128
|
+
expire: token.expires_in - 300,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
interface IAccessToken {
|
|
135
|
+
expires_in: number;
|
|
136
|
+
access_token: string;
|
|
137
|
+
}
|