@thorprovider/medusa-extended 1.2.3 → 1.3.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/dist/index.d.mts +91 -3
- package/dist/index.d.ts +91 -3
- package/dist/index.js +210 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +210 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/dropshipper.ts +307 -13
package/src/dropshipper.ts
CHANGED
|
@@ -106,6 +106,35 @@ import type {
|
|
|
106
106
|
GetDashboardStatsResponse,
|
|
107
107
|
// Storefront (V)
|
|
108
108
|
GetStorefrontDropshipperCategoriesResponse,
|
|
109
|
+
// Financial Endpoints — Group A
|
|
110
|
+
GetDropshipperAccountBalanceResponse,
|
|
111
|
+
GetDropshipperAccountOrdersOptions,
|
|
112
|
+
GetDropshipperAccountOrdersResponse,
|
|
113
|
+
GetAdminDropshipperAccountOrdersResponse,
|
|
114
|
+
GetAdminDropshipperAccountSettlementsOptions,
|
|
115
|
+
GetAdminDropshipperAccountSettlementsResponse,
|
|
116
|
+
ResolveGuaranteeBody,
|
|
117
|
+
ResolveGuaranteeResponse,
|
|
118
|
+
CreateCompensacionBody,
|
|
119
|
+
CreateCompensacionResponse,
|
|
120
|
+
CreateAjusteBody,
|
|
121
|
+
CreateAjusteResponse,
|
|
122
|
+
// Financial Endpoints — Group B
|
|
123
|
+
CreateCobroBody,
|
|
124
|
+
CreateCobroResponse,
|
|
125
|
+
CreatePagoBody,
|
|
126
|
+
CreatePagoResponse,
|
|
127
|
+
CreateReversoBody,
|
|
128
|
+
CreateReversoResponse,
|
|
129
|
+
ConfirmMovementBody,
|
|
130
|
+
ConfirmMovementResponse,
|
|
131
|
+
CancelMovementBody,
|
|
132
|
+
CancelMovementResponse,
|
|
133
|
+
GetFinancialAnalysisResponse,
|
|
134
|
+
RegisterPaymentBody,
|
|
135
|
+
RegisterPaymentResponse,
|
|
136
|
+
// Dashboard Capabilities
|
|
137
|
+
DropshipperDashboardCapabilities,
|
|
109
138
|
// Inline return types
|
|
110
139
|
DropshipperCategory,
|
|
111
140
|
DropshipperPromotion,
|
|
@@ -220,6 +249,22 @@ export class DropshipperClient {
|
|
|
220
249
|
return response.json() as Promise<T>;
|
|
221
250
|
}
|
|
222
251
|
|
|
252
|
+
// -------------------------------------------------------------------------
|
|
253
|
+
// Capabilities
|
|
254
|
+
// -------------------------------------------------------------------------
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Fetch dashboard capabilities from the backend.
|
|
258
|
+
*
|
|
259
|
+
* `GET /admin/thor/dropshipper/capabilities`
|
|
260
|
+
*/
|
|
261
|
+
async getCapabilities(): Promise<DropshipperDashboardCapabilities> {
|
|
262
|
+
return this.request<DropshipperDashboardCapabilities>(
|
|
263
|
+
'GET',
|
|
264
|
+
'/admin/thor/dropshipper/capabilities',
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
223
268
|
// -------------------------------------------------------------------------
|
|
224
269
|
// Onboarding (Solo X)
|
|
225
270
|
// -------------------------------------------------------------------------
|
|
@@ -422,6 +467,8 @@ export class DropshipperClient {
|
|
|
422
467
|
const qs = new URLSearchParams({
|
|
423
468
|
currency_code: params.currency_code.toLowerCase(),
|
|
424
469
|
...(params.country_code ? { country_code: params.country_code.toLowerCase() } : {}),
|
|
470
|
+
...(params.province ? { province: params.province } : {}),
|
|
471
|
+
...(params.city ? { city: params.city } : {}),
|
|
425
472
|
});
|
|
426
473
|
|
|
427
474
|
return this.request<GetDropshipperShippingOptionsResponse>(
|
|
@@ -636,8 +683,6 @@ export class DropshipperClient {
|
|
|
636
683
|
/**
|
|
637
684
|
* Delete a custom category.
|
|
638
685
|
*
|
|
639
|
-
* Pass `{ force: true }` to cascade-delete child categories.
|
|
640
|
-
*
|
|
641
686
|
* `DELETE /admin/thor/dropshipper/categories/:id`
|
|
642
687
|
*/
|
|
643
688
|
async deleteCategory(
|
|
@@ -676,7 +721,7 @@ export class DropshipperClient {
|
|
|
676
721
|
): Promise<CreateCategoryMappingResponse> {
|
|
677
722
|
return this.request<CreateCategoryMappingResponse>(
|
|
678
723
|
'POST',
|
|
679
|
-
|
|
724
|
+
`/admin/thor/dropshipper/category-mappings`,
|
|
680
725
|
body,
|
|
681
726
|
);
|
|
682
727
|
}
|
|
@@ -893,19 +938,53 @@ export class DropshipperClient {
|
|
|
893
938
|
*
|
|
894
939
|
* `GET /admin/thor/dropshipper/settlements/:id`
|
|
895
940
|
*/
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
941
|
+
async getSettlement(
|
|
942
|
+
settlementId: string,
|
|
943
|
+
): Promise<GetSettlementDetailResponse> {
|
|
944
|
+
return this.request<GetSettlementDetailResponse>(
|
|
945
|
+
'GET',
|
|
946
|
+
`/admin/thor/dropshipper/settlements/${settlementId}`,
|
|
947
|
+
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Consolidated financial balance for the authenticated dropshipper.
|
|
953
|
+
*
|
|
954
|
+
* `GET /admin/thor/dropshipper/account/balance`
|
|
955
|
+
*/
|
|
956
|
+
async getAccountBalance(): Promise<GetDropshipperAccountBalanceResponse> {
|
|
957
|
+
return this.request<GetDropshipperAccountBalanceResponse>(
|
|
900
958
|
'GET',
|
|
901
|
-
|
|
959
|
+
'/admin/thor/dropshipper/account/balance',
|
|
960
|
+
);
|
|
961
|
+
}
|
|
902
962
|
|
|
903
|
-
|
|
904
|
-
|
|
963
|
+
/**
|
|
964
|
+
* Unified financial order list for the authenticated dropshipper.
|
|
965
|
+
*
|
|
966
|
+
* `GET /admin/thor/dropshipper/account/orders`
|
|
967
|
+
*/
|
|
968
|
+
async getAccountOrders(
|
|
969
|
+
options: GetDropshipperAccountOrdersOptions = {},
|
|
970
|
+
): Promise<GetDropshipperAccountOrdersResponse> {
|
|
971
|
+
const { tab, status, limit = 20, offset = 0, q } = options;
|
|
972
|
+
const qs = new URLSearchParams({
|
|
973
|
+
limit: String(limit),
|
|
974
|
+
offset: String(offset),
|
|
975
|
+
...(tab ? { tab } : {}),
|
|
976
|
+
...(status ? { status } : {}),
|
|
977
|
+
...(q ? { q } : {}),
|
|
978
|
+
});
|
|
979
|
+
return this.request<GetDropshipperAccountOrdersResponse>(
|
|
980
|
+
'GET',
|
|
981
|
+
`/admin/thor/dropshipper/account/orders?${qs}`,
|
|
982
|
+
);
|
|
983
|
+
}
|
|
905
984
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
985
|
+
// -------------------------------------------------------------------------
|
|
986
|
+
// Admin Settlements (Solo X)
|
|
987
|
+
// -------------------------------------------------------------------------
|
|
909
988
|
|
|
910
989
|
/**
|
|
911
990
|
* Create a settlement record for a dropshipper account.
|
|
@@ -1034,6 +1113,221 @@ export class DropshipperClient {
|
|
|
1034
1113
|
);
|
|
1035
1114
|
}
|
|
1036
1115
|
|
|
1116
|
+
// -------------------------------------------------------------------------
|
|
1117
|
+
// Financial Endpoints — Group A (Admin X)
|
|
1118
|
+
// -------------------------------------------------------------------------
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* List orders with financial detail for a dropshipper account (Admin only).
|
|
1122
|
+
*
|
|
1123
|
+
* `GET /admin/thor/dropshipper/admin/accounts/:id/orders`
|
|
1124
|
+
*/
|
|
1125
|
+
async getAdminAccountOrders(
|
|
1126
|
+
accountId: string,
|
|
1127
|
+
options: GetDropshipperAccountOrdersOptions = {},
|
|
1128
|
+
): Promise<GetAdminDropshipperAccountOrdersResponse> {
|
|
1129
|
+
const { tab, status, limit = 20, offset = 0, q } = options;
|
|
1130
|
+
const qs = new URLSearchParams({
|
|
1131
|
+
limit: String(limit),
|
|
1132
|
+
offset: String(offset),
|
|
1133
|
+
...(tab ? { tab } : {}),
|
|
1134
|
+
...(status ? { status } : {}),
|
|
1135
|
+
...(q ? { q } : {}),
|
|
1136
|
+
});
|
|
1137
|
+
return this.request<GetAdminDropshipperAccountOrdersResponse>(
|
|
1138
|
+
'GET',
|
|
1139
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/orders?${qs}`,
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* List financial movements for a dropshipper account (Admin only).
|
|
1145
|
+
*
|
|
1146
|
+
* `GET /admin/thor/dropshipper/admin/accounts/:id/settlements`
|
|
1147
|
+
*/
|
|
1148
|
+
async getAdminAccountSettlements(
|
|
1149
|
+
accountId: string,
|
|
1150
|
+
options: GetAdminDropshipperAccountSettlementsOptions = {},
|
|
1151
|
+
): Promise<GetAdminDropshipperAccountSettlementsResponse> {
|
|
1152
|
+
const { type, status, limit = 20, offset = 0 } = options;
|
|
1153
|
+
const qs = new URLSearchParams({
|
|
1154
|
+
limit: String(limit),
|
|
1155
|
+
offset: String(offset),
|
|
1156
|
+
...(type ? { type } : {}),
|
|
1157
|
+
...(status ? { status } : {}),
|
|
1158
|
+
});
|
|
1159
|
+
return this.request<GetAdminDropshipperAccountSettlementsResponse>(
|
|
1160
|
+
'GET',
|
|
1161
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/settlements?${qs}`,
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Manually resolve a guarantee on an order (Admin only).
|
|
1167
|
+
*
|
|
1168
|
+
* `POST /admin/thor/dropshipper/admin/accounts/:id/guarantee/:order_id`
|
|
1169
|
+
*/
|
|
1170
|
+
async resolveGuarantee(
|
|
1171
|
+
accountId: string,
|
|
1172
|
+
orderId: string,
|
|
1173
|
+
body: ResolveGuaranteeBody,
|
|
1174
|
+
): Promise<ResolveGuaranteeResponse> {
|
|
1175
|
+
return this.request<ResolveGuaranteeResponse>(
|
|
1176
|
+
'POST',
|
|
1177
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/guarantee/${orderId}`,
|
|
1178
|
+
body,
|
|
1179
|
+
);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Create an internal compensation (netting) between DS and Thor debts (Admin only).
|
|
1184
|
+
*
|
|
1185
|
+
* `POST /admin/thor/dropshipper/admin/accounts/:id/settlements/compensacion`
|
|
1186
|
+
*/
|
|
1187
|
+
async createCompensacion(
|
|
1188
|
+
accountId: string,
|
|
1189
|
+
body: CreateCompensacionBody,
|
|
1190
|
+
): Promise<CreateCompensacionResponse> {
|
|
1191
|
+
return this.request<CreateCompensacionResponse>(
|
|
1192
|
+
'POST',
|
|
1193
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/settlements/compensacion`,
|
|
1194
|
+
body,
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* Create a financial adjustment (Admin only).
|
|
1200
|
+
*
|
|
1201
|
+
* `POST /admin/thor/dropshipper/admin/accounts/:id/settlements/ajuste`
|
|
1202
|
+
*/
|
|
1203
|
+
async createAjuste(
|
|
1204
|
+
accountId: string,
|
|
1205
|
+
body: CreateAjusteBody,
|
|
1206
|
+
): Promise<CreateAjusteResponse> {
|
|
1207
|
+
return this.request<CreateAjusteResponse>(
|
|
1208
|
+
'POST',
|
|
1209
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/settlements/ajuste`,
|
|
1210
|
+
body,
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// -------------------------------------------------------------------------
|
|
1215
|
+
// Financial Endpoints — Group B (Admin X)
|
|
1216
|
+
// -------------------------------------------------------------------------
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* Register a cobro — DS pays Thor the product cost (Admin only).
|
|
1220
|
+
*
|
|
1221
|
+
* `POST /admin/thor/dropshipper/admin/accounts/:id/settlements/cobro`
|
|
1222
|
+
*/
|
|
1223
|
+
async createCobro(
|
|
1224
|
+
accountId: string,
|
|
1225
|
+
body: CreateCobroBody,
|
|
1226
|
+
): Promise<CreateCobroResponse> {
|
|
1227
|
+
return this.request<CreateCobroResponse>(
|
|
1228
|
+
'POST',
|
|
1229
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/settlements/cobro`,
|
|
1230
|
+
body,
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/**
|
|
1235
|
+
* Register a pago — Thor pays the dropshipper their commission (Admin only).
|
|
1236
|
+
*
|
|
1237
|
+
* `POST /admin/thor/dropshipper/admin/accounts/:id/settlements/pago`
|
|
1238
|
+
*/
|
|
1239
|
+
async createPago(
|
|
1240
|
+
accountId: string,
|
|
1241
|
+
body: CreatePagoBody,
|
|
1242
|
+
): Promise<CreatePagoResponse> {
|
|
1243
|
+
return this.request<CreatePagoResponse>(
|
|
1244
|
+
'POST',
|
|
1245
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/settlements/pago`,
|
|
1246
|
+
body,
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* Reverse a confirmed financial movement (Admin only).
|
|
1252
|
+
*
|
|
1253
|
+
* `POST /admin/thor/dropshipper/admin/accounts/:id/settlements/:mov_id/reverso`
|
|
1254
|
+
*/
|
|
1255
|
+
async reverseSettlement(
|
|
1256
|
+
accountId: string,
|
|
1257
|
+
movementId: string,
|
|
1258
|
+
body: CreateReversoBody,
|
|
1259
|
+
): Promise<CreateReversoResponse> {
|
|
1260
|
+
return this.request<CreateReversoResponse>(
|
|
1261
|
+
'POST',
|
|
1262
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/settlements/${movementId}/reverso`,
|
|
1263
|
+
body,
|
|
1264
|
+
);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* Confirm a pending financial movement (Admin only).
|
|
1269
|
+
*
|
|
1270
|
+
* `POST /admin/thor/dropshipper/admin/accounts/:id/settlements/:mov_id/confirm`
|
|
1271
|
+
*/
|
|
1272
|
+
async confirmSettlementMovement(
|
|
1273
|
+
accountId: string,
|
|
1274
|
+
movementId: string,
|
|
1275
|
+
body: ConfirmMovementBody = {},
|
|
1276
|
+
): Promise<ConfirmMovementResponse> {
|
|
1277
|
+
return this.request<ConfirmMovementResponse>(
|
|
1278
|
+
'POST',
|
|
1279
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/settlements/${movementId}/confirm`,
|
|
1280
|
+
body,
|
|
1281
|
+
);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Cancel a pending financial movement draft (Admin only).
|
|
1286
|
+
*
|
|
1287
|
+
* `POST /admin/thor/dropshipper/admin/accounts/:id/settlements/:mov_id/cancel`
|
|
1288
|
+
*/
|
|
1289
|
+
async cancelSettlementMovement(
|
|
1290
|
+
accountId: string,
|
|
1291
|
+
movementId: string,
|
|
1292
|
+
body: CancelMovementBody,
|
|
1293
|
+
): Promise<CancelMovementResponse> {
|
|
1294
|
+
return this.request<CancelMovementResponse>(
|
|
1295
|
+
'POST',
|
|
1296
|
+
`/admin/thor/dropshipper/admin/accounts/${accountId}/settlements/${movementId}/cancel`,
|
|
1297
|
+
body,
|
|
1298
|
+
);
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* Get financial analysis for a dropshipper order (Admin only).
|
|
1303
|
+
*
|
|
1304
|
+
* `GET /admin/thor/dropshipper/admin/orders/:id/financial-analysis`
|
|
1305
|
+
*/
|
|
1306
|
+
async getOrderFinancialAnalysis(
|
|
1307
|
+
orderId: string,
|
|
1308
|
+
): Promise<GetFinancialAnalysisResponse> {
|
|
1309
|
+
return this.request<GetFinancialAnalysisResponse>(
|
|
1310
|
+
'GET',
|
|
1311
|
+
`/admin/thor/dropshipper/admin/orders/${orderId}/financial-analysis`,
|
|
1312
|
+
);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Register a partial or full payment for an order.
|
|
1317
|
+
*
|
|
1318
|
+
* `POST /admin/thor/dropshipper/orders/:id/payment`
|
|
1319
|
+
*/
|
|
1320
|
+
async registerOrderPayment(
|
|
1321
|
+
orderId: string,
|
|
1322
|
+
body: RegisterPaymentBody,
|
|
1323
|
+
): Promise<RegisterPaymentResponse> {
|
|
1324
|
+
return this.request<RegisterPaymentResponse>(
|
|
1325
|
+
'POST',
|
|
1326
|
+
`/admin/thor/dropshipper/orders/${orderId}/payment`,
|
|
1327
|
+
body,
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1037
1331
|
// -------------------------------------------------------------------------
|
|
1038
1332
|
// Promotions (Solo Y)
|
|
1039
1333
|
// -------------------------------------------------------------------------
|