@profplum700/etsy-v3-api-client 2.4.3 → 2.5.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.ts CHANGED
@@ -976,6 +976,211 @@ interface UploadListingFileParams {
976
976
  name?: string;
977
977
  rank?: number;
978
978
  }
979
+ interface EtsyShopProcessingProfile {
980
+ shop_id: number;
981
+ readiness_state_id: number;
982
+ readiness_state: 'ready_to_ship' | 'made_to_order';
983
+ min_processing_days: number;
984
+ max_processing_days: number;
985
+ processing_days_display_label: string;
986
+ }
987
+ interface CreateReadinessStateParams {
988
+ readiness_state: 'ready_to_ship' | 'made_to_order';
989
+ min_processing_time: number;
990
+ max_processing_time: number;
991
+ processing_time_unit?: 'days' | 'weeks';
992
+ }
993
+ interface UpdateReadinessStateParams {
994
+ readiness_state?: 'ready_to_ship' | 'made_to_order';
995
+ min_processing_time?: number;
996
+ max_processing_time?: number;
997
+ processing_time_unit?: 'days' | 'weeks';
998
+ }
999
+ interface GetReadinessStateParams {
1000
+ limit?: number;
1001
+ offset?: number;
1002
+ }
1003
+ interface EtsyShopReturnPolicy {
1004
+ return_policy_id: number;
1005
+ shop_id: number;
1006
+ accepts_returns: boolean;
1007
+ accepts_exchanges: boolean;
1008
+ return_deadline: number | null;
1009
+ }
1010
+ interface CreateReturnPolicyParams {
1011
+ accepts_returns: boolean;
1012
+ accepts_exchanges: boolean;
1013
+ return_deadline?: number | null;
1014
+ }
1015
+ interface UpdateReturnPolicyParams {
1016
+ accepts_returns: boolean;
1017
+ accepts_exchanges: boolean;
1018
+ return_deadline?: number | null;
1019
+ }
1020
+ interface ConsolidateReturnPoliciesParams {
1021
+ source_return_policy_id: number;
1022
+ destination_return_policy_id: number;
1023
+ }
1024
+ interface EtsyShopHolidayPreference {
1025
+ shop_id: number;
1026
+ holiday_id: number;
1027
+ country_iso: string;
1028
+ is_working: boolean;
1029
+ holiday_name: string;
1030
+ }
1031
+ interface UpdateHolidayPreferencesParams {
1032
+ is_working: boolean;
1033
+ }
1034
+ interface EtsyListingFile {
1035
+ listing_file_id: number;
1036
+ listing_id: number;
1037
+ rank: number;
1038
+ filename: string;
1039
+ filesize: string;
1040
+ size_bytes: number;
1041
+ filetype: string;
1042
+ create_timestamp: number;
1043
+ created_timestamp: number;
1044
+ }
1045
+ interface EtsyListingVideo {
1046
+ video_id: number;
1047
+ height: number;
1048
+ width: number;
1049
+ thumbnail_url: string;
1050
+ video_url: string;
1051
+ video_state: 'active' | 'inactive' | 'deleted' | 'flagged';
1052
+ }
1053
+ interface EtsyListingTranslation {
1054
+ listing_id: number;
1055
+ language: string;
1056
+ title: string | null;
1057
+ description: string | null;
1058
+ tags: string[];
1059
+ }
1060
+ interface CreateListingTranslationParams {
1061
+ title: string;
1062
+ description: string;
1063
+ tags?: string[];
1064
+ }
1065
+ interface UpdateListingTranslationParams {
1066
+ title: string;
1067
+ description: string;
1068
+ tags?: string[];
1069
+ }
1070
+ interface EtsyListingVariationImage {
1071
+ property_id: number;
1072
+ value_id: number;
1073
+ value: string | null;
1074
+ image_id: number;
1075
+ }
1076
+ interface UpdateVariationImagesParams {
1077
+ variation_images: Array<{
1078
+ property_id: number;
1079
+ value_id: number;
1080
+ image_id: number;
1081
+ }>;
1082
+ }
1083
+ interface EtsyUserAddress {
1084
+ user_address_id: number;
1085
+ user_id: number;
1086
+ name: string;
1087
+ first_line: string;
1088
+ second_line: string | null;
1089
+ city: string;
1090
+ state: string | null;
1091
+ zip: string | null;
1092
+ iso_country_code: string | null;
1093
+ country_name: string | null;
1094
+ is_default_shipping_address: boolean;
1095
+ }
1096
+ interface EtsyShippingCarrierMailClass {
1097
+ mail_class_key: string;
1098
+ name: string;
1099
+ }
1100
+ interface EtsyShippingCarrier {
1101
+ shipping_carrier_id: number;
1102
+ name: string;
1103
+ domestic_classes: EtsyShippingCarrierMailClass[];
1104
+ international_classes: EtsyShippingCarrierMailClass[];
1105
+ }
1106
+ interface FindShopsParams {
1107
+ shop_name: string;
1108
+ limit?: number;
1109
+ offset?: number;
1110
+ }
1111
+ interface GetListingsByIdsParams {
1112
+ listing_ids: number[];
1113
+ includes?: ListingIncludes[];
1114
+ legacy?: boolean;
1115
+ }
1116
+ interface FindActiveListingsByShopParams {
1117
+ limit?: number;
1118
+ offset?: number;
1119
+ sort_on?: 'created' | 'price' | 'updated' | 'score';
1120
+ sort_order?: 'asc' | 'ascending' | 'desc' | 'descending' | 'up' | 'down';
1121
+ keywords?: string;
1122
+ legacy?: boolean;
1123
+ }
1124
+ interface GetFeaturedListingsParams {
1125
+ limit?: number;
1126
+ offset?: number;
1127
+ legacy?: boolean;
1128
+ }
1129
+ interface GetListingsByShopReceiptParams {
1130
+ limit?: number;
1131
+ offset?: number;
1132
+ legacy?: boolean;
1133
+ }
1134
+ interface GetListingsBySectionParams {
1135
+ shop_section_ids: number[];
1136
+ limit?: number;
1137
+ offset?: number;
1138
+ sort_on?: 'created' | 'price' | 'updated' | 'score';
1139
+ sort_order?: 'asc' | 'ascending' | 'desc' | 'descending' | 'up' | 'down';
1140
+ legacy?: boolean;
1141
+ }
1142
+ interface GetListingsByReturnPolicyParams {
1143
+ legacy?: boolean;
1144
+ }
1145
+ interface CreateShippingProfileUpgradeParams {
1146
+ type: number;
1147
+ upgrade_name: string;
1148
+ price: number;
1149
+ secondary_price: number;
1150
+ shipping_carrier_id?: number;
1151
+ mail_class?: string;
1152
+ min_delivery_days?: number;
1153
+ max_delivery_days?: number;
1154
+ }
1155
+ interface UpdateShippingProfileUpgradeParams {
1156
+ upgrade_name?: string;
1157
+ type?: number;
1158
+ price?: number;
1159
+ secondary_price?: number;
1160
+ shipping_carrier_id?: number;
1161
+ mail_class?: string;
1162
+ min_delivery_days?: number;
1163
+ max_delivery_days?: number;
1164
+ }
1165
+ interface GetTransactionsByListingParams {
1166
+ limit?: number;
1167
+ offset?: number;
1168
+ legacy?: boolean;
1169
+ }
1170
+ interface GetTransactionsByShopParams {
1171
+ limit?: number;
1172
+ offset?: number;
1173
+ legacy?: boolean;
1174
+ }
1175
+ interface GetLedgerEntryPaymentsParams {
1176
+ ledger_entry_ids: number[];
1177
+ }
1178
+ interface TokenScopesParams {
1179
+ token: string;
1180
+ }
1181
+ interface TokenScopesResponse {
1182
+ scopes: string[];
1183
+ }
979
1184
 
