@profplum700/etsy-v3-api-client 2.4.2 → 2.4.3
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 +0 -1
- package/README.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.esm.js +161 -47
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +1 -1
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +161 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +78 -41
- package/dist/index.esm.js +161 -47
- package/dist/index.esm.js.map +1 -1
- package/dist/node.cjs +161 -47
- package/dist/node.cjs.map +1 -1
- package/dist/node.esm.js +161 -47
- package/dist/node.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/node.esm.js
CHANGED
|
@@ -1431,6 +1431,24 @@ class EtsyClient {
|
|
|
1431
1431
|
sleep(ms) {
|
|
1432
1432
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
1433
1433
|
}
|
|
1434
|
+
buildFormBody(params) {
|
|
1435
|
+
const body = new URLSearchParams();
|
|
1436
|
+
for (const [key, value] of Object.entries(params)) {
|
|
1437
|
+
if (value === undefined || value === null)
|
|
1438
|
+
continue;
|
|
1439
|
+
if (Array.isArray(value)) {
|
|
1440
|
+
for (const item of value) {
|
|
1441
|
+
if (item === undefined || item === null)
|
|
1442
|
+
continue;
|
|
1443
|
+
body.append(key, String(item));
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
else {
|
|
1447
|
+
body.append(key, String(value));
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
return body;
|
|
1451
|
+
}
|
|
1434
1452
|
getApiKey() {
|
|
1435
1453
|
if (this.sharedSecret) {
|
|
1436
1454
|
return `${this.keystring}:${this.sharedSecret}`;
|
|
@@ -1490,19 +1508,37 @@ class EtsyClient {
|
|
|
1490
1508
|
searchParams.set('sort_order', params.sort_order);
|
|
1491
1509
|
if (params.includes)
|
|
1492
1510
|
searchParams.set('includes', params.includes.join(','));
|
|
1511
|
+
if (params.legacy !== undefined) {
|
|
1512
|
+
searchParams.set('legacy', params.legacy.toString());
|
|
1513
|
+
}
|
|
1493
1514
|
const response = await this.makeRequest(`/shops/${targetShopId}/listings?${searchParams.toString()}`);
|
|
1494
1515
|
return response.results;
|
|
1495
1516
|
}
|
|
1496
|
-
async getListing(listingId,
|
|
1497
|
-
const
|
|
1498
|
-
|
|
1517
|
+
async getListing(listingId, params) {
|
|
1518
|
+
const resolvedParams = Array.isArray(params)
|
|
1519
|
+
? { includes: params }
|
|
1520
|
+
: params;
|
|
1521
|
+
const searchParams = new URLSearchParams();
|
|
1522
|
+
if (resolvedParams?.includes) {
|
|
1523
|
+
searchParams.set('includes', resolvedParams.includes.join(','));
|
|
1524
|
+
}
|
|
1525
|
+
if (resolvedParams?.language) {
|
|
1526
|
+
searchParams.set('language', resolvedParams.language);
|
|
1527
|
+
}
|
|
1528
|
+
if (resolvedParams?.legacy !== undefined) {
|
|
1529
|
+
searchParams.set('legacy', resolvedParams.legacy.toString());
|
|
1530
|
+
}
|
|
1531
|
+
if (resolvedParams?.allow_suggested_title !== undefined) {
|
|
1532
|
+
searchParams.set('allow_suggested_title', resolvedParams.allow_suggested_title.toString());
|
|
1533
|
+
}
|
|
1534
|
+
const query = searchParams.toString();
|
|
1535
|
+
const suffix = query ? `?${query}` : '';
|
|
1536
|
+
return this.makeRequest(`/listings/${listingId}${suffix}`);
|
|
1499
1537
|
}
|
|
1500
1538
|
async findAllListingsActive(params = {}) {
|
|
1501
1539
|
const searchParams = new URLSearchParams();
|
|
1502
1540
|
if (params.keywords)
|
|
1503
1541
|
searchParams.set('keywords', params.keywords);
|
|
1504
|
-
if (params.category)
|
|
1505
|
-
searchParams.set('category', params.category);
|
|
1506
1542
|
if (params.limit !== undefined)
|
|
1507
1543
|
searchParams.set('limit', params.limit.toString());
|
|
1508
1544
|
if (params.offset !== undefined)
|
|
@@ -1515,12 +1551,14 @@ class EtsyClient {
|
|
|
1515
1551
|
searchParams.set('min_price', params.min_price.toString());
|
|
1516
1552
|
if (params.max_price !== undefined)
|
|
1517
1553
|
searchParams.set('max_price', params.max_price.toString());
|
|
1518
|
-
if (params.
|
|
1519
|
-
searchParams.set('
|
|
1520
|
-
|
|
1521
|
-
searchParams.set('location', params.location);
|
|
1554
|
+
if (params.taxonomy_id !== undefined) {
|
|
1555
|
+
searchParams.set('taxonomy_id', params.taxonomy_id.toString());
|
|
1556
|
+
}
|
|
1522
1557
|
if (params.shop_location)
|
|
1523
1558
|
searchParams.set('shop_location', params.shop_location);
|
|
1559
|
+
if (params.legacy !== undefined) {
|
|
1560
|
+
searchParams.set('legacy', params.legacy.toString());
|
|
1561
|
+
}
|
|
1524
1562
|
const response = await this.makeRequest(`/listings/active?${searchParams.toString()}`);
|
|
1525
1563
|
return response.results;
|
|
1526
1564
|
}
|
|
@@ -1528,8 +1566,20 @@ class EtsyClient {
|
|
|
1528
1566
|
const response = await this.makeRequest(`/listings/${listingId}/images`);
|
|
1529
1567
|
return response.results;
|
|
1530
1568
|
}
|
|
1531
|
-
async getListingInventory(listingId) {
|
|
1532
|
-
|
|
1569
|
+
async getListingInventory(listingId, params = {}) {
|
|
1570
|
+
const searchParams = new URLSearchParams();
|
|
1571
|
+
if (params.show_deleted !== undefined) {
|
|
1572
|
+
searchParams.set('show_deleted', params.show_deleted.toString());
|
|
1573
|
+
}
|
|
1574
|
+
if (params.includes) {
|
|
1575
|
+
searchParams.set('includes', params.includes);
|
|
1576
|
+
}
|
|
1577
|
+
if (params.legacy !== undefined) {
|
|
1578
|
+
searchParams.set('legacy', params.legacy.toString());
|
|
1579
|
+
}
|
|
1580
|
+
const query = searchParams.toString();
|
|
1581
|
+
const suffix = query ? `?${query}` : '';
|
|
1582
|
+
return this.makeRequest(`/listings/${listingId}/inventory${suffix}`);
|
|
1533
1583
|
}
|
|
1534
1584
|
async getReviewsByListing(listingId, params = {}) {
|
|
1535
1585
|
const searchParams = new URLSearchParams();
|
|
@@ -1566,7 +1616,8 @@ class EtsyClient {
|
|
|
1566
1616
|
return response.results;
|
|
1567
1617
|
}
|
|
1568
1618
|
async getUserShops() {
|
|
1569
|
-
const
|
|
1619
|
+
const user = await this.getUser();
|
|
1620
|
+
const response = await this.makeRequest(`/users/${user.user_id}/shops`);
|
|
1570
1621
|
return response.results || [];
|
|
1571
1622
|
}
|
|
1572
1623
|
async updateShop(shopId, params, options) {
|
|
@@ -1583,21 +1634,27 @@ class EtsyClient {
|
|
|
1583
1634
|
}
|
|
1584
1635
|
}
|
|
1585
1636
|
}
|
|
1637
|
+
const body = this.buildFormBody(params);
|
|
1586
1638
|
return this.makeRequest(`/shops/${shopId}`, {
|
|
1587
1639
|
method: 'PUT',
|
|
1588
|
-
|
|
1640
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1641
|
+
body: body.toString()
|
|
1589
1642
|
}, false);
|
|
1590
1643
|
}
|
|
1591
1644
|
async createShopSection(shopId, params) {
|
|
1645
|
+
const body = this.buildFormBody(params);
|
|
1592
1646
|
return this.makeRequest(`/shops/${shopId}/sections`, {
|
|
1593
1647
|
method: 'POST',
|
|
1594
|
-
|
|
1648
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1649
|
+
body: body.toString()
|
|
1595
1650
|
}, false);
|
|
1596
1651
|
}
|
|
1597
1652
|
async updateShopSection(shopId, sectionId, params) {
|
|
1653
|
+
const body = this.buildFormBody(params);
|
|
1598
1654
|
return this.makeRequest(`/shops/${shopId}/sections/${sectionId}`, {
|
|
1599
1655
|
method: 'PUT',
|
|
1600
|
-
|
|
1656
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1657
|
+
body: body.toString()
|
|
1601
1658
|
}, false);
|
|
1602
1659
|
}
|
|
1603
1660
|
async deleteShopSection(shopId, sectionId) {
|
|
@@ -1617,9 +1674,13 @@ class EtsyClient {
|
|
|
1617
1674
|
}
|
|
1618
1675
|
}
|
|
1619
1676
|
}
|
|
1620
|
-
|
|
1677
|
+
const legacy = options?.legacy;
|
|
1678
|
+
const query = legacy !== undefined ? `?legacy=${legacy}` : '';
|
|
1679
|
+
const body = this.buildFormBody(params);
|
|
1680
|
+
return this.makeRequest(`/shops/${shopId}/listings${query}`, {
|
|
1621
1681
|
method: 'POST',
|
|
1622
|
-
|
|
1682
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1683
|
+
body: body.toString()
|
|
1623
1684
|
}, false);
|
|
1624
1685
|
}
|
|
1625
1686
|
async updateListing(shopId, listingId, params, options) {
|
|
@@ -1636,16 +1697,22 @@ class EtsyClient {
|
|
|
1636
1697
|
}
|
|
1637
1698
|
}
|
|
1638
1699
|
}
|
|
1639
|
-
|
|
1700
|
+
const legacy = options?.legacy;
|
|
1701
|
+
const query = legacy !== undefined ? `?legacy=${legacy}` : '';
|
|
1702
|
+
const body = this.buildFormBody(params);
|
|
1703
|
+
return this.makeRequest(`/shops/${shopId}/listings/${listingId}${query}`, {
|
|
1640
1704
|
method: 'PATCH',
|
|
1641
|
-
|
|
1705
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1706
|
+
body: body.toString()
|
|
1642
1707
|
}, false);
|
|
1643
1708
|
}
|
|
1644
1709
|
async deleteListing(listingId) {
|
|
1645
1710
|
await this.makeRequest(`/listings/${listingId}`, { method: 'DELETE' }, false);
|
|
1646
1711
|
}
|
|
1647
|
-
async updateListingInventory(listingId, params) {
|
|
1648
|
-
|
|
1712
|
+
async updateListingInventory(listingId, params, options) {
|
|
1713
|
+
const legacy = options?.legacy;
|
|
1714
|
+
const query = legacy !== undefined ? `?legacy=${legacy}` : '';
|
|
1715
|
+
return this.makeRequest(`/listings/${listingId}/inventory${query}`, {
|
|
1649
1716
|
method: 'PUT',
|
|
1650
1717
|
body: JSON.stringify(params)
|
|
1651
1718
|
}, false);
|
|
@@ -1678,8 +1745,8 @@ class EtsyClient {
|
|
|
1678
1745
|
}
|
|
1679
1746
|
return response.json();
|
|
1680
1747
|
}
|
|
1681
|
-
async getListingImage(
|
|
1682
|
-
return this.makeRequest(`/
|
|
1748
|
+
async getListingImage(listingId, imageId) {
|
|
1749
|
+
return this.makeRequest(`/listings/${listingId}/images/${imageId}`);
|
|
1683
1750
|
}
|
|
1684
1751
|
async deleteListingImage(shopId, listingId, imageId) {
|
|
1685
1752
|
await this.makeRequest(`/shops/${shopId}/listings/${listingId}/images/${imageId}`, { method: 'DELETE' }, false);
|
|
@@ -1726,20 +1793,40 @@ class EtsyClient {
|
|
|
1726
1793
|
searchParams.set('was_shipped', params.was_shipped.toString());
|
|
1727
1794
|
if (params?.was_delivered !== undefined)
|
|
1728
1795
|
searchParams.set('was_delivered', params.was_delivered.toString());
|
|
1796
|
+
if (params?.was_canceled !== undefined)
|
|
1797
|
+
searchParams.set('was_canceled', params.was_canceled.toString());
|
|
1798
|
+
if (params?.legacy !== undefined)
|
|
1799
|
+
searchParams.set('legacy', params.legacy.toString());
|
|
1729
1800
|
const response = await this.makeRequest(`/shops/${shopId}/receipts?${searchParams.toString()}`);
|
|
1730
1801
|
return response.results;
|
|
1731
1802
|
}
|
|
1732
|
-
async getShopReceipt(shopId, receiptId) {
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1803
|
+
async getShopReceipt(shopId, receiptId, params = {}) {
|
|
1804
|
+
const searchParams = new URLSearchParams();
|
|
1805
|
+
if (params.legacy !== undefined) {
|
|
1806
|
+
searchParams.set('legacy', params.legacy.toString());
|
|
1807
|
+
}
|
|
1808
|
+
const query = searchParams.toString();
|
|
1809
|
+
const suffix = query ? `?${query}` : '';
|
|
1810
|
+
return this.makeRequest(`/shops/${shopId}/receipts/${receiptId}${suffix}`);
|
|
1811
|
+
}
|
|
1812
|
+
async updateShopReceipt(shopId, receiptId, params, options) {
|
|
1813
|
+
const legacy = options?.legacy;
|
|
1814
|
+
const query = legacy !== undefined ? `?legacy=${legacy}` : '';
|
|
1815
|
+
const body = this.buildFormBody(params);
|
|
1816
|
+
return this.makeRequest(`/shops/${shopId}/receipts/${receiptId}${query}`, {
|
|
1737
1817
|
method: 'PUT',
|
|
1738
|
-
|
|
1818
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1819
|
+
body: body.toString()
|
|
1739
1820
|
}, false);
|
|
1740
1821
|
}
|
|
1741
|
-
async getShopReceiptTransactions(shopId, receiptId) {
|
|
1742
|
-
const
|
|
1822
|
+
async getShopReceiptTransactions(shopId, receiptId, params = {}) {
|
|
1823
|
+
const searchParams = new URLSearchParams();
|
|
1824
|
+
if (params.legacy !== undefined) {
|
|
1825
|
+
searchParams.set('legacy', params.legacy.toString());
|
|
1826
|
+
}
|
|
1827
|
+
const query = searchParams.toString();
|
|
1828
|
+
const suffix = query ? `?${query}` : '';
|
|
1829
|
+
const response = await this.makeRequest(`/shops/${shopId}/receipts/${receiptId}/transactions${suffix}`);
|
|
1743
1830
|
return response.results;
|
|
1744
1831
|
}
|
|
1745
1832
|
async getShopTransaction(shopId, transactionId) {
|
|
@@ -1750,37 +1837,54 @@ class EtsyClient {
|
|
|
1750
1837
|
return response.results;
|
|
1751
1838
|
}
|
|
1752
1839
|
async createShopShippingProfile(shopId, params) {
|
|
1840
|
+
const body = this.buildFormBody(params);
|
|
1753
1841
|
return this.makeRequest(`/shops/${shopId}/shipping-profiles`, {
|
|
1754
1842
|
method: 'POST',
|
|
1755
|
-
|
|
1843
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1844
|
+
body: body.toString()
|
|
1756
1845
|
}, false);
|
|
1757
1846
|
}
|
|
1758
1847
|
async getShopShippingProfile(shopId, profileId) {
|
|
1759
1848
|
return this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}`);
|
|
1760
1849
|
}
|
|
1761
1850
|
async updateShopShippingProfile(shopId, profileId, params) {
|
|
1851
|
+
const body = this.buildFormBody(params);
|
|
1762
1852
|
return this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}`, {
|
|
1763
1853
|
method: 'PUT',
|
|
1764
|
-
|
|
1854
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1855
|
+
body: body.toString()
|
|
1765
1856
|
}, false);
|
|
1766
1857
|
}
|
|
1767
1858
|
async deleteShopShippingProfile(shopId, profileId) {
|
|
1768
1859
|
await this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}`, { method: 'DELETE' }, false);
|
|
1769
1860
|
}
|
|
1770
|
-
async getShopShippingProfileDestinations(shopId, profileId) {
|
|
1771
|
-
const
|
|
1861
|
+
async getShopShippingProfileDestinations(shopId, profileId, params = {}) {
|
|
1862
|
+
const searchParams = new URLSearchParams();
|
|
1863
|
+
if (params.limit !== undefined) {
|
|
1864
|
+
searchParams.set('limit', params.limit.toString());
|
|
1865
|
+
}
|
|
1866
|
+
if (params.offset !== undefined) {
|
|
1867
|
+
searchParams.set('offset', params.offset.toString());
|
|
1868
|
+
}
|
|
1869
|
+
const query = searchParams.toString();
|
|
1870
|
+
const suffix = query ? `?${query}` : '';
|
|
1871
|
+
const response = await this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}/destinations${suffix}`);
|
|
1772
1872
|
return response.results;
|
|
1773
1873
|
}
|
|
1774
1874
|
async createShopShippingProfileDestination(shopId, profileId, params) {
|
|
1875
|
+
const body = this.buildFormBody(params);
|
|
1775
1876
|
return this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}/destinations`, {
|
|
1776
1877
|
method: 'POST',
|
|
1777
|
-
|
|
1878
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1879
|
+
body: body.toString()
|
|
1778
1880
|
}, false);
|
|
1779
1881
|
}
|
|
1780
1882
|
async updateShopShippingProfileDestination(shopId, profileId, destinationId, params) {
|
|
1883
|
+
const body = this.buildFormBody(params);
|
|
1781
1884
|
return this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}/destinations/${destinationId}`, {
|
|
1782
1885
|
method: 'PUT',
|
|
1783
|
-
|
|
1886
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1887
|
+
body: body.toString()
|
|
1784
1888
|
}, false);
|
|
1785
1889
|
}
|
|
1786
1890
|
async deleteShopShippingProfileDestination(shopId, profileId, destinationId) {
|
|
@@ -1790,16 +1894,16 @@ class EtsyClient {
|
|
|
1790
1894
|
const response = await this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}/upgrades`);
|
|
1791
1895
|
return response.results;
|
|
1792
1896
|
}
|
|
1793
|
-
async createReceiptShipment(shopId, receiptId, params) {
|
|
1794
|
-
|
|
1897
|
+
async createReceiptShipment(shopId, receiptId, params, options) {
|
|
1898
|
+
const legacy = options?.legacy;
|
|
1899
|
+
const query = legacy !== undefined ? `?legacy=${legacy}` : '';
|
|
1900
|
+
const body = this.buildFormBody(params);
|
|
1901
|
+
return this.makeRequest(`/shops/${shopId}/receipts/${receiptId}/tracking${query}`, {
|
|
1795
1902
|
method: 'POST',
|
|
1796
|
-
|
|
1903
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1904
|
+
body: body.toString()
|
|
1797
1905
|
}, false);
|
|
1798
1906
|
}
|
|
1799
|
-
async getShopReceiptShipments(shopId, receiptId) {
|
|
1800
|
-
const response = await this.makeRequest(`/shops/${shopId}/receipts/${receiptId}/shipments`);
|
|
1801
|
-
return response.results;
|
|
1802
|
-
}
|
|
1803
1907
|
async getShopPaymentAccountLedgerEntries(shopId, params) {
|
|
1804
1908
|
const searchParams = new URLSearchParams();
|
|
1805
1909
|
searchParams.set('min_created', params.min_created.toString());
|
|
@@ -1814,8 +1918,18 @@ class EtsyClient {
|
|
|
1814
1918
|
async getShopPaymentAccountLedgerEntry(shopId, entryId) {
|
|
1815
1919
|
return this.makeRequest(`/shops/${shopId}/payment-account/ledger-entries/${entryId}`);
|
|
1816
1920
|
}
|
|
1921
|
+
async getPayments(shopId, paymentIds) {
|
|
1922
|
+
const searchParams = new URLSearchParams();
|
|
1923
|
+
searchParams.set('payment_ids', paymentIds.join(','));
|
|
1924
|
+
const response = await this.makeRequest(`/shops/${shopId}/payments?${searchParams.toString()}`);
|
|
1925
|
+
return response.results;
|
|
1926
|
+
}
|
|
1817
1927
|
async getShopPayment(shopId, paymentId) {
|
|
1818
|
-
|
|
1928
|
+
const payments = await this.getPayments(shopId, [Number(paymentId)]);
|
|
1929
|
+
if (payments.length === 0) {
|
|
1930
|
+
throw new EtsyApiError('Payment not found', 404);
|
|
1931
|
+
}
|
|
1932
|
+
return payments[0];
|
|
1819
1933
|
}
|
|
1820
1934
|
async getBuyerTaxonomyNodes() {
|
|
1821
1935
|
const response = await this.makeRequest('/buyer-taxonomy/nodes');
|
|
@@ -1832,8 +1946,8 @@ class EtsyClient {
|
|
|
1832
1946
|
async updateListingProperty(params) {
|
|
1833
1947
|
const { shopId, listingId, propertyId, valueIds, values, scaleId } = params;
|
|
1834
1948
|
const body = new URLSearchParams();
|
|
1835
|
-
valueIds.forEach(id => body.append('value_ids
|
|
1836
|
-
values.forEach(val => body.append('values
|
|
1949
|
+
valueIds.forEach(id => body.append('value_ids', id.toString()));
|
|
1950
|
+
values.forEach(val => body.append('values', val));
|
|
1837
1951
|
if (scaleId !== undefined) {
|
|
1838
1952
|
body.append('scale_id', scaleId.toString());
|
|
1839
1953
|
}
|