@basedone/core 0.2.2 → 0.2.4
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/{chunk-Z5OW2FDP.mjs → chunk-NVL2HX2H.mjs} +602 -1
- package/dist/ecommerce.d.mts +1321 -8
- package/dist/ecommerce.d.ts +1321 -8
- package/dist/ecommerce.js +602 -1
- package/dist/ecommerce.mjs +1 -1
- package/dist/index.d.mts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +609 -1
- package/dist/index.mjs +8 -2
- package/lib/ecommerce/client/base.ts +7 -1
- package/lib/ecommerce/client/customer.ts +217 -0
- package/lib/ecommerce/client/merchant.ts +783 -0
- package/lib/ecommerce/types/entities.ts +94 -0
- package/lib/ecommerce/types/enums.ts +7 -1
- package/lib/ecommerce/types/requests.ts +151 -0
- package/lib/ecommerce/types/responses.ts +314 -0
- package/lib/utils/formatter.ts +1 -1
- package/lib/utils/time.ts +24 -0
- package/package.json +3 -2
|
@@ -130,11 +130,13 @@ var BaseEcommerceClient = class {
|
|
|
130
130
|
maxRetries: config.maxRetries || 3,
|
|
131
131
|
retryBaseDelay: config.retryBaseDelay || 1e3,
|
|
132
132
|
headers: config.headers,
|
|
133
|
-
enableRetry: config.enableRetry !== false
|
|
133
|
+
enableRetry: config.enableRetry !== false,
|
|
134
|
+
withCredentials: config.withCredentials || false
|
|
134
135
|
};
|
|
135
136
|
this.axiosInstance = axios.create({
|
|
136
137
|
baseURL: this.config.baseURL,
|
|
137
138
|
timeout: this.config.timeout,
|
|
139
|
+
withCredentials: this.config.withCredentials,
|
|
138
140
|
headers: {
|
|
139
141
|
"Content-Type": "application/json",
|
|
140
142
|
...this.config.headers
|
|
@@ -678,6 +680,34 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
678
680
|
return this.post("/api/marketplace/tax/calculate", request);
|
|
679
681
|
}
|
|
680
682
|
// ============================================================================
|
|
683
|
+
// Shipping Calculation API
|
|
684
|
+
// ============================================================================
|
|
685
|
+
/**
|
|
686
|
+
* Calculate shipping options for cart items
|
|
687
|
+
*
|
|
688
|
+
* @param request - Cart items, merchant, and destination
|
|
689
|
+
* @returns Available shipping options with costs
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* ```typescript
|
|
693
|
+
* const result = await client.calculateShippingOptions({
|
|
694
|
+
* merchantId: "merchant_123",
|
|
695
|
+
* cartItems: [
|
|
696
|
+
* { productId: "prod_123", quantity: 2 }
|
|
697
|
+
* ],
|
|
698
|
+
* destinationCountry: "US",
|
|
699
|
+
* orderSubtotal: 99.99
|
|
700
|
+
* });
|
|
701
|
+
*
|
|
702
|
+
* result.shippingOptions.forEach(opt => {
|
|
703
|
+
* console.log(opt.name, opt.cost, opt.estimatedDelivery);
|
|
704
|
+
* });
|
|
705
|
+
* ```
|
|
706
|
+
*/
|
|
707
|
+
async calculateShippingOptions(request) {
|
|
708
|
+
return this.post("/api/marketplace/shipping/calculate", request);
|
|
709
|
+
}
|
|
710
|
+
// ============================================================================
|
|
681
711
|
// Banners API
|
|
682
712
|
// ============================================================================
|
|
683
713
|
/**
|
|
@@ -935,6 +965,171 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
935
965
|
const queryString = params ? buildQueryString(params) : "";
|
|
936
966
|
return this.get(`/api/marketplace/following${queryString}`);
|
|
937
967
|
}
|
|
968
|
+
// ============================================================================
|
|
969
|
+
// Payment Methods
|
|
970
|
+
// ============================================================================
|
|
971
|
+
/**
|
|
972
|
+
* Get available payment methods
|
|
973
|
+
*
|
|
974
|
+
* Returns the list of enabled payment methods that can be used during checkout.
|
|
975
|
+
*
|
|
976
|
+
* @returns List of available payment methods with display info
|
|
977
|
+
*
|
|
978
|
+
* @example
|
|
979
|
+
* ```typescript
|
|
980
|
+
* const result = await client.getPaymentMethods();
|
|
981
|
+
* if (result.paymentsEnabled) {
|
|
982
|
+
* result.methods.forEach(method => {
|
|
983
|
+
* console.log(`${method.name}: ${method.description}`);
|
|
984
|
+
* });
|
|
985
|
+
* }
|
|
986
|
+
* ```
|
|
987
|
+
*/
|
|
988
|
+
async getPaymentMethods() {
|
|
989
|
+
return this.get("/api/marketplace/payments/methods");
|
|
990
|
+
}
|
|
991
|
+
// ============================================================================
|
|
992
|
+
// GEM System API
|
|
993
|
+
// ============================================================================
|
|
994
|
+
/**
|
|
995
|
+
* Get user's gem balance
|
|
996
|
+
*
|
|
997
|
+
* Returns the current gem balance including total gems, available gems,
|
|
998
|
+
* and gems expiring soon. Gems are earned at 100 per $1 of revenue.
|
|
999
|
+
*
|
|
1000
|
+
* @returns Current gem balance with USD equivalent
|
|
1001
|
+
*
|
|
1002
|
+
* @example
|
|
1003
|
+
* ```typescript
|
|
1004
|
+
* const balance = await client.getGemBalance();
|
|
1005
|
+
* console.log(`You have ${balance.totalGems} gems (${balance.usdEquivalent} USD)`);
|
|
1006
|
+
* console.log(`${balance.expiringSoon} gems expiring soon`);
|
|
1007
|
+
* ```
|
|
1008
|
+
*/
|
|
1009
|
+
async getGemBalance() {
|
|
1010
|
+
return this.get("/api/gems/balance");
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Get gem transaction history
|
|
1014
|
+
*
|
|
1015
|
+
* Returns paginated history of gem transactions including earning,
|
|
1016
|
+
* spending, and expiration events.
|
|
1017
|
+
*
|
|
1018
|
+
* @param params - Query parameters for filtering and pagination
|
|
1019
|
+
* @returns Paginated gem history
|
|
1020
|
+
*
|
|
1021
|
+
* @example
|
|
1022
|
+
* ```typescript
|
|
1023
|
+
* // Get all history
|
|
1024
|
+
* const history = await client.getGemHistory({ limit: 20, offset: 0 });
|
|
1025
|
+
*
|
|
1026
|
+
* // Get only earned gems
|
|
1027
|
+
* const earned = await client.getGemHistory({ type: "earn", limit: 10 });
|
|
1028
|
+
*
|
|
1029
|
+
* // Get only spent gems
|
|
1030
|
+
* const spent = await client.getGemHistory({ type: "spend", limit: 10 });
|
|
1031
|
+
*
|
|
1032
|
+
* history.items.forEach(item => {
|
|
1033
|
+
* console.log(`${item.type}: ${item.amount} gems - ${item.createdAt}`);
|
|
1034
|
+
* });
|
|
1035
|
+
* ```
|
|
1036
|
+
*/
|
|
1037
|
+
async getGemHistory(params) {
|
|
1038
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
1039
|
+
return this.get(`/api/gems/history${queryString}`);
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Get gems that are expiring soon
|
|
1043
|
+
*
|
|
1044
|
+
* Returns gem batches that will expire within the specified number of days.
|
|
1045
|
+
* Useful for prompting users to spend gems before they expire.
|
|
1046
|
+
*
|
|
1047
|
+
* @param params - Query parameters (days: default 30, max 180)
|
|
1048
|
+
* @returns Expiring gem batches with countdown info
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```typescript
|
|
1052
|
+
* // Get gems expiring in next 30 days (default)
|
|
1053
|
+
* const expiring = await client.getExpiringGems();
|
|
1054
|
+
*
|
|
1055
|
+
* // Get gems expiring in next 7 days
|
|
1056
|
+
* const urgent = await client.getExpiringGems({ days: 7 });
|
|
1057
|
+
*
|
|
1058
|
+
* if (expiring.totalExpiring > 0) {
|
|
1059
|
+
* console.log(`${expiring.totalExpiring} gems expiring soon!`);
|
|
1060
|
+
* expiring.batches.forEach(batch => {
|
|
1061
|
+
* console.log(`${batch.amount} gems expire in ${batch.daysUntilExpiry} days`);
|
|
1062
|
+
* });
|
|
1063
|
+
* }
|
|
1064
|
+
* ```
|
|
1065
|
+
*/
|
|
1066
|
+
async getExpiringGems(params) {
|
|
1067
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
1068
|
+
return this.get(`/api/gems/expiring${queryString}`);
|
|
1069
|
+
}
|
|
1070
|
+
// ============================================================================
|
|
1071
|
+
// Browsing Location API
|
|
1072
|
+
// ============================================================================
|
|
1073
|
+
/**
|
|
1074
|
+
* Get user's browsing location
|
|
1075
|
+
*
|
|
1076
|
+
* Returns the user's saved delivery location for geo-based product filtering.
|
|
1077
|
+
* This location is used to show products from merchants that ship to the area.
|
|
1078
|
+
*
|
|
1079
|
+
* @returns Current browsing location or null if not set
|
|
1080
|
+
*
|
|
1081
|
+
* @example
|
|
1082
|
+
* ```typescript
|
|
1083
|
+
* const result = await client.getBrowsingLocation();
|
|
1084
|
+
* if (result.location) {
|
|
1085
|
+
* console.log(`Delivery to: ${result.location.city}, ${result.location.country}`);
|
|
1086
|
+
* }
|
|
1087
|
+
* ```
|
|
1088
|
+
*/
|
|
1089
|
+
async getBrowsingLocation() {
|
|
1090
|
+
return this.get("/api/user/browsing-location");
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Save user's browsing location
|
|
1094
|
+
*
|
|
1095
|
+
* Sets the user's delivery location for geo-based product filtering.
|
|
1096
|
+
* Products will be filtered to show only items from merchants that ship to this location.
|
|
1097
|
+
*
|
|
1098
|
+
* @param request - Location data from Google Places or manual input
|
|
1099
|
+
* @returns The saved location
|
|
1100
|
+
*
|
|
1101
|
+
* @example
|
|
1102
|
+
* ```typescript
|
|
1103
|
+
* const result = await client.saveBrowsingLocation({
|
|
1104
|
+
* formattedAddress: "Singapore, Singapore",
|
|
1105
|
+
* city: "Singapore",
|
|
1106
|
+
* country: "SG",
|
|
1107
|
+
* latitude: 1.3521,
|
|
1108
|
+
* longitude: 103.8198
|
|
1109
|
+
* });
|
|
1110
|
+
* console.log(`Location saved: ${result.location.formattedAddress}`);
|
|
1111
|
+
* ```
|
|
1112
|
+
*/
|
|
1113
|
+
async saveBrowsingLocation(request) {
|
|
1114
|
+
return this.post("/api/user/browsing-location", request);
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Clear user's browsing location
|
|
1118
|
+
*
|
|
1119
|
+
* Removes the user's saved delivery location. Products will no longer
|
|
1120
|
+
* be filtered by shipping destination.
|
|
1121
|
+
*
|
|
1122
|
+
* @returns Success response
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```typescript
|
|
1126
|
+
* await client.clearBrowsingLocation();
|
|
1127
|
+
* console.log("Location cleared - showing all products");
|
|
1128
|
+
* ```
|
|
1129
|
+
*/
|
|
1130
|
+
async clearBrowsingLocation() {
|
|
1131
|
+
return this.delete("/api/user/browsing-location");
|
|
1132
|
+
}
|
|
938
1133
|
};
|
|
939
1134
|
|
|
940
1135
|
// lib/ecommerce/client/merchant.ts
|
|
@@ -1469,6 +1664,192 @@ var MerchantEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1469
1664
|
return this.patch(`/api/marketplace/merchant/shipping/shipments/${shipmentId}`, request);
|
|
1470
1665
|
}
|
|
1471
1666
|
// ============================================================================
|
|
1667
|
+
// Shipping Settings (Zones & Rates)
|
|
1668
|
+
// ============================================================================
|
|
1669
|
+
/**
|
|
1670
|
+
* Get merchant shipping settings
|
|
1671
|
+
*
|
|
1672
|
+
* @returns Shipping settings
|
|
1673
|
+
*
|
|
1674
|
+
* @example
|
|
1675
|
+
* ```typescript
|
|
1676
|
+
* const { settings } = await client.getShippingSettings();
|
|
1677
|
+
* console.log("Handling fee:", settings.defaultHandlingFee);
|
|
1678
|
+
* ```
|
|
1679
|
+
*/
|
|
1680
|
+
async getShippingSettings() {
|
|
1681
|
+
return this.get("/api/marketplace/merchant/shipping/settings");
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Update merchant shipping settings
|
|
1685
|
+
*
|
|
1686
|
+
* @param request - Settings to update
|
|
1687
|
+
* @returns Updated settings
|
|
1688
|
+
*
|
|
1689
|
+
* @example
|
|
1690
|
+
* ```typescript
|
|
1691
|
+
* await client.updateShippingSettings({
|
|
1692
|
+
* defaultHandlingFee: 2.50,
|
|
1693
|
+
* freeShippingEnabled: true,
|
|
1694
|
+
* freeShippingThreshold: 100
|
|
1695
|
+
* });
|
|
1696
|
+
* ```
|
|
1697
|
+
*/
|
|
1698
|
+
async updateShippingSettings(request) {
|
|
1699
|
+
return this.post("/api/marketplace/merchant/shipping/settings", request);
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* List all shipping zones
|
|
1703
|
+
*
|
|
1704
|
+
* @returns List of shipping zones with rate counts
|
|
1705
|
+
*
|
|
1706
|
+
* @example
|
|
1707
|
+
* ```typescript
|
|
1708
|
+
* const { zones } = await client.listShippingZones();
|
|
1709
|
+
* zones.forEach(z => console.log(z.name, z.countries.length, "countries"));
|
|
1710
|
+
* ```
|
|
1711
|
+
*/
|
|
1712
|
+
async listShippingZones() {
|
|
1713
|
+
return this.get("/api/marketplace/merchant/shipping/zones");
|
|
1714
|
+
}
|
|
1715
|
+
/**
|
|
1716
|
+
* Get a shipping zone by ID
|
|
1717
|
+
*
|
|
1718
|
+
* @param zoneId - Zone ID
|
|
1719
|
+
* @returns Zone with rates
|
|
1720
|
+
*
|
|
1721
|
+
* @example
|
|
1722
|
+
* ```typescript
|
|
1723
|
+
* const { zone } = await client.getShippingZone("zone_123");
|
|
1724
|
+
* console.log(zone.name, zone.rates?.length, "rates");
|
|
1725
|
+
* ```
|
|
1726
|
+
*/
|
|
1727
|
+
async getShippingZone(zoneId) {
|
|
1728
|
+
return this.get(`/api/marketplace/merchant/shipping/zones/${zoneId}`);
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Create a shipping zone
|
|
1732
|
+
*
|
|
1733
|
+
* @param request - Zone data
|
|
1734
|
+
* @returns Created zone
|
|
1735
|
+
*
|
|
1736
|
+
* @example
|
|
1737
|
+
* ```typescript
|
|
1738
|
+
* const { zone } = await client.createShippingZone({
|
|
1739
|
+
* name: "Southeast Asia",
|
|
1740
|
+
* countries: ["SG", "MY", "TH", "ID", "PH", "VN"],
|
|
1741
|
+
* isDefault: false,
|
|
1742
|
+
* priority: 10
|
|
1743
|
+
* });
|
|
1744
|
+
* ```
|
|
1745
|
+
*/
|
|
1746
|
+
async createShippingZone(request) {
|
|
1747
|
+
return this.post("/api/marketplace/merchant/shipping/zones", request);
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Update a shipping zone
|
|
1751
|
+
*
|
|
1752
|
+
* @param zoneId - Zone ID
|
|
1753
|
+
* @param request - Updated zone data
|
|
1754
|
+
* @returns Updated zone
|
|
1755
|
+
*
|
|
1756
|
+
* @example
|
|
1757
|
+
* ```typescript
|
|
1758
|
+
* await client.updateShippingZone("zone_123", {
|
|
1759
|
+
* countries: ["SG", "MY", "TH", "ID", "PH", "VN", "BN"]
|
|
1760
|
+
* });
|
|
1761
|
+
* ```
|
|
1762
|
+
*/
|
|
1763
|
+
async updateShippingZone(zoneId, request) {
|
|
1764
|
+
return this.put(`/api/marketplace/merchant/shipping/zones/${zoneId}`, request);
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* Delete a shipping zone
|
|
1768
|
+
*
|
|
1769
|
+
* @param zoneId - Zone ID
|
|
1770
|
+
* @returns Success response
|
|
1771
|
+
*
|
|
1772
|
+
* @example
|
|
1773
|
+
* ```typescript
|
|
1774
|
+
* await client.deleteShippingZone("zone_123");
|
|
1775
|
+
* ```
|
|
1776
|
+
*/
|
|
1777
|
+
async deleteShippingZone(zoneId) {
|
|
1778
|
+
return this.delete(`/api/marketplace/merchant/shipping/zones/${zoneId}`);
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* List shipping rates
|
|
1782
|
+
*
|
|
1783
|
+
* @param zoneId - Optional zone ID to filter by
|
|
1784
|
+
* @returns List of shipping rates
|
|
1785
|
+
*
|
|
1786
|
+
* @example
|
|
1787
|
+
* ```typescript
|
|
1788
|
+
* // All rates
|
|
1789
|
+
* const { rates } = await client.listShippingRates();
|
|
1790
|
+
*
|
|
1791
|
+
* // Rates for a specific zone
|
|
1792
|
+
* const { rates: zoneRates } = await client.listShippingRates("zone_123");
|
|
1793
|
+
* ```
|
|
1794
|
+
*/
|
|
1795
|
+
async listShippingRates(zoneId) {
|
|
1796
|
+
const query = zoneId ? `?zoneId=${zoneId}` : "";
|
|
1797
|
+
return this.get(`/api/marketplace/merchant/shipping/rates${query}`);
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* Create a shipping rate
|
|
1801
|
+
*
|
|
1802
|
+
* @param request - Rate data
|
|
1803
|
+
* @returns Created rate
|
|
1804
|
+
*
|
|
1805
|
+
* @example
|
|
1806
|
+
* ```typescript
|
|
1807
|
+
* const { rate } = await client.createShippingRate({
|
|
1808
|
+
* zoneId: "zone_123",
|
|
1809
|
+
* name: "Standard Shipping",
|
|
1810
|
+
* baseRate: 5.00,
|
|
1811
|
+
* perKgRate: 1.50,
|
|
1812
|
+
* minDeliveryDays: 7,
|
|
1813
|
+
* maxDeliveryDays: 14
|
|
1814
|
+
* });
|
|
1815
|
+
* ```
|
|
1816
|
+
*/
|
|
1817
|
+
async createShippingRate(request) {
|
|
1818
|
+
return this.post("/api/marketplace/merchant/shipping/rates", request);
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* Update a shipping rate
|
|
1822
|
+
*
|
|
1823
|
+
* @param rateId - Rate ID
|
|
1824
|
+
* @param request - Updated rate data
|
|
1825
|
+
* @returns Updated rate
|
|
1826
|
+
*
|
|
1827
|
+
* @example
|
|
1828
|
+
* ```typescript
|
|
1829
|
+
* await client.updateShippingRate("rate_123", {
|
|
1830
|
+
* baseRate: 6.00,
|
|
1831
|
+
* freeAboveAmount: 75
|
|
1832
|
+
* });
|
|
1833
|
+
* ```
|
|
1834
|
+
*/
|
|
1835
|
+
async updateShippingRate(rateId, request) {
|
|
1836
|
+
return this.put(`/api/marketplace/merchant/shipping/rates/${rateId}`, request);
|
|
1837
|
+
}
|
|
1838
|
+
/**
|
|
1839
|
+
* Delete a shipping rate
|
|
1840
|
+
*
|
|
1841
|
+
* @param rateId - Rate ID
|
|
1842
|
+
* @returns Success response
|
|
1843
|
+
*
|
|
1844
|
+
* @example
|
|
1845
|
+
* ```typescript
|
|
1846
|
+
* await client.deleteShippingRate("rate_123");
|
|
1847
|
+
* ```
|
|
1848
|
+
*/
|
|
1849
|
+
async deleteShippingRate(rateId) {
|
|
1850
|
+
return this.delete(`/api/marketplace/merchant/shipping/rates/${rateId}`);
|
|
1851
|
+
}
|
|
1852
|
+
// ============================================================================
|
|
1472
1853
|
// Returns & Refunds
|
|
1473
1854
|
// ============================================================================
|
|
1474
1855
|
/**
|
|
@@ -2066,6 +2447,223 @@ var MerchantEcommerceClient = class extends BaseEcommerceClient {
|
|
|
2066
2447
|
async exportTaxReport(reportId) {
|
|
2067
2448
|
return this.get(`/api/marketplace/merchant/tax-reports/${reportId}/export`);
|
|
2068
2449
|
}
|
|
2450
|
+
// ============================================
|
|
2451
|
+
// DROPSHIPPING APIs
|
|
2452
|
+
// ============================================
|
|
2453
|
+
/**
|
|
2454
|
+
* List connected dropship suppliers
|
|
2455
|
+
*
|
|
2456
|
+
* @returns Connected and available suppliers
|
|
2457
|
+
*
|
|
2458
|
+
* @example
|
|
2459
|
+
* ```typescript
|
|
2460
|
+
* const { connected, available } = await client.listDropshipSuppliers();
|
|
2461
|
+
* ```
|
|
2462
|
+
*/
|
|
2463
|
+
async listDropshipSuppliers() {
|
|
2464
|
+
return this.get("/api/marketplace/merchant/dropship/suppliers");
|
|
2465
|
+
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Connect a new dropship supplier
|
|
2468
|
+
*
|
|
2469
|
+
* @param request - Supplier credentials
|
|
2470
|
+
* @returns Connected supplier
|
|
2471
|
+
*
|
|
2472
|
+
* @example
|
|
2473
|
+
* ```typescript
|
|
2474
|
+
* const supplier = await client.connectDropshipSupplier({
|
|
2475
|
+
* code: "CJ_DROPSHIPPING",
|
|
2476
|
+
* apiKey: "your-api-key"
|
|
2477
|
+
* });
|
|
2478
|
+
* ```
|
|
2479
|
+
*/
|
|
2480
|
+
async connectDropshipSupplier(request) {
|
|
2481
|
+
return this.post("/api/marketplace/merchant/dropship/suppliers", request);
|
|
2482
|
+
}
|
|
2483
|
+
/**
|
|
2484
|
+
* Update dropship supplier settings
|
|
2485
|
+
*
|
|
2486
|
+
* @param supplierId - Supplier ID
|
|
2487
|
+
* @param request - Settings to update
|
|
2488
|
+
* @returns Updated supplier
|
|
2489
|
+
*/
|
|
2490
|
+
async updateDropshipSupplier(supplierId, request) {
|
|
2491
|
+
return this.put(`/api/marketplace/merchant/dropship/suppliers/${supplierId}`, request);
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
* Disconnect a dropship supplier
|
|
2495
|
+
*
|
|
2496
|
+
* @param supplierId - Supplier ID
|
|
2497
|
+
*/
|
|
2498
|
+
async disconnectDropshipSupplier(supplierId) {
|
|
2499
|
+
return this.delete(`/api/marketplace/merchant/dropship/suppliers/${supplierId}`);
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Search products from connected suppliers
|
|
2503
|
+
*
|
|
2504
|
+
* @param request - Search parameters
|
|
2505
|
+
* @returns Search results with pagination
|
|
2506
|
+
*
|
|
2507
|
+
* @example
|
|
2508
|
+
* ```typescript
|
|
2509
|
+
* const results = await client.searchDropshipProducts({
|
|
2510
|
+
* supplierId: "supplier_123",
|
|
2511
|
+
* query: "wireless headphones",
|
|
2512
|
+
* limit: 20
|
|
2513
|
+
* });
|
|
2514
|
+
* ```
|
|
2515
|
+
*/
|
|
2516
|
+
async searchDropshipProducts(request) {
|
|
2517
|
+
return this.post("/api/marketplace/merchant/dropship/search", request);
|
|
2518
|
+
}
|
|
2519
|
+
/**
|
|
2520
|
+
* Get dropship supplier categories
|
|
2521
|
+
*
|
|
2522
|
+
* @param supplierId - Supplier ID
|
|
2523
|
+
* @returns Category list
|
|
2524
|
+
*/
|
|
2525
|
+
async getDropshipCategories(supplierId) {
|
|
2526
|
+
return this.get(`/api/marketplace/merchant/dropship/categories?supplierId=${supplierId}`);
|
|
2527
|
+
}
|
|
2528
|
+
/**
|
|
2529
|
+
* Get detailed product info from supplier
|
|
2530
|
+
*
|
|
2531
|
+
* @param supplierId - Supplier ID
|
|
2532
|
+
* @param externalProductId - Supplier's product ID
|
|
2533
|
+
* @returns Product details with suggested pricing
|
|
2534
|
+
*/
|
|
2535
|
+
async getDropshipProductDetails(supplierId, externalProductId) {
|
|
2536
|
+
return this.get(
|
|
2537
|
+
`/api/marketplace/merchant/dropship/products/${encodeURIComponent(externalProductId)}?supplierId=${supplierId}`
|
|
2538
|
+
);
|
|
2539
|
+
}
|
|
2540
|
+
/**
|
|
2541
|
+
* Import a product from supplier to your store
|
|
2542
|
+
*
|
|
2543
|
+
* @param request - Import parameters
|
|
2544
|
+
* @returns Created product IDs
|
|
2545
|
+
*
|
|
2546
|
+
* @example
|
|
2547
|
+
* ```typescript
|
|
2548
|
+
* const result = await client.importDropshipProduct({
|
|
2549
|
+
* supplierId: "supplier_123",
|
|
2550
|
+
* externalProductId: "ext_product_456",
|
|
2551
|
+
* priceUSDC: 29.99,
|
|
2552
|
+
* title: "Custom Title"
|
|
2553
|
+
* });
|
|
2554
|
+
* ```
|
|
2555
|
+
*/
|
|
2556
|
+
async importDropshipProduct(request) {
|
|
2557
|
+
return this.post("/api/marketplace/merchant/dropship/import", request);
|
|
2558
|
+
}
|
|
2559
|
+
/**
|
|
2560
|
+
* Bulk import products from supplier
|
|
2561
|
+
*
|
|
2562
|
+
* @param request - Bulk import parameters
|
|
2563
|
+
* @returns Import results
|
|
2564
|
+
*/
|
|
2565
|
+
async bulkImportDropshipProducts(request) {
|
|
2566
|
+
return this.post("/api/marketplace/merchant/dropship/import", request);
|
|
2567
|
+
}
|
|
2568
|
+
/**
|
|
2569
|
+
* List imported dropship products
|
|
2570
|
+
*
|
|
2571
|
+
* @param params - Filter parameters
|
|
2572
|
+
* @returns Imported products list
|
|
2573
|
+
*/
|
|
2574
|
+
async listDropshipProducts(params) {
|
|
2575
|
+
const query = params ? `?${buildQueryString(params)}` : "";
|
|
2576
|
+
return this.get(`/api/marketplace/merchant/dropship/import${query}`);
|
|
2577
|
+
}
|
|
2578
|
+
/**
|
|
2579
|
+
* List dropship order links
|
|
2580
|
+
*
|
|
2581
|
+
* @param params - Filter parameters
|
|
2582
|
+
* @returns Order links with status summary
|
|
2583
|
+
*/
|
|
2584
|
+
async listDropshipOrders(params) {
|
|
2585
|
+
let query = "";
|
|
2586
|
+
if (params) {
|
|
2587
|
+
const queryParams = {};
|
|
2588
|
+
if (params.status) {
|
|
2589
|
+
queryParams.status = Array.isArray(params.status) ? params.status.join(",") : params.status;
|
|
2590
|
+
}
|
|
2591
|
+
if (params.limit) queryParams.limit = params.limit.toString();
|
|
2592
|
+
if (params.offset) queryParams.offset = params.offset.toString();
|
|
2593
|
+
query = `?${buildQueryString(queryParams)}`;
|
|
2594
|
+
}
|
|
2595
|
+
return this.get(`/api/marketplace/merchant/dropship/orders${query}`);
|
|
2596
|
+
}
|
|
2597
|
+
/**
|
|
2598
|
+
* Forward orders to supplier
|
|
2599
|
+
*
|
|
2600
|
+
* @param orderItemIds - Order item IDs to forward
|
|
2601
|
+
* @returns Forward results
|
|
2602
|
+
*/
|
|
2603
|
+
async forwardDropshipOrders(orderItemIds) {
|
|
2604
|
+
return this.post("/api/marketplace/merchant/dropship/orders", {
|
|
2605
|
+
action: "forward",
|
|
2606
|
+
orderItemIds
|
|
2607
|
+
});
|
|
2608
|
+
}
|
|
2609
|
+
/**
|
|
2610
|
+
* Sync tracking for all pending dropship orders
|
|
2611
|
+
*
|
|
2612
|
+
* @returns Sync results
|
|
2613
|
+
*/
|
|
2614
|
+
async syncDropshipTracking() {
|
|
2615
|
+
return this.post("/api/marketplace/merchant/dropship/orders", {
|
|
2616
|
+
action: "sync"
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
* Get order forwarding details for manual forwarding
|
|
2621
|
+
*
|
|
2622
|
+
* @param orderItemId - Order item ID
|
|
2623
|
+
* @returns Forwarding details
|
|
2624
|
+
*/
|
|
2625
|
+
async getDropshipOrderDetails(orderItemId) {
|
|
2626
|
+
return this.get(`/api/marketplace/merchant/dropship/orders/${orderItemId}/forward`);
|
|
2627
|
+
}
|
|
2628
|
+
/**
|
|
2629
|
+
* Forward a single order item to supplier
|
|
2630
|
+
*
|
|
2631
|
+
* @param orderItemId - Order item ID
|
|
2632
|
+
* @returns Forward result
|
|
2633
|
+
*/
|
|
2634
|
+
async forwardDropshipOrder(orderItemId) {
|
|
2635
|
+
return this.post(`/api/marketplace/merchant/dropship/orders/${orderItemId}/forward`, {});
|
|
2636
|
+
}
|
|
2637
|
+
/**
|
|
2638
|
+
* Get dropship settings
|
|
2639
|
+
*
|
|
2640
|
+
* @returns Merchant dropship settings
|
|
2641
|
+
*/
|
|
2642
|
+
async getDropshipSettings() {
|
|
2643
|
+
return this.get("/api/marketplace/merchant/dropship/settings");
|
|
2644
|
+
}
|
|
2645
|
+
/**
|
|
2646
|
+
* Update dropship settings
|
|
2647
|
+
*
|
|
2648
|
+
* @param request - Settings to update
|
|
2649
|
+
* @returns Updated settings
|
|
2650
|
+
*/
|
|
2651
|
+
async updateDropshipSettings(request) {
|
|
2652
|
+
return this.put("/api/marketplace/merchant/dropship/settings", request);
|
|
2653
|
+
}
|
|
2654
|
+
/**
|
|
2655
|
+
* Sync dropship products and/or orders
|
|
2656
|
+
*
|
|
2657
|
+
* @param type - Sync type (products, orders, all, single)
|
|
2658
|
+
* @param dropshipProductId - For single product sync
|
|
2659
|
+
* @returns Sync results
|
|
2660
|
+
*/
|
|
2661
|
+
async syncDropship(type, dropshipProductId) {
|
|
2662
|
+
return this.post("/api/marketplace/merchant/dropship/sync", {
|
|
2663
|
+
type,
|
|
2664
|
+
dropshipProductId
|
|
2665
|
+
});
|
|
2666
|
+
}
|
|
2069
2667
|
};
|
|
2070
2668
|
|
|
2071
2669
|
// lib/ecommerce/types/enums.ts
|
|
@@ -2083,6 +2681,8 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
|
2083
2681
|
})(OrderStatus || {});
|
|
2084
2682
|
var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
|
|
2085
2683
|
PaymentMethod2["USDC_ESCROW"] = "USDC_ESCROW";
|
|
2684
|
+
PaymentMethod2["BASEDPAY"] = "BASEDPAY";
|
|
2685
|
+
PaymentMethod2["STRIPE"] = "STRIPE";
|
|
2086
2686
|
PaymentMethod2["POINTS"] = "POINTS";
|
|
2087
2687
|
return PaymentMethod2;
|
|
2088
2688
|
})(PaymentMethod || {});
|
|
@@ -2193,6 +2793,7 @@ var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
|
|
|
2193
2793
|
ProductSortBy2["PRICE_DESC"] = "price_desc";
|
|
2194
2794
|
ProductSortBy2["POPULAR"] = "popular";
|
|
2195
2795
|
ProductSortBy2["FEATURED"] = "featured";
|
|
2796
|
+
ProductSortBy2["NEARBY"] = "nearby";
|
|
2196
2797
|
return ProductSortBy2;
|
|
2197
2798
|
})(ProductSortBy || {});
|
|
2198
2799
|
var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
|