980
1185
  interface BulkOperationConfig {
981
1186
  concurrency?: number;
@@ -1176,6 +1381,65 @@ declare class EtsyClient {
1176
1381
  getListingProperties(shopId: string, listingId: string): Promise<EtsyListingProperty[]>;
1177
1382
  updateListingProperty(params: UpdateListingPropertyParams): Promise<EtsyListingProperty>;
1178
1383
  getShopProductionPartners(shopId: string): Promise<EtsyShopProductionPartner[]>;
1384
+ createShopReadinessStateDefinition(shopId: string, params: CreateReadinessStateParams): Promise<EtsyShopProcessingProfile>;
1385
+ getShopReadinessStateDefinitions(shopId: string, params?: GetReadinessStateParams): Promise<EtsyShopProcessingProfile[]>;
1386
+ getShopReadinessStateDefinition(shopId: string, definitionId: string): Promise<EtsyShopProcessingProfile>;
1387
+ updateShopReadinessStateDefinition(shopId: string, definitionId: string, params: UpdateReadinessStateParams): Promise<EtsyShopProcessingProfile>;
1388
+ deleteShopReadinessStateDefinition(shopId: string, definitionId: string): Promise<void>;
1389
+ createShopReturnPolicy(shopId: string, params: CreateReturnPolicyParams): Promise<EtsyShopReturnPolicy>;
1390
+ getShopReturnPolicies(shopId: string): Promise<EtsyShopReturnPolicy[]>;
1391
+ getShopReturnPolicy(shopId: string, returnPolicyId: string): Promise<EtsyShopReturnPolicy>;
1392
+ updateShopReturnPolicy(shopId: string, returnPolicyId: string, params: UpdateReturnPolicyParams): Promise<EtsyShopReturnPolicy>;
1393
+ deleteShopReturnPolicy(shopId: string, returnPolicyId: string): Promise<void>;
1394
+ consolidateShopReturnPolicies(shopId: string, params: ConsolidateReturnPoliciesParams): Promise<EtsyShopReturnPolicy>;
1395
+ getHolidayPreferences(shopId: string): Promise<EtsyShopHolidayPreference[]>;
1396
+ updateHolidayPreferences(shopId: string, holidayId: string, params: UpdateHolidayPreferencesParams): Promise<EtsyShopHolidayPreference>;
1397
+ uploadListingFile(shopId: string, listingId: string, fileData: Blob | Buffer, params?: {
1398
+ name?: string;
1399
+ rank?: number;
1400
+ listing_file_id?: number;
1401
+ }): Promise<EtsyListingFile>;
1402
+ getAllListingFiles(shopId: string, listingId: string): Promise<EtsyListingFile[]>;
1403
+ getListingFile(shopId: string, listingId: string, fileId: string): Promise<EtsyListingFile>;
1404
+ deleteListingFile(shopId: string, listingId: string, fileId: string): Promise<void>;
1405
+ uploadListingVideo(shopId: string, listingId: string, videoData: Blob | Buffer, params?: {
1406
+ name?: string;
1407
+ video_id?: number;
1408
+ }): Promise<EtsyListingVideo>;
1409
+ getListingVideos(listingId: string): Promise<EtsyListingVideo[]>;
1410
+ getListingVideo(listingId: string, videoId: string): Promise<EtsyListingVideo>;
1411
+ deleteListingVideo(shopId: string, listingId: string, videoId: string): Promise<void>;
1412
+ createListingTranslation(shopId: string, listingId: string, language: string, params: CreateListingTranslationParams): Promise<EtsyListingTranslation>;
1413
+ getListingTranslation(shopId: string, listingId: string, language: string): Promise<EtsyListingTranslation>;
1414
+ updateListingTranslation(shopId: string, listingId: string, language: string, params: UpdateListingTranslationParams): Promise<EtsyListingTranslation>;
1415
+ getListingVariationImages(shopId: string, listingId: string): Promise<EtsyListingVariationImage[]>;
1416
+ updateVariationImages(shopId: string, listingId: string, params: UpdateVariationImagesParams): Promise<EtsyListingVariationImage[]>;
1417
+ findAllActiveListingsByShop(shopId: string, params?: FindActiveListingsByShopParams): Promise<EtsyListing[]>;
1418
+ getFeaturedListingsByShop(shopId: string, params?: GetFeaturedListingsParams): Promise<EtsyListing[]>;
1419
+ getListingsByListingIds(params: GetListingsByIdsParams): Promise<EtsyListing[]>;
1420
+ getListingsByShopReceipt(shopId: string, receiptId: string, params?: GetListingsByShopReceiptParams): Promise<EtsyListing[]>;
1421
+ getListingProperty(listingId: string, propertyId: string): Promise<EtsyListingProperty>;
1422
+ deleteListingProperty(shopId: string, listingId: string, propertyId: string): Promise<void>;
1423
+ getListingProduct(listingId: string, productId: string): Promise<EtsyListingProduct>;
1424
+ getListingOffering(listingId: string, productId: string, offeringId: string): Promise<EtsyListingOffering>;
1425
+ getListingsByShopSectionId(shopId: string, params: GetListingsBySectionParams): Promise<EtsyListing[]>;
1426
+ getListingsByShopReturnPolicy(shopId: string, returnPolicyId: string, params?: GetListingsByReturnPolicyParams): Promise<EtsyListing[]>;
1427
+ findShops(params: FindShopsParams): Promise<EtsyShop[]>;
1428
+ createShopShippingProfileUpgrade(shopId: string, profileId: string, params: CreateShippingProfileUpgradeParams): Promise<EtsyShippingProfileUpgrade>;
1429
+ updateShopShippingProfileUpgrade(shopId: string, profileId: string, upgradeId: string, params: UpdateShippingProfileUpgradeParams): Promise<EtsyShippingProfileUpgrade>;
1430
+ deleteShopShippingProfileUpgrade(shopId: string, profileId: string, upgradeId: string): Promise<void>;
1431
+ getShippingCarriers(originCountryIso: string): Promise<EtsyShippingCarrier[]>;
1432
+ getShopReceiptTransactionsByListing(shopId: string, listingId: string, params?: GetTransactionsByListingParams): Promise<EtsyShopReceiptTransaction[]>;
1433
+ getShopReceiptTransactionsByShop(shopId: string, params?: GetTransactionsByShopParams): Promise<EtsyShopReceiptTransaction[]>;
1434
+ getPaymentAccountLedgerEntryPayments(shopId: string, params: GetLedgerEntryPaymentsParams): Promise<EtsyPayment[]>;
1435
+ getShopPaymentByReceiptId(shopId: string, receiptId: string): Promise<EtsyPayment[]>;
1436
+ getMe(): Promise<EtsyUser>;
1437
+ getUserAddresses(): Promise<EtsyUserAddress[]>;
1438
+ getUserAddress(userAddressId: string): Promise<EtsyUserAddress>;
1439
+ deleteUserAddress(userAddressId: string): Promise<void>;
1440
+ getPropertiesByBuyerTaxonomyId(taxonomyId: number): Promise<EtsyBuyerTaxonomyProperty[]>;
1441
+ ping(): Promise<number>;
1442
+ tokenScopes(params: TokenScopesParams): Promise<TokenScopesResponse>;
1179
1443
  getRemainingRequests(): number;
1180
1444
  getRateLimitStatus(): RateLimitStatus;
1181
1445
  onApproachingRateLimit(callback: ApproachingLimitCallback, threshold?: number): void;
@@ -1815,4 +2079,4 @@ declare function getLibraryInfo(): {
1815
2079
  };
1816
2080
 
1817
2081
  export { AuthHelper, BatchQueryExecutor, BulkOperationManager, COMMON_SCOPE_COMBINATIONS, CacheWithInvalidation, CreateListingSchema, DEFAULT_RETRY_CONFIG, ETSY_SCOPES, EncryptedFileTokenStorage, EtsyApiError, EtsyAuthError, EtsyClient, EtsyRateLimitError, EtsyRateLimiter, EtsyWebhookHandler, FieldValidator, FileTokenStorage, GlobalRequestQueue, LFUCache, LIBRARY_NAME, LRUCache, ListingQueryBuilder, LocalStorageTokenStorage, MemoryTokenStorage, PaginatedResults, PluginManager, ReceiptQueryBuilder, RedisCacheStorage, RetryManager, SecureTokenStorage, SessionStorageTokenStorage, TokenManager, UpdateListingSchema, UpdateShopSchema, VERSION, ValidationException, Validator, WebhookSecurity, combineValidators, createAnalyticsPlugin, createAuthHelper, createBatchQuery, createBulkOperationManager, createCacheStorage, createCacheWithInvalidation, createCachingPlugin, createCodeChallenge, createDefaultTokenStorage, createEtsyClient, createListingQuery, createLoggingPlugin, createPaginatedResults, createRateLimitPlugin, createRateLimiter, createReceiptQuery, createRedisCacheStorage, createRetryPlugin, createTokenManager, createValidator, createWebhookHandler, createWebhookSecurity, decryptAES256GCM, EtsyClient as default, defaultRateLimiter, deriveKeyFromPassword, encryptAES256GCM, executeBulkOperation, field, generateCodeVerifier, generateEncryptionKey, generateRandomBase64Url, generateState, getAvailableStorage, getEnvironmentInfo, getGlobalQueue, getLibraryInfo, hasLocalStorage, hasSessionStorage, isBrowser, isNode, isSecureStorageSupported, sha256, sha256Base64Url, validate, validateEncryptionKey, validateOrThrow, withQueryBuilder, withQueue, withRetry };
1818
- export type { AdvancedCachingConfig, AnalyticsPluginConfig, ApproachingLimitCallback, AuthHelperConfig, BulkImageUploadOperation, BulkOperationConfig, BulkOperationError, BulkOperationResult, BulkOperationSummary, BulkUpdateListingOperation, CacheEntry, CacheStats, CacheStorage, CacheStrategy, CachingPluginConfig, CreateDraftListingParams, CreateReceiptShipmentParams, CreateShippingProfileDestinationParams, CreateShippingProfileParams, CreateShopSectionParams, EncryptedData, EncryptedStorageConfig, EtsyApiResponse, EtsyBuyerTaxonomyNode, EtsyBuyerTaxonomyProperty, EtsyBuyerTaxonomyPropertyScale, EtsyBuyerTaxonomyPropertyValue, EtsyClientConfig, EtsyClientWithQueryBuilder, EtsyErrorDetails, EtsyListing, EtsyListingImage, EtsyListingInventory, EtsyListingOffering, EtsyListingProduct, EtsyListingProperty, EtsyListingPropertyScale, EtsyListingPropertyValue, EtsyPagination, EtsyPayment, EtsyPaymentAccountLedgerEntry, EtsyPaymentAdjustment, EtsyPlugin, EtsyRateLimitHeaders, EtsyReview, EtsySellerTaxonomyNode, EtsyShippingProfile, EtsyShippingProfileDestination, EtsyShippingProfileUpgrade, EtsyShop, EtsyShopProductionPartner, EtsyShopReceipt, EtsyShopReceiptShipment, EtsyShopReceiptTransaction, EtsyShopRefund, EtsyShopSection, EtsyTokenResponse, EtsyTokens, EtsyTransactionVariation, EtsyUser, EtsyWebhookEvent, EtsyWebhookEventType, GetPaymentAccountLedgerEntriesParams, GetReviewsParams, GetShopReceiptsParams, ListingParams, ListingSortOn, ListingState, LoggerInterface, LoggingPluginConfig, PageFetcher, PaginationOptions, PluginRequestConfig, PluginResponse, QueueOptions, RateLimitConfig, RateLimitErrorType, RateLimitPluginConfig, RateLimitStatus, RedisClientLike, RedisConfig, RequestPriority, RetryConfig, RetryOptions, RetryPluginConfig, SearchParams, SecureTokenStorageConfig, SortOrder, TokenRefreshCallback, TokenRotationCallback, TokenRotationConfig, TokenStorage, UpdateListingInventoryParams, UpdateListingParams, UpdateListingPropertyParams, UpdateShippingProfileDestinationParams, UpdateShippingProfileParams, UpdateShopParams, UpdateShopReceiptParams, UpdateShopSectionParams, UploadListingFileParams, UploadListingImageParams, ValidationError, ValidationOptions, ValidationResult, ValidationSchema, ValidatorFunction, WebhookConfig, WebhookEventHandler, WebhookSecurityConfig };
2082
+ export type { AdvancedCachingConfig, AnalyticsPluginConfig, ApproachingLimitCallback, AuthHelperConfig, BulkImageUploadOperation, BulkOperationConfig, BulkOperationError, BulkOperationResult, BulkOperationSummary, BulkUpdateListingOperation, CacheEntry, CacheStats, CacheStorage, CacheStrategy, CachingPluginConfig, ConsolidateReturnPoliciesParams, CreateDraftListingParams, CreateListingTranslationParams, CreateReadinessStateParams, CreateReceiptShipmentParams, CreateReturnPolicyParams, CreateShippingProfileDestinationParams, CreateShippingProfileParams, CreateShippingProfileUpgradeParams, CreateShopSectionParams, EncryptedData, EncryptedStorageConfig, EtsyApiResponse, EtsyBuyerTaxonomyNode, EtsyBuyerTaxonomyProperty, EtsyBuyerTaxonomyPropertyScale, EtsyBuyerTaxonomyPropertyValue, EtsyClientConfig, EtsyClientWithQueryBuilder, EtsyErrorDetails, EtsyListing, EtsyListingFile, EtsyListingImage, EtsyListingInventory, EtsyListingOffering, EtsyListingProduct, EtsyListingProperty, EtsyListingPropertyScale, EtsyListingPropertyValue, EtsyListingTranslation, EtsyListingVariationImage, EtsyListingVideo, EtsyPagination, EtsyPayment, EtsyPaymentAccountLedgerEntry, EtsyPaymentAdjustment, EtsyPlugin, EtsyRateLimitHeaders, EtsyReview, EtsySellerTaxonomyNode, EtsyShippingCarrier, EtsyShippingCarrierMailClass, EtsyShippingProfile, EtsyShippingProfileDestination, EtsyShippingProfileUpgrade, EtsyShop, EtsyShopHolidayPreference, EtsyShopProcessingProfile, EtsyShopProductionPartner, EtsyShopReceipt, EtsyShopReceiptShipment, EtsyShopReceiptTransaction, EtsyShopRefund, EtsyShopReturnPolicy, EtsyShopSection, EtsyTokenResponse, EtsyTokens, EtsyTransactionVariation, EtsyUser, EtsyUserAddress, EtsyWebhookEvent, EtsyWebhookEventType, FindActiveListingsByShopParams, FindShopsParams, GetFeaturedListingsParams, GetLedgerEntryPaymentsParams, GetListingsByIdsParams, GetListingsByReturnPolicyParams, GetListingsBySectionParams, GetListingsByShopReceiptParams, GetPaymentAccountLedgerEntriesParams, GetReadinessStateParams, GetReviewsParams, GetShopReceiptsParams, GetTransactionsByListingParams, GetTransactionsByShopParams, ListingParams, ListingSortOn, ListingState, LoggerInterface, LoggingPluginConfig, PageFetcher, PaginationOptions, PluginRequestConfig, PluginResponse, QueueOptions, RateLimitConfig, RateLimitErrorType, RateLimitPluginConfig, RateLimitStatus, RedisClientLike, RedisConfig, RequestPriority, RetryConfig, RetryOptions, RetryPluginConfig, SearchParams, SecureTokenStorageConfig, SortOrder, TokenRefreshCallback, TokenRotationCallback, TokenRotationConfig, TokenScopesParams, TokenScopesResponse, TokenStorage, UpdateHolidayPreferencesParams, UpdateListingInventoryParams, UpdateListingParams, UpdateListingPropertyParams, UpdateListingTranslationParams, UpdateReadinessStateParams, UpdateReturnPolicyParams, UpdateShippingProfileDestinationParams, UpdateShippingProfileParams, UpdateShippingProfileUpgradeParams, UpdateShopParams, UpdateShopReceiptParams, UpdateShopSectionParams, UpdateVariationImagesParams, UploadListingFileParams, UploadListingImageParams, ValidationError, ValidationOptions, ValidationResult, ValidationSchema, ValidatorFunction, WebhookConfig, WebhookEventHandler, WebhookSecurityConfig };
package/dist/index.esm.js CHANGED
@@ -1975,6 +1975,376 @@ class EtsyClient {
1975
1975
  const response = await this.makeRequest(`/shops/${shopId}/production-partners`);
1976
1976
  return response.results;
1977
1977
  }
1978
+ async createShopReadinessStateDefinition(shopId, params) {
1979
+ const body = this.buildFormBody(params);
1980
+ return this.makeRequest(`/shops/${shopId}/readiness-state-definitions`, {
1981
+ method: 'POST',
1982
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
1983
+ body: body.toString()
1984
+ }, false);
1985
+ }
1986
+ async getShopReadinessStateDefinitions(shopId, params = {}) {
1987
+ const searchParams = new URLSearchParams();
1988
+ if (params.limit !== undefined)
1989
+ searchParams.set('limit', params.limit.toString());
1990
+ if (params.offset !== undefined)
1991
+ searchParams.set('offset', params.offset.toString());
1992
+ const query = searchParams.toString();
1993
+ const suffix = query ? `?${query}` : '';
1994
+ const response = await this.makeRequest(`/shops/${shopId}/readiness-state-definitions${suffix}`);
1995
+ return response.results;
1996
+ }
1997
+ async getShopReadinessStateDefinition(shopId, definitionId) {
1998
+ return this.makeRequest(`/shops/${shopId}/readiness-state-definitions/${definitionId}`);
1999
+ }
2000
+ async updateShopReadinessStateDefinition(shopId, definitionId, params) {
2001
+ const body = this.buildFormBody(params);
2002
+ return this.makeRequest(`/shops/${shopId}/readiness-state-definitions/${definitionId}`, {
2003
+ method: 'PUT',
2004
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2005
+ body: body.toString()
2006
+ }, false);
2007
+ }
2008
+ async deleteShopReadinessStateDefinition(shopId, definitionId) {
2009
+ await this.makeRequest(`/shops/${shopId}/readiness-state-definitions/${definitionId}`, { method: 'DELETE' }, false);
2010
+ }
2011
+ async createShopReturnPolicy(shopId, params) {
2012
+ const body = this.buildFormBody(params);
2013
+ return this.makeRequest(`/shops/${shopId}/policies/return`, {
2014
+ method: 'POST',
2015
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2016
+ body: body.toString()
2017
+ }, false);
2018
+ }
2019
+ async getShopReturnPolicies(shopId) {
2020
+ const response = await this.makeRequest(`/shops/${shopId}/policies/return`);
2021
+ return response.results;
2022
+ }
2023
+ async getShopReturnPolicy(shopId, returnPolicyId) {
2024
+ return this.makeRequest(`/shops/${shopId}/policies/return/${returnPolicyId}`);
2025
+ }
2026
+ async updateShopReturnPolicy(shopId, returnPolicyId, params) {
2027
+ const body = this.buildFormBody(params);
2028
+ return this.makeRequest(`/shops/${shopId}/policies/return/${returnPolicyId}`, {
2029
+ method: 'PUT',
2030
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2031
+ body: body.toString()
2032
+ }, false);
2033
+ }
2034
+ async deleteShopReturnPolicy(shopId, returnPolicyId) {
2035
+ await this.makeRequest(`/shops/${shopId}/policies/return/${returnPolicyId}`, { method: 'DELETE' }, false);
2036
+ }
2037
+ async consolidateShopReturnPolicies(shopId, params) {
2038
+ const body = this.buildFormBody(params);
2039
+ return this.makeRequest(`/shops/${shopId}/policies/return/consolidate`, {
2040
+ method: 'POST',
2041
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2042
+ body: body.toString()
2043
+ }, false);
2044
+ }
2045
+ async getHolidayPreferences(shopId) {
2046
+ const response = await this.makeRequest(`/shops/${shopId}/holiday-preferences`);
2047
+ return response.results;
2048
+ }
2049
+ async updateHolidayPreferences(shopId, holidayId, params) {
2050
+ const body = this.buildFormBody(params);
2051
+ return this.makeRequest(`/shops/${shopId}/holiday-preferences/${holidayId}`, {
2052
+ method: 'PUT',
2053
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2054
+ body: body.toString()
2055
+ }, false);
2056
+ }
2057
+ async uploadListingFile(shopId, listingId, fileData, params) {
2058
+ const formData = new FormData();
2059
+ formData.append('file', fileData);
2060
+ if (params?.name)
2061
+ formData.append('name', params.name);
2062
+ if (params?.rank !== undefined)
2063
+ formData.append('rank', params.rank.toString());
2064
+ if (params?.listing_file_id !== undefined)
2065
+ formData.append('listing_file_id', params.listing_file_id.toString());
2066
+ const url = `${this.baseUrl}/shops/${shopId}/listings/${listingId}/files`;
2067
+ await this.rateLimiter.waitForRateLimit();
2068
+ const accessToken = await this.tokenManager.getAccessToken();
2069
+ const response = await this.fetch(url, {
2070
+ method: 'POST',
2071
+ headers: {
2072
+ 'Authorization': `Bearer ${accessToken}`,
2073
+ 'x-api-key': this.getApiKey(),
2074
+ },
2075
+ body: formData
2076
+ });
2077
+ if (!response.ok) {
2078
+ const errorText = await response.text();
2079
+ throw new EtsyApiError(`Failed to upload file: ${response.status} ${response.statusText}`, response.status, errorText);
2080
+ }
2081
+ return response.json();
2082
+ }
2083
+ async getAllListingFiles(shopId, listingId) {
2084
+ const response = await this.makeRequest(`/shops/${shopId}/listings/${listingId}/files`);
2085
+ return response.results;
2086
+ }
2087
+ async getListingFile(shopId, listingId, fileId) {
2088
+ return this.makeRequest(`/shops/${shopId}/listings/${listingId}/files/${fileId}`);
2089
+ }
2090
+ async deleteListingFile(shopId, listingId, fileId) {
2091
+ await this.makeRequest(`/shops/${shopId}/listings/${listingId}/files/${fileId}`, { method: 'DELETE' }, false);
2092
+ }
2093
+ async uploadListingVideo(shopId, listingId, videoData, params) {
2094
+ const formData = new FormData();
2095
+ formData.append('video', videoData);
2096
+ if (params?.name)
2097
+ formData.append('name', params.name);
2098
+ if (params?.video_id !== undefined)
2099
+ formData.append('video_id', params.video_id.toString());
2100
+ const url = `${this.baseUrl}/shops/${shopId}/listings/${listingId}/videos`;
2101
+ await this.rateLimiter.waitForRateLimit();
2102
+ const accessToken = await this.tokenManager.getAccessToken();
2103
+ const response = await this.fetch(url, {
2104
+ method: 'POST',
2105
+ headers: {
2106
+ 'Authorization': `Bearer ${accessToken}`,
2107
+ 'x-api-key': this.getApiKey(),
2108
+ },
2109
+ body: formData
2110
+ });
2111
+ if (!response.ok) {
2112
+ const errorText = await response.text();
2113
+ throw new EtsyApiError(`Failed to upload video: ${response.status} ${response.statusText}`, response.status, errorText);
2114
+ }
2115
+ return response.json();
2116
+ }
2117
+ async getListingVideos(listingId) {
2118
+ const response = await this.makeRequest(`/listings/${listingId}/videos`);
2119
+ return response.results;
2120
+ }
2121
+ async getListingVideo(listingId, videoId) {
2122
+ return this.makeRequest(`/listings/${listingId}/videos/${videoId}`);
2123
+ }
2124
+ async deleteListingVideo(shopId, listingId, videoId) {
2125
+ await this.makeRequest(`/shops/${shopId}/listings/${listingId}/videos/${videoId}`, { method: 'DELETE' }, false);
2126
+ }
2127
+ async createListingTranslation(shopId, listingId, language, params) {
2128
+ const body = this.buildFormBody(params);
2129
+ return this.makeRequest(`/shops/${shopId}/listings/${listingId}/translations/${language}`, {
2130
+ method: 'POST',
2131
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2132
+ body: body.toString()
2133
+ }, false);
2134
+ }
2135
+ async getListingTranslation(shopId, listingId, language) {
2136
+ return this.makeRequest(`/shops/${shopId}/listings/${listingId}/translations/${language}`);
2137
+ }
2138
+ async updateListingTranslation(shopId, listingId, language, params) {
2139
+ const body = this.buildFormBody(params);
2140
+ return this.makeRequest(`/shops/${shopId}/listings/${listingId}/translations/${language}`, {
2141
+ method: 'PUT',
2142
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2143
+ body: body.toString()
2144
+ }, false);
2145
+ }
2146
+ async getListingVariationImages(shopId, listingId) {
2147
+ const response = await this.makeRequest(`/shops/${shopId}/listings/${listingId}/variation-images`);
2148
+ return response.results;
2149
+ }
2150
+ async updateVariationImages(shopId, listingId, params) {
2151
+ const response = await this.makeRequest(`/shops/${shopId}/listings/${listingId}/variation-images`, {
2152
+ method: 'POST',
2153
+ body: JSON.stringify(params)
2154
+ }, false);
2155
+ return response.results;
2156
+ }
2157
+ async findAllActiveListingsByShop(shopId, params = {}) {
2158
+ const searchParams = new URLSearchParams();
2159
+ if (params.limit !== undefined)
2160
+ searchParams.set('limit', params.limit.toString());
2161
+ if (params.offset !== undefined)
2162
+ searchParams.set('offset', params.offset.toString());
2163
+ if (params.sort_on)
2164
+ searchParams.set('sort_on', params.sort_on);
2165
+ if (params.sort_order)
2166
+ searchParams.set('sort_order', params.sort_order);
2167
+ if (params.keywords)
2168
+ searchParams.set('keywords', params.keywords);
2169
+ if (params.legacy !== undefined)
2170
+ searchParams.set('legacy', params.legacy.toString());
2171
+ const query = searchParams.toString();
2172
+ const suffix = query ? `?${query}` : '';
2173
+ const response = await this.makeRequest(`/shops/${shopId}/listings/active${suffix}`);
2174
+ return response.results;
2175
+ }
2176
+ async getFeaturedListingsByShop(shopId, params = {}) {
2177
+ const searchParams = new URLSearchParams();
2178
+ if (params.limit !== undefined)
2179
+ searchParams.set('limit', params.limit.toString());
2180
+ if (params.offset !== undefined)
2181
+ searchParams.set('offset', params.offset.toString());
2182
+ if (params.legacy !== undefined)
2183
+ searchParams.set('legacy', params.legacy.toString());
2184
+ const query = searchParams.toString();
2185
+ const suffix = query ? `?${query}` : '';
2186
+ const response = await this.makeRequest(`/shops/${shopId}/listings/featured${suffix}`);
2187
+ return response.results;
2188
+ }
2189
+ async getListingsByListingIds(params) {
2190
+ const searchParams = new URLSearchParams();
2191
+ searchParams.set('listing_ids', params.listing_ids.join(','));
2192
+ if (params.includes)
2193
+ searchParams.set('includes', params.includes.join(','));
2194
+ if (params.legacy !== undefined)
2195
+ searchParams.set('legacy', params.legacy.toString());
2196
+ const response = await this.makeRequest(`/listings/batch?${searchParams.toString()}`);
2197
+ return response.results;
2198
+ }
2199
+ async getListingsByShopReceipt(shopId, receiptId, params = {}) {
2200
+ const searchParams = new URLSearchParams();
2201
+ if (params.limit !== undefined)
2202
+ searchParams.set('limit', params.limit.toString());
2203
+ if (params.offset !== undefined)
2204
+ searchParams.set('offset', params.offset.toString());
2205
+ if (params.legacy !== undefined)
2206
+ searchParams.set('legacy', params.legacy.toString());
2207
+ const query = searchParams.toString();
2208
+ const suffix = query ? `?${query}` : '';
2209
+ const response = await this.makeRequest(`/shops/${shopId}/receipts/${receiptId}/listings${suffix}`);
2210
+ return response.results;
2211
+ }
2212
+ async getListingProperty(listingId, propertyId) {
2213
+ return this.makeRequest(`/listings/${listingId}/properties/${propertyId}`);
2214
+ }
2215
+ async deleteListingProperty(shopId, listingId, propertyId) {
2216
+ await this.makeRequest(`/shops/${shopId}/listings/${listingId}/properties/${propertyId}`, { method: 'DELETE' }, false);
2217
+ }
2218
+ async getListingProduct(listingId, productId) {
2219
+ return this.makeRequest(`/listings/${listingId}/inventory/products/${productId}`);
2220
+ }
2221
+ async getListingOffering(listingId, productId, offeringId) {
2222
+ return this.makeRequest(`/listings/${listingId}/products/${productId}/offerings/${offeringId}`);
2223
+ }
2224
+ async getListingsByShopSectionId(shopId, params) {
2225
+ const searchParams = new URLSearchParams();
2226
+ searchParams.set('shop_section_ids', params.shop_section_ids.join(','));
2227
+ if (params.limit !== undefined)
2228
+ searchParams.set('limit', params.limit.toString());
2229
+ if (params.offset !== undefined)
2230
+ searchParams.set('offset', params.offset.toString());
2231
+ if (params.sort_on)
2232
+ searchParams.set('sort_on', params.sort_on);
2233
+ if (params.sort_order)
2234
+ searchParams.set('sort_order', params.sort_order);
2235
+ if (params.legacy !== undefined)
2236
+ searchParams.set('legacy', params.legacy.toString());
2237
+ const response = await this.makeRequest(`/shops/${shopId}/shop-sections/listings?${searchParams.toString()}`);
2238
+ return response.results;
2239
+ }
2240
+ async getListingsByShopReturnPolicy(shopId, returnPolicyId, params = {}) {
2241
+ const searchParams = new URLSearchParams();
2242
+ if (params.legacy !== undefined)
2243
+ searchParams.set('legacy', params.legacy.toString());
2244
+ const query = searchParams.toString();
2245
+ const suffix = query ? `?${query}` : '';
2246
+ const response = await this.makeRequest(`/shops/${shopId}/policies/return/${returnPolicyId}/listings${suffix}`);
2247
+ return response.results;
2248
+ }
2249
+ async findShops(params) {
2250
+ const searchParams = new URLSearchParams();
2251
+ searchParams.set('shop_name', params.shop_name);
2252
+ if (params.limit !== undefined)
2253
+ searchParams.set('limit', params.limit.toString());
2254
+ if (params.offset !== undefined)
2255
+ searchParams.set('offset', params.offset.toString());
2256
+ const response = await this.makeRequest(`/shops?${searchParams.toString()}`);
2257
+ return response.results;
2258
+ }
2259
+ async createShopShippingProfileUpgrade(shopId, profileId, params) {
2260
+ const body = this.buildFormBody(params);
2261
+ return this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}/upgrades`, {
2262
+ method: 'POST',
2263
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2264
+ body: body.toString()
2265
+ }, false);
2266
+ }
2267
+ async updateShopShippingProfileUpgrade(shopId, profileId, upgradeId, params) {
2268
+ const body = this.buildFormBody(params);
2269
+ return this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}/upgrades/${upgradeId}`, {
2270
+ method: 'PUT',
2271
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2272
+ body: body.toString()
2273
+ }, false);
2274
+ }
2275
+ async deleteShopShippingProfileUpgrade(shopId, profileId, upgradeId) {
2276
+ await this.makeRequest(`/shops/${shopId}/shipping-profiles/${profileId}/upgrades/${upgradeId}`, { method: 'DELETE' }, false);
2277
+ }
2278
+ async getShippingCarriers(originCountryIso) {
2279
+ const searchParams = new URLSearchParams();
2280
+ searchParams.set('origin_country_iso', originCountryIso);
2281
+ const response = await this.makeRequest(`/shipping-carriers?${searchParams.toString()}`);
2282
+ return response.results;
2283
+ }
2284
+ async getShopReceiptTransactionsByListing(shopId, listingId, params = {}) {
2285
+ const searchParams = new URLSearchParams();
2286
+ if (params.limit !== undefined)
2287
+ searchParams.set('limit', params.limit.toString());
2288
+ if (params.offset !== undefined)
2289
+ searchParams.set('offset', params.offset.toString());
2290
+ if (params.legacy !== undefined)
2291
+ searchParams.set('legacy', params.legacy.toString());
2292
+ const query = searchParams.toString();
2293
+ const suffix = query ? `?${query}` : '';
2294
+ const response = await this.makeRequest(`/shops/${shopId}/listings/${listingId}/transactions${suffix}`);
2295
+ return response.results;
2296
+ }
2297
+ async getShopReceiptTransactionsByShop(shopId, params = {}) {
2298
+ const searchParams = new URLSearchParams();
2299
+ if (params.limit !== undefined)
2300
+ searchParams.set('limit', params.limit.toString());
2301
+ if (params.offset !== undefined)
2302
+ searchParams.set('offset', params.offset.toString());
2303
+ if (params.legacy !== undefined)
2304
+ searchParams.set('legacy', params.legacy.toString());
2305
+ const query = searchParams.toString();
2306
+ const suffix = query ? `?${query}` : '';
2307
+ const response = await this.makeRequest(`/shops/${shopId}/transactions${suffix}`);
2308
+ return response.results;
2309
+ }
2310
+ async getPaymentAccountLedgerEntryPayments(shopId, params) {
2311
+ const searchParams = new URLSearchParams();
2312
+ searchParams.set('ledger_entry_ids', params.ledger_entry_ids.join(','));
2313
+ const response = await this.makeRequest(`/shops/${shopId}/payment-account/ledger-entries/payments?${searchParams.toString()}`);
2314
+ return response.results;
2315
+ }
2316
+ async getShopPaymentByReceiptId(shopId, receiptId) {
2317
+ const response = await this.makeRequest(`/shops/${shopId}/receipts/${receiptId}/payments`);
2318
+ return response.results;
2319
+ }
2320
+ async getMe() {
2321
+ return this.makeRequest('/users/me');
2322
+ }
2323
+ async getUserAddresses() {
2324
+ const response = await this.makeRequest('/user/addresses');
2325
+ return response.results;
2326
+ }
2327
+ async getUserAddress(userAddressId) {
2328
+ return this.makeRequest(`/user/addresses/${userAddressId}`);
2329
+ }
2330
+ async deleteUserAddress(userAddressId) {
2331
+ await this.makeRequest(`/user/addresses/${userAddressId}`, { method: 'DELETE' }, false);
2332
+ }
2333
+ async getPropertiesByBuyerTaxonomyId(taxonomyId) {
2334
+ const response = await this.makeRequest(`/buyer-taxonomy/nodes/${taxonomyId}/properties`);
2335
+ return response.results;
2336
+ }
2337
+ async ping() {
2338
+ return this.makeRequest('/openapi-ping', {}, false);
2339
+ }
2340
+ async tokenScopes(params) {
2341
+ const body = this.buildFormBody(params);
2342
+ return this.makeRequest('/scopes', {
2343
+ method: 'POST',
2344
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
2345
+ body: body.toString()
2346
+ }, false);
2347
+ }
1978
2348
  getRemainingRequests() {
1979
2349
  return this.rateLimiter.getRemainingRequests();
1980
2350
  }