@pexcode/dlis-sdk 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/LICENSE +21 -0
- package/README.md +332 -0
- package/dist/api/core/ApiError.d.ts +10 -0
- package/dist/api/core/ApiError.js +15 -0
- package/dist/api/core/ApiRequestOptions.d.ts +13 -0
- package/dist/api/core/ApiRequestOptions.js +2 -0
- package/dist/api/core/ApiResult.d.ts +7 -0
- package/dist/api/core/ApiResult.js +2 -0
- package/dist/api/core/CancelablePromise.d.ts +20 -0
- package/dist/api/core/CancelablePromise.js +116 -0
- package/dist/api/core/OpenAPI.d.ts +16 -0
- package/dist/api/core/OpenAPI.js +14 -0
- package/dist/api/core/request.d.ts +34 -0
- package/dist/api/core/request.js +294 -0
- package/dist/api/index.d.ts +46 -0
- package/dist/api/index.js +48 -0
- package/dist/api/models/AppLevel.d.ts +5 -0
- package/dist/api/models/AppLevel.js +13 -0
- package/dist/api/models/BillingType.d.ts +5 -0
- package/dist/api/models/BillingType.js +13 -0
- package/dist/api/models/BranchId.d.ts +1 -0
- package/dist/api/models/BranchId.js +2 -0
- package/dist/api/models/BranchLedgerAttributes.d.ts +23 -0
- package/dist/api/models/BranchLedgerAttributes.js +2 -0
- package/dist/api/models/CalculateCostAttributes.d.ts +14 -0
- package/dist/api/models/CalculateCostAttributes.js +2 -0
- package/dist/api/models/CheckBlackListAttribute.d.ts +7 -0
- package/dist/api/models/CheckBlackListAttribute.js +2 -0
- package/dist/api/models/ClientAttributes.d.ts +26 -0
- package/dist/api/models/ClientAttributes.js +2 -0
- package/dist/api/models/ClientCreationAttributes.d.ts +12 -0
- package/dist/api/models/ClientCreationAttributes.js +2 -0
- package/dist/api/models/ClientTypeEnum.d.ts +4 -0
- package/dist/api/models/ClientTypeEnum.js +12 -0
- package/dist/api/models/CostId.d.ts +1 -0
- package/dist/api/models/CostId.js +2 -0
- package/dist/api/models/Currencies.d.ts +7 -0
- package/dist/api/models/Currencies.js +15 -0
- package/dist/api/models/EndpointId.d.ts +1 -0
- package/dist/api/models/EndpointId.js +2 -0
- package/dist/api/models/HttpSuccess.d.ts +5 -0
- package/dist/api/models/HttpSuccess.js +2 -0
- package/dist/api/models/LedgerCategory.d.ts +7 -0
- package/dist/api/models/LedgerCategory.js +15 -0
- package/dist/api/models/LedgerStatus.d.ts +5 -0
- package/dist/api/models/LedgerStatus.js +13 -0
- package/dist/api/models/LedgerType.d.ts +4 -0
- package/dist/api/models/LedgerType.js +12 -0
- package/dist/api/models/MovementsStatusAttributes.d.ts +6 -0
- package/dist/api/models/MovementsStatusAttributes.js +14 -0
- package/dist/api/models/PackageId.d.ts +1 -0
- package/dist/api/models/PackageId.js +2 -0
- package/dist/api/models/PackagePlatform.d.ts +6 -0
- package/dist/api/models/PackagePlatform.js +14 -0
- package/dist/api/models/PackageType.d.ts +4 -0
- package/dist/api/models/PackageType.js +12 -0
- package/dist/api/models/PlatformEnum.d.ts +8 -0
- package/dist/api/models/PlatformEnum.js +16 -0
- package/dist/api/models/ProofOfDeliveryType.d.ts +5 -0
- package/dist/api/models/ProofOfDeliveryType.js +13 -0
- package/dist/api/models/ReferenceType.d.ts +4 -0
- package/dist/api/models/ReferenceType.js +12 -0
- package/dist/api/models/SdkId.d.ts +1 -0
- package/dist/api/models/SdkId.js +2 -0
- package/dist/api/models/SdkInfoAttributes.d.ts +25 -0
- package/dist/api/models/SdkInfoAttributes.js +2 -0
- package/dist/api/models/SdkLedgerOverview.d.ts +6 -0
- package/dist/api/models/SdkLedgerOverview.js +2 -0
- package/dist/api/models/SdkPackagesCreationAttributes.d.ts +26 -0
- package/dist/api/models/SdkPackagesCreationAttributes.js +2 -0
- package/dist/api/models/ShippingOption.d.ts +5 -0
- package/dist/api/models/ShippingOption.js +13 -0
- package/dist/api/models/ShippingServiceData.d.ts +10 -0
- package/dist/api/models/ShippingServiceData.js +2 -0
- package/dist/api/models/Sizes.d.ts +5 -0
- package/dist/api/models/Sizes.js +13 -0
- package/dist/api/models/TenantId.d.ts +1 -0
- package/dist/api/models/TenantId.js +2 -0
- package/dist/api/models/UserId.d.ts +1 -0
- package/dist/api/models/UserId.js +2 -0
- package/dist/api/models/appAttributes.d.ts +4 -0
- package/dist/api/models/appAttributes.js +2 -0
- package/dist/api/models/branchesAttributes.d.ts +28 -0
- package/dist/api/models/branchesAttributes.js +2 -0
- package/dist/api/models/citiesAttributes.d.ts +12 -0
- package/dist/api/models/citiesAttributes.js +2 -0
- package/dist/api/models/costModelAttributes.d.ts +29 -0
- package/dist/api/models/costModelAttributes.js +2 -0
- package/dist/api/models/limitedSdkAttributes.d.ts +11 -0
- package/dist/api/models/limitedSdkAttributes.js +2 -0
- package/dist/api/models/movementsAttributes.d.ts +19 -0
- package/dist/api/models/movementsAttributes.js +2 -0
- package/dist/api/models/packagesAttributes.d.ts +70 -0
- package/dist/api/models/packagesAttributes.js +2 -0
- package/dist/api/models/packagesGroupAttributes.d.ts +8 -0
- package/dist/api/models/packagesGroupAttributes.js +2 -0
- package/dist/api/models/regionsAttributes.d.ts +11 -0
- package/dist/api/models/regionsAttributes.js +2 -0
- package/dist/api/models/sdksAttributes.d.ts +23 -0
- package/dist/api/models/sdksAttributes.js +2 -0
- package/dist/api/services/RegionsControllerService.d.ts +30 -0
- package/dist/api/services/RegionsControllerService.js +49 -0
- package/dist/api/services/SdkControllerService.d.ts +54 -0
- package/dist/api/services/SdkControllerService.js +94 -0
- package/dist/api/services/SdkPackagesControllerService.d.ts +55 -0
- package/dist/api/services/SdkPackagesControllerService.js +109 -0
- package/dist/api/services/SdkRegionsControllerService.d.ts +17 -0
- package/dist/api/services/SdkRegionsControllerService.js +36 -0
- package/dist/api-handler.d.ts +10 -0
- package/dist/api-handler.js +26 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +130 -0
- package/dist/sdk.spec.d.ts +1 -0
- package/dist/sdk.spec.js +150 -0
- package/package.json +38 -0
package/dist/sdk.spec.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const _1 = require(".");
|
|
4
|
+
const BillingType_1 = require("./api/models/BillingType");
|
|
5
|
+
const PacketType_1 = require("./api/models/PacketType");
|
|
6
|
+
const ProofOfDeliveryType_1 = require("./api/models/ProofOfDeliveryType");
|
|
7
|
+
const ShippingOption_1 = require("./api/models/ShippingOption");
|
|
8
|
+
const tokenKey = "token";
|
|
9
|
+
describe('My app Info', () => {
|
|
10
|
+
it('get my info', async () => {
|
|
11
|
+
// Arrange
|
|
12
|
+
const qds = new _1.QDSystem(tokenKey);
|
|
13
|
+
// Act
|
|
14
|
+
const result = await qds.MyInfo();
|
|
15
|
+
// Assert
|
|
16
|
+
expect(result.name).toBe("test");
|
|
17
|
+
expect(result.address).toBe("test");
|
|
18
|
+
expect(result.maxRequestCount).toBe(444);
|
|
19
|
+
});
|
|
20
|
+
it('throw get my info', async () => {
|
|
21
|
+
// Arrange
|
|
22
|
+
const qds = new _1.QDSystem("");
|
|
23
|
+
// Act + assert
|
|
24
|
+
await expect(qds.MyInfo()).rejects.toThrow('Login required: Authorization header missing or invalid.');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('getTenantBranches', () => {
|
|
28
|
+
it('get get Tenant Branches ', async () => {
|
|
29
|
+
// Arrange
|
|
30
|
+
const qds = new _1.QDSystem(tokenKey);
|
|
31
|
+
// Act
|
|
32
|
+
const result = await qds.getTenantBranches();
|
|
33
|
+
// Assert
|
|
34
|
+
expect(result).toHaveLength(3);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('GetList', () => {
|
|
38
|
+
it('get my GetList', async () => {
|
|
39
|
+
// Arrange
|
|
40
|
+
const qds = new _1.QDSystem(tokenKey);
|
|
41
|
+
// Act
|
|
42
|
+
const result = await qds.GetList(1, 10);
|
|
43
|
+
// Assert
|
|
44
|
+
expect(result).toHaveLength(10);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe('CompanyList', () => {
|
|
48
|
+
it('get CompanyList in city', async () => {
|
|
49
|
+
// Arrange
|
|
50
|
+
const qds = new _1.QDSystem(tokenKey);
|
|
51
|
+
const cityId = 1;
|
|
52
|
+
// Act
|
|
53
|
+
const result = await qds.getCompanyListOfCity(cityId);
|
|
54
|
+
// Assert
|
|
55
|
+
expect(result).toHaveLength(1);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe('GetPackageDetails', () => {
|
|
59
|
+
it('get GetPackageDetails', async () => {
|
|
60
|
+
// Arrange
|
|
61
|
+
const qds = new _1.QDSystem(tokenKey);
|
|
62
|
+
const packageId = "a43f98a1-4a8a-4b90-956f-3279498fe58b";
|
|
63
|
+
// Act
|
|
64
|
+
const result = await qds.GetPackageDetails(packageId);
|
|
65
|
+
// Assert
|
|
66
|
+
expect(result.branchId).toEqual("ea9eae40-0985-4187-91ec-d90e0f739f53");
|
|
67
|
+
expect(result.senderAddress).toEqual('456 Sender Ave');
|
|
68
|
+
expect(result.recipientAddress).toEqual('123 Test Street');
|
|
69
|
+
expect(result.recipientName).toEqual('Test Recipient');
|
|
70
|
+
expect(result.recipientPhone).toEqual('0987654321');
|
|
71
|
+
expect(result.recipientCityId).toEqual(1);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('CalculateCost', () => {
|
|
75
|
+
it('CalculateCost', async () => {
|
|
76
|
+
// Arrange
|
|
77
|
+
const qds = new _1.QDSystem(tokenKey);
|
|
78
|
+
const costParams = {
|
|
79
|
+
costId: 'ef14157c-b186-4c28-8a3c-61568b338874', // Replace with a valid cost ID
|
|
80
|
+
branchId: 'ea9eae40-0985-4187-91ec-d90e0f739f53', // Replace with a valid branch ID
|
|
81
|
+
recipientCityId: 1, // Replace with a valid city ID
|
|
82
|
+
isExpress: false,
|
|
83
|
+
isPickup: false
|
|
84
|
+
};
|
|
85
|
+
// Act
|
|
86
|
+
const result = await qds.CalculateCost(costParams);
|
|
87
|
+
// Assert
|
|
88
|
+
expect(result.baseCost).toEqual("0.00");
|
|
89
|
+
expect(result.currency).toEqual("USD");
|
|
90
|
+
expect(result.details.currency).toEqual("USD");
|
|
91
|
+
expect(result.details.id).toEqual("ef14157c-b186-4c28-8a3c-61568b338874");
|
|
92
|
+
expect(result.details.type).toEqual(PacketType_1.PacketType.PACKET);
|
|
93
|
+
expect(result.details.modelV1).toEqual(true);
|
|
94
|
+
expect(result.details.cityBaseCosts).toEqual(0);
|
|
95
|
+
expect(result.details.taxRate).toEqual(0);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
describe('CreatePackage', () => {
|
|
99
|
+
it('get my CreatePackage', async () => {
|
|
100
|
+
// Arrange
|
|
101
|
+
const qds = new _1.QDSystem(tokenKey);
|
|
102
|
+
const packagePayload = {
|
|
103
|
+
senderPhone: '1234567890',
|
|
104
|
+
shippingOption: ShippingOption_1.ShippingOption.EXPRESS,
|
|
105
|
+
billingType: BillingType_1.BillingType.NONE,
|
|
106
|
+
proofOfDeliveryType: ProofOfDeliveryType_1.ProofOfDeliveryType.NONE,
|
|
107
|
+
branchId: 'ea9eae40-0985-4187-91ec-d90e0f739f53', // Replace with a valid branch ID
|
|
108
|
+
costId: 'ef14157c-b186-4c28-8a3c-61568b338874', // Replace with a valid cost ID
|
|
109
|
+
recipientCityId: 1, // Replace with a valid city ID
|
|
110
|
+
recipientAddress: '123 Test Street',
|
|
111
|
+
recipientLng: 44.4,
|
|
112
|
+
recipientLat: 33.3,
|
|
113
|
+
senderName: 'Test Sender',
|
|
114
|
+
senderAddress: '456 Sender Ave',
|
|
115
|
+
senderEmail: 'sender@test.com',
|
|
116
|
+
recipientEmail: 'recipient@test.com',
|
|
117
|
+
type: PacketType_1.PacketType.PACKET,
|
|
118
|
+
recipientName: 'Test Recipient',
|
|
119
|
+
recipientPhone: '0987654321',
|
|
120
|
+
note: 'Test package from SDK',
|
|
121
|
+
shippingCost: 10,
|
|
122
|
+
packetCost: 50,
|
|
123
|
+
showCostBox: true,
|
|
124
|
+
express: false,
|
|
125
|
+
isPaid: false,
|
|
126
|
+
isPaidOnline: false,
|
|
127
|
+
pickup: false,
|
|
128
|
+
includeProducts: false,
|
|
129
|
+
isTesting: true,
|
|
130
|
+
};
|
|
131
|
+
// Act
|
|
132
|
+
const result = await qds.CreatePackage(packagePayload);
|
|
133
|
+
// Assert
|
|
134
|
+
expect(result.branchId).toEqual(packagePayload.branchId);
|
|
135
|
+
expect(result.senderAddress).toEqual(packagePayload.senderAddress);
|
|
136
|
+
expect(result.recipientAddress).toEqual(packagePayload.recipientAddress);
|
|
137
|
+
expect(result.recipientName).toEqual(packagePayload.recipientName);
|
|
138
|
+
expect(result.recipientPhone).toEqual(packagePayload.recipientPhone);
|
|
139
|
+
expect(result.recipientCityId).toEqual(packagePayload.recipientCityId);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe('CheckBlackList', () => {
|
|
143
|
+
it('get my CheckBlackList', async () => {
|
|
144
|
+
// Arrange
|
|
145
|
+
const qds = new _1.QDSystem(tokenKey);
|
|
146
|
+
const blacklistQuery = { phone: '1112223333' };
|
|
147
|
+
// Act Assert
|
|
148
|
+
await expect(qds.CheckBlackList(blacklistQuery)).rejects.toThrow('Data not found !!!.');
|
|
149
|
+
});
|
|
150
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pexcode/dlis-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "This is a library published under Pexcode to help users and developers to use dlis API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"author": "Mussab Muhaimeed",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"prepare": "npm run build",
|
|
20
|
+
"push": "npm publish --access public",
|
|
21
|
+
"swagger-dev": "npx openapi-typescript-codegen --input http://localhost:2501/swagger-sdk.json --output src/api --client axios",
|
|
22
|
+
"build-tsup": "tsup src/index.ts --format cjs,esm --dts --clean --minify",
|
|
23
|
+
"cleanup-api": "node scripts/cleanup-api.ts",
|
|
24
|
+
"test": "jest"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/jest": "^30.0.0",
|
|
28
|
+
"@types/node": "^25.0.5",
|
|
29
|
+
"jest": "^30.2.0",
|
|
30
|
+
"openapi-typescript-codegen": "^0.29.0",
|
|
31
|
+
"ts-jest": "^29.4.6",
|
|
32
|
+
"tsup": "^8.5.1",
|
|
33
|
+
"typescript": "^5.8.3"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"axios": "^1.7.7"
|
|
37
|
+
}
|
|
38
|
+
}
|