pathao-merchant-sdk 1.1.0 → 2.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 +75 -0
- package/CONTRIBUTING.md +187 -0
- package/README.md +114 -34
- package/dist/index.d.mts +98 -92
- package/dist/index.d.ts +98 -92
- package/dist/index.js +159 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -87
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -2
package/dist/index.d.mts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Official API Details:
|
|
5
5
|
* - Authentication: OAuth2 with client_id, client_secret, username, password
|
|
6
|
-
* - Live URL: https://api-hermes.pathao.com
|
|
7
6
|
* - All endpoints use /aladdin/api/v1/ prefix
|
|
7
|
+
* - Base URL can be set via PATHAO_BASE_URL environment variable or constructor config
|
|
8
|
+
* - Timeout can be set via PATHAO_TIMEOUT environment variable or constructor config
|
|
8
9
|
*/
|
|
9
10
|
interface PathaoAuthResponse {
|
|
10
11
|
token_type: string;
|
|
@@ -34,11 +35,12 @@ interface PathaoStoreRequest {
|
|
|
34
35
|
name: string;
|
|
35
36
|
contact_name: string;
|
|
36
37
|
contact_number: string;
|
|
38
|
+
secondary_contact?: string;
|
|
39
|
+
otp_number?: string;
|
|
37
40
|
address: string;
|
|
38
41
|
city_id: number;
|
|
39
42
|
zone_id: number;
|
|
40
43
|
area_id: number;
|
|
41
|
-
store_type: number;
|
|
42
44
|
}
|
|
43
45
|
interface PathaoOrderResponse {
|
|
44
46
|
type: string;
|
|
@@ -46,44 +48,46 @@ interface PathaoOrderResponse {
|
|
|
46
48
|
message: string;
|
|
47
49
|
data: {
|
|
48
50
|
consignment_id: string;
|
|
49
|
-
invoice_id: string;
|
|
50
51
|
merchant_order_id: string;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
recipient_phone: string;
|
|
54
|
-
recipient_address: string;
|
|
55
|
-
recipient_city: string;
|
|
56
|
-
recipient_zone: string;
|
|
57
|
-
recipient_area: string;
|
|
58
|
-
delivery_type: string;
|
|
59
|
-
item_type: string;
|
|
60
|
-
item_quantity: number;
|
|
61
|
-
item_weight: number;
|
|
62
|
-
item_description: string;
|
|
63
|
-
amount_to_collect: number;
|
|
64
|
-
special_instruction: string;
|
|
65
|
-
status: string;
|
|
66
|
-
created_at: string;
|
|
67
|
-
updated_at: string;
|
|
52
|
+
order_status: string;
|
|
53
|
+
delivery_fee: number;
|
|
68
54
|
};
|
|
69
55
|
}
|
|
70
|
-
interface
|
|
56
|
+
interface PathaoStoreCreateResponse {
|
|
71
57
|
type: string;
|
|
72
58
|
code: number;
|
|
73
59
|
message: string;
|
|
74
60
|
data: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
61
|
+
store_name: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface PathaoStore {
|
|
65
|
+
store_id: number;
|
|
66
|
+
store_name: string;
|
|
67
|
+
store_address: string;
|
|
68
|
+
is_active: number;
|
|
69
|
+
city_id: number;
|
|
70
|
+
zone_id: number;
|
|
71
|
+
hub_id: number;
|
|
72
|
+
is_default_store: boolean;
|
|
73
|
+
is_default_return_store: boolean;
|
|
74
|
+
}
|
|
75
|
+
interface PathaoStoreListResponse {
|
|
76
|
+
type: string;
|
|
77
|
+
code: number;
|
|
78
|
+
message: string;
|
|
79
|
+
data: {
|
|
80
|
+
data: PathaoStore[];
|
|
81
|
+
total: number;
|
|
82
|
+
current_page: number;
|
|
83
|
+
per_page: number;
|
|
84
|
+
total_in_page: number;
|
|
85
|
+
last_page: number;
|
|
86
|
+
path: string;
|
|
87
|
+
to: number;
|
|
88
|
+
from: number;
|
|
89
|
+
last_page_url: string;
|
|
90
|
+
first_page_url: string;
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
interface PathaoPriceRequest {
|
|
@@ -93,42 +97,32 @@ interface PathaoPriceRequest {
|
|
|
93
97
|
delivery_type: number;
|
|
94
98
|
recipient_city: number;
|
|
95
99
|
recipient_zone: number;
|
|
96
|
-
recipient_area: number;
|
|
97
100
|
}
|
|
98
101
|
interface PathaoPriceResponse {
|
|
99
102
|
type: string;
|
|
100
103
|
code: number;
|
|
101
104
|
message: string;
|
|
102
105
|
data: {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
cod_charge: number;
|
|
112
|
-
total_charge: number;
|
|
113
|
-
currency: string;
|
|
106
|
+
price: number;
|
|
107
|
+
discount: number;
|
|
108
|
+
promo_discount: number;
|
|
109
|
+
plan_id: number;
|
|
110
|
+
cod_enabled: number;
|
|
111
|
+
cod_percentage: number;
|
|
112
|
+
additional_charge: number;
|
|
113
|
+
final_price: number;
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
interface PathaoCityResponse {
|
|
117
117
|
type: string;
|
|
118
118
|
code: number;
|
|
119
119
|
message: string;
|
|
120
|
-
data:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
zone_id: number;
|
|
125
|
-
zone_name: string;
|
|
126
|
-
area_list: Array<{
|
|
127
|
-
area_id: number;
|
|
128
|
-
area_name: string;
|
|
129
|
-
}>;
|
|
120
|
+
data: {
|
|
121
|
+
data: Array<{
|
|
122
|
+
city_id: number;
|
|
123
|
+
city_name: string;
|
|
130
124
|
}>;
|
|
131
|
-
}
|
|
125
|
+
};
|
|
132
126
|
}
|
|
133
127
|
interface PathaoOrderStatusResponse {
|
|
134
128
|
type: string;
|
|
@@ -136,47 +130,43 @@ interface PathaoOrderStatusResponse {
|
|
|
136
130
|
message: string;
|
|
137
131
|
data: {
|
|
138
132
|
consignment_id: string;
|
|
139
|
-
invoice_id: string;
|
|
140
133
|
merchant_order_id: string;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
recipient_phone: string;
|
|
144
|
-
recipient_address: string;
|
|
145
|
-
recipient_city: string;
|
|
146
|
-
recipient_zone: string;
|
|
147
|
-
recipient_area: string;
|
|
148
|
-
delivery_type: string;
|
|
149
|
-
item_type: string;
|
|
150
|
-
item_quantity: number;
|
|
151
|
-
item_weight: number;
|
|
152
|
-
item_description: string;
|
|
153
|
-
amount_to_collect: number;
|
|
154
|
-
special_instruction: string;
|
|
155
|
-
status: string;
|
|
156
|
-
status_updated_at: string;
|
|
157
|
-
created_at: string;
|
|
134
|
+
order_status: string;
|
|
135
|
+
order_status_slug: string;
|
|
158
136
|
updated_at: string;
|
|
137
|
+
invoice_id: string | null;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
interface PathaoZoneResponse {
|
|
141
|
+
type: string;
|
|
142
|
+
code: number;
|
|
143
|
+
message: string;
|
|
144
|
+
data: {
|
|
145
|
+
data: Array<{
|
|
146
|
+
zone_id: number;
|
|
147
|
+
zone_name: string;
|
|
148
|
+
}>;
|
|
159
149
|
};
|
|
160
150
|
}
|
|
161
151
|
interface PathaoAreaResponse {
|
|
162
152
|
type: string;
|
|
163
153
|
code: number;
|
|
164
154
|
message: string;
|
|
165
|
-
data:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
155
|
+
data: {
|
|
156
|
+
data: Array<{
|
|
157
|
+
area_id: number;
|
|
158
|
+
area_name: string;
|
|
159
|
+
home_delivery_available: boolean;
|
|
160
|
+
pickup_available: boolean;
|
|
161
|
+
}>;
|
|
162
|
+
};
|
|
173
163
|
}
|
|
174
164
|
interface PathaoConfig {
|
|
175
165
|
clientId: string;
|
|
176
166
|
clientSecret: string;
|
|
177
167
|
username: string;
|
|
178
168
|
password: string;
|
|
179
|
-
baseURL
|
|
169
|
+
baseURL: string;
|
|
180
170
|
timeout?: number;
|
|
181
171
|
}
|
|
182
172
|
interface PathaoError {
|
|
@@ -194,10 +184,6 @@ declare enum ItemType {
|
|
|
194
184
|
DOCUMENT = 1,
|
|
195
185
|
PARCEL = 2
|
|
196
186
|
}
|
|
197
|
-
declare enum StoreType {
|
|
198
|
-
PICKUP_POINT = 1,
|
|
199
|
-
SERVICE_POINT = 2
|
|
200
|
-
}
|
|
201
187
|
|
|
202
188
|
/**
|
|
203
189
|
* Pathao Merchant API Service (Unofficial SDK)
|
|
@@ -206,8 +192,9 @@ declare enum StoreType {
|
|
|
206
192
|
*
|
|
207
193
|
* API Details (based on public documentation):
|
|
208
194
|
* - Authentication: OAuth2 with client_id, client_secret, username, password
|
|
209
|
-
* - Live URL: https://api-hermes.pathao.com
|
|
210
195
|
* - All endpoints use /aladdin/api/v1/ prefix
|
|
196
|
+
* - Base URL can be set via PATHAO_BASE_URL environment variable or constructor config
|
|
197
|
+
* - Timeout can be set via PATHAO_TIMEOUT environment variable or constructor config
|
|
211
198
|
*
|
|
212
199
|
* Features implemented:
|
|
213
200
|
* - Token-based authentication with refresh token support
|
|
@@ -224,23 +211,42 @@ declare class PathaoApiService {
|
|
|
224
211
|
private refreshToken;
|
|
225
212
|
private tokenExpiry;
|
|
226
213
|
private config;
|
|
214
|
+
private isAuthenticating;
|
|
215
|
+
private authPromise;
|
|
216
|
+
private requestQueue;
|
|
217
|
+
private circuitBreaker;
|
|
227
218
|
constructor(config: PathaoConfig);
|
|
228
219
|
private ensureAuthenticated;
|
|
220
|
+
private performAuthentication;
|
|
221
|
+
private processRequestQueue;
|
|
229
222
|
private authenticate;
|
|
230
223
|
private refreshAccessToken;
|
|
231
224
|
private getErrorMessage;
|
|
225
|
+
private handleCircuitBreaker;
|
|
232
226
|
createOrder(orderData: PathaoOrderRequest): Promise<PathaoOrderResponse>;
|
|
233
|
-
createStore(storeData: PathaoStoreRequest): Promise<
|
|
234
|
-
getStores(): Promise<
|
|
227
|
+
createStore(storeData: PathaoStoreRequest): Promise<PathaoStoreCreateResponse>;
|
|
228
|
+
getStores(): Promise<PathaoStoreListResponse>;
|
|
235
229
|
calculatePrice(priceData: PathaoPriceRequest): Promise<PathaoPriceResponse>;
|
|
236
230
|
getCities(): Promise<PathaoCityResponse>;
|
|
237
|
-
|
|
231
|
+
getZones(cityId: number): Promise<PathaoZoneResponse>;
|
|
232
|
+
getAreas(zoneId: number): Promise<PathaoAreaResponse>;
|
|
238
233
|
getOrderStatus(consignmentId: string): Promise<PathaoOrderStatusResponse>;
|
|
234
|
+
createBulkOrder(orders: PathaoOrderRequest[]): Promise<{
|
|
235
|
+
message: string;
|
|
236
|
+
type: string;
|
|
237
|
+
code: number;
|
|
238
|
+
data: boolean;
|
|
239
|
+
}>;
|
|
239
240
|
static validatePhoneNumber(phone: string): boolean;
|
|
240
241
|
static formatPhoneNumber(phone: string): string;
|
|
241
242
|
static validateAddress(address: string): boolean;
|
|
242
243
|
static validateWeight(weight: number): boolean;
|
|
243
244
|
static validateRecipientName(name: string): boolean;
|
|
245
|
+
static validateStoreName(name: string): boolean;
|
|
246
|
+
static validateContactName(name: string): boolean;
|
|
247
|
+
static validateContactNumber(phone: string): boolean;
|
|
248
|
+
static validateStoreAddress(address: string): boolean;
|
|
249
|
+
clearAuth(): void;
|
|
244
250
|
}
|
|
245
251
|
|
|
246
|
-
export { DeliveryType, ItemType, PathaoApiService, type PathaoAreaResponse, type PathaoAuthResponse, type PathaoCityResponse, type PathaoConfig, type PathaoError, type PathaoOrderRequest, type PathaoOrderResponse, type PathaoOrderStatusResponse, type PathaoPriceRequest, type PathaoPriceResponse, type
|
|
252
|
+
export { DeliveryType, ItemType, PathaoApiService, type PathaoAreaResponse, type PathaoAuthResponse, type PathaoCityResponse, type PathaoConfig, type PathaoError, type PathaoOrderRequest, type PathaoOrderResponse, type PathaoOrderStatusResponse, type PathaoPriceRequest, type PathaoPriceResponse, type PathaoStore, type PathaoStoreCreateResponse, type PathaoStoreListResponse, type PathaoStoreRequest, type PathaoZoneResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Official API Details:
|
|
5
5
|
* - Authentication: OAuth2 with client_id, client_secret, username, password
|
|
6
|
-
* - Live URL: https://api-hermes.pathao.com
|
|
7
6
|
* - All endpoints use /aladdin/api/v1/ prefix
|
|
7
|
+
* - Base URL can be set via PATHAO_BASE_URL environment variable or constructor config
|
|
8
|
+
* - Timeout can be set via PATHAO_TIMEOUT environment variable or constructor config
|
|
8
9
|
*/
|
|
9
10
|
interface PathaoAuthResponse {
|
|
10
11
|
token_type: string;
|
|
@@ -34,11 +35,12 @@ interface PathaoStoreRequest {
|
|
|
34
35
|
name: string;
|
|
35
36
|
contact_name: string;
|
|
36
37
|
contact_number: string;
|
|
38
|
+
secondary_contact?: string;
|
|
39
|
+
otp_number?: string;
|
|
37
40
|
address: string;
|
|
38
41
|
city_id: number;
|
|
39
42
|
zone_id: number;
|
|
40
43
|
area_id: number;
|
|
41
|
-
store_type: number;
|
|
42
44
|
}
|
|
43
45
|
interface PathaoOrderResponse {
|
|
44
46
|
type: string;
|
|
@@ -46,44 +48,46 @@ interface PathaoOrderResponse {
|
|
|
46
48
|
message: string;
|
|
47
49
|
data: {
|
|
48
50
|
consignment_id: string;
|
|
49
|
-
invoice_id: string;
|
|
50
51
|
merchant_order_id: string;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
recipient_phone: string;
|
|
54
|
-
recipient_address: string;
|
|
55
|
-
recipient_city: string;
|
|
56
|
-
recipient_zone: string;
|
|
57
|
-
recipient_area: string;
|
|
58
|
-
delivery_type: string;
|
|
59
|
-
item_type: string;
|
|
60
|
-
item_quantity: number;
|
|
61
|
-
item_weight: number;
|
|
62
|
-
item_description: string;
|
|
63
|
-
amount_to_collect: number;
|
|
64
|
-
special_instruction: string;
|
|
65
|
-
status: string;
|
|
66
|
-
created_at: string;
|
|
67
|
-
updated_at: string;
|
|
52
|
+
order_status: string;
|
|
53
|
+
delivery_fee: number;
|
|
68
54
|
};
|
|
69
55
|
}
|
|
70
|
-
interface
|
|
56
|
+
interface PathaoStoreCreateResponse {
|
|
71
57
|
type: string;
|
|
72
58
|
code: number;
|
|
73
59
|
message: string;
|
|
74
60
|
data: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
61
|
+
store_name: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface PathaoStore {
|
|
65
|
+
store_id: number;
|
|
66
|
+
store_name: string;
|
|
67
|
+
store_address: string;
|
|
68
|
+
is_active: number;
|
|
69
|
+
city_id: number;
|
|
70
|
+
zone_id: number;
|
|
71
|
+
hub_id: number;
|
|
72
|
+
is_default_store: boolean;
|
|
73
|
+
is_default_return_store: boolean;
|
|
74
|
+
}
|
|
75
|
+
interface PathaoStoreListResponse {
|
|
76
|
+
type: string;
|
|
77
|
+
code: number;
|
|
78
|
+
message: string;
|
|
79
|
+
data: {
|
|
80
|
+
data: PathaoStore[];
|
|
81
|
+
total: number;
|
|
82
|
+
current_page: number;
|
|
83
|
+
per_page: number;
|
|
84
|
+
total_in_page: number;
|
|
85
|
+
last_page: number;
|
|
86
|
+
path: string;
|
|
87
|
+
to: number;
|
|
88
|
+
from: number;
|
|
89
|
+
last_page_url: string;
|
|
90
|
+
first_page_url: string;
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
interface PathaoPriceRequest {
|
|
@@ -93,42 +97,32 @@ interface PathaoPriceRequest {
|
|
|
93
97
|
delivery_type: number;
|
|
94
98
|
recipient_city: number;
|
|
95
99
|
recipient_zone: number;
|
|
96
|
-
recipient_area: number;
|
|
97
100
|
}
|
|
98
101
|
interface PathaoPriceResponse {
|
|
99
102
|
type: string;
|
|
100
103
|
code: number;
|
|
101
104
|
message: string;
|
|
102
105
|
data: {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
cod_charge: number;
|
|
112
|
-
total_charge: number;
|
|
113
|
-
currency: string;
|
|
106
|
+
price: number;
|
|
107
|
+
discount: number;
|
|
108
|
+
promo_discount: number;
|
|
109
|
+
plan_id: number;
|
|
110
|
+
cod_enabled: number;
|
|
111
|
+
cod_percentage: number;
|
|
112
|
+
additional_charge: number;
|
|
113
|
+
final_price: number;
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
interface PathaoCityResponse {
|
|
117
117
|
type: string;
|
|
118
118
|
code: number;
|
|
119
119
|
message: string;
|
|
120
|
-
data:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
zone_id: number;
|
|
125
|
-
zone_name: string;
|
|
126
|
-
area_list: Array<{
|
|
127
|
-
area_id: number;
|
|
128
|
-
area_name: string;
|
|
129
|
-
}>;
|
|
120
|
+
data: {
|
|
121
|
+
data: Array<{
|
|
122
|
+
city_id: number;
|
|
123
|
+
city_name: string;
|
|
130
124
|
}>;
|
|
131
|
-
}
|
|
125
|
+
};
|
|
132
126
|
}
|
|
133
127
|
interface PathaoOrderStatusResponse {
|
|
134
128
|
type: string;
|
|
@@ -136,47 +130,43 @@ interface PathaoOrderStatusResponse {
|
|
|
136
130
|
message: string;
|
|
137
131
|
data: {
|
|
138
132
|
consignment_id: string;
|
|
139
|
-
invoice_id: string;
|
|
140
133
|
merchant_order_id: string;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
recipient_phone: string;
|
|
144
|
-
recipient_address: string;
|
|
145
|
-
recipient_city: string;
|
|
146
|
-
recipient_zone: string;
|
|
147
|
-
recipient_area: string;
|
|
148
|
-
delivery_type: string;
|
|
149
|
-
item_type: string;
|
|
150
|
-
item_quantity: number;
|
|
151
|
-
item_weight: number;
|
|
152
|
-
item_description: string;
|
|
153
|
-
amount_to_collect: number;
|
|
154
|
-
special_instruction: string;
|
|
155
|
-
status: string;
|
|
156
|
-
status_updated_at: string;
|
|
157
|
-
created_at: string;
|
|
134
|
+
order_status: string;
|
|
135
|
+
order_status_slug: string;
|
|
158
136
|
updated_at: string;
|
|
137
|
+
invoice_id: string | null;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
interface PathaoZoneResponse {
|
|
141
|
+
type: string;
|
|
142
|
+
code: number;
|
|
143
|
+
message: string;
|
|
144
|
+
data: {
|
|
145
|
+
data: Array<{
|
|
146
|
+
zone_id: number;
|
|
147
|
+
zone_name: string;
|
|
148
|
+
}>;
|
|
159
149
|
};
|
|
160
150
|
}
|
|
161
151
|
interface PathaoAreaResponse {
|
|
162
152
|
type: string;
|
|
163
153
|
code: number;
|
|
164
154
|
message: string;
|
|
165
|
-
data:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
155
|
+
data: {
|
|
156
|
+
data: Array<{
|
|
157
|
+
area_id: number;
|
|
158
|
+
area_name: string;
|
|
159
|
+
home_delivery_available: boolean;
|
|
160
|
+
pickup_available: boolean;
|
|
161
|
+
}>;
|
|
162
|
+
};
|
|
173
163
|
}
|
|
174
164
|
interface PathaoConfig {
|
|
175
165
|
clientId: string;
|
|
176
166
|
clientSecret: string;
|
|
177
167
|
username: string;
|
|
178
168
|
password: string;
|
|
179
|
-
baseURL
|
|
169
|
+
baseURL: string;
|
|
180
170
|
timeout?: number;
|
|
181
171
|
}
|
|
182
172
|
interface PathaoError {
|
|
@@ -194,10 +184,6 @@ declare enum ItemType {
|
|
|
194
184
|
DOCUMENT = 1,
|
|
195
185
|
PARCEL = 2
|
|
196
186
|
}
|
|
197
|
-
declare enum StoreType {
|
|
198
|
-
PICKUP_POINT = 1,
|
|
199
|
-
SERVICE_POINT = 2
|
|
200
|
-
}
|
|
201
187
|
|
|
202
188
|
/**
|
|
203
189
|
* Pathao Merchant API Service (Unofficial SDK)
|
|
@@ -206,8 +192,9 @@ declare enum StoreType {
|
|
|
206
192
|
*
|
|
207
193
|
* API Details (based on public documentation):
|
|
208
194
|
* - Authentication: OAuth2 with client_id, client_secret, username, password
|
|
209
|
-
* - Live URL: https://api-hermes.pathao.com
|
|
210
195
|
* - All endpoints use /aladdin/api/v1/ prefix
|
|
196
|
+
* - Base URL can be set via PATHAO_BASE_URL environment variable or constructor config
|
|
197
|
+
* - Timeout can be set via PATHAO_TIMEOUT environment variable or constructor config
|
|
211
198
|
*
|
|
212
199
|
* Features implemented:
|
|
213
200
|
* - Token-based authentication with refresh token support
|
|
@@ -224,23 +211,42 @@ declare class PathaoApiService {
|
|
|
224
211
|
private refreshToken;
|
|
225
212
|
private tokenExpiry;
|
|
226
213
|
private config;
|
|
214
|
+
private isAuthenticating;
|
|
215
|
+
private authPromise;
|
|
216
|
+
private requestQueue;
|
|
217
|
+
private circuitBreaker;
|
|
227
218
|
constructor(config: PathaoConfig);
|
|
228
219
|
private ensureAuthenticated;
|
|
220
|
+
private performAuthentication;
|
|
221
|
+
private processRequestQueue;
|
|
229
222
|
private authenticate;
|
|
230
223
|
private refreshAccessToken;
|
|
231
224
|
private getErrorMessage;
|
|
225
|
+
private handleCircuitBreaker;
|
|
232
226
|
createOrder(orderData: PathaoOrderRequest): Promise<PathaoOrderResponse>;
|
|
233
|
-
createStore(storeData: PathaoStoreRequest): Promise<
|
|
234
|
-
getStores(): Promise<
|
|
227
|
+
createStore(storeData: PathaoStoreRequest): Promise<PathaoStoreCreateResponse>;
|
|
228
|
+
getStores(): Promise<PathaoStoreListResponse>;
|
|
235
229
|
calculatePrice(priceData: PathaoPriceRequest): Promise<PathaoPriceResponse>;
|
|
236
230
|
getCities(): Promise<PathaoCityResponse>;
|
|
237
|
-
|
|
231
|
+
getZones(cityId: number): Promise<PathaoZoneResponse>;
|
|
232
|
+
getAreas(zoneId: number): Promise<PathaoAreaResponse>;
|
|
238
233
|
getOrderStatus(consignmentId: string): Promise<PathaoOrderStatusResponse>;
|
|
234
|
+
createBulkOrder(orders: PathaoOrderRequest[]): Promise<{
|
|
235
|
+
message: string;
|
|
236
|
+
type: string;
|
|
237
|
+
code: number;
|
|
238
|
+
data: boolean;
|
|
239
|
+
}>;
|
|
239
240
|
static validatePhoneNumber(phone: string): boolean;
|
|
240
241
|
static formatPhoneNumber(phone: string): string;
|
|
241
242
|
static validateAddress(address: string): boolean;
|
|
242
243
|
static validateWeight(weight: number): boolean;
|
|
243
244
|
static validateRecipientName(name: string): boolean;
|
|
245
|
+
static validateStoreName(name: string): boolean;
|
|
246
|
+
static validateContactName(name: string): boolean;
|
|
247
|
+
static validateContactNumber(phone: string): boolean;
|
|
248
|
+
static validateStoreAddress(address: string): boolean;
|
|
249
|
+
clearAuth(): void;
|
|
244
250
|
}
|
|
245
251
|
|
|
246
|
-
export { DeliveryType, ItemType, PathaoApiService, type PathaoAreaResponse, type PathaoAuthResponse, type PathaoCityResponse, type PathaoConfig, type PathaoError, type PathaoOrderRequest, type PathaoOrderResponse, type PathaoOrderStatusResponse, type PathaoPriceRequest, type PathaoPriceResponse, type
|
|
252
|
+
export { DeliveryType, ItemType, PathaoApiService, type PathaoAreaResponse, type PathaoAuthResponse, type PathaoCityResponse, type PathaoConfig, type PathaoError, type PathaoOrderRequest, type PathaoOrderResponse, type PathaoOrderStatusResponse, type PathaoPriceRequest, type PathaoPriceResponse, type PathaoStore, type PathaoStoreCreateResponse, type PathaoStoreListResponse, type PathaoStoreRequest, type PathaoZoneResponse };
|