diff --git a/src/core/gateway/deleteSwap.ts b/src/core/files/deleteSwap.ts similarity index 96% rename from src/core/gateway/deleteSwap.ts rename to src/core/files/deleteSwap.ts index 3f22bd8..7b98a47 100644 --- a/src/core/gateway/deleteSwap.ts +++ b/src/core/files/deleteSwap.ts @@ -55,14 +55,14 @@ export const deleteSwap = async ( }; } - let endpoint: string = "https://api.pinata.cloud"; + let endpoint: string = "https://api.pinata.cloud/v3"; if (config.endpointUrl) { endpoint = config.endpointUrl; } try { - const request = await fetch(`${endpoint}/v3/ipfs/swap/${cid}`, { + const request = await fetch(`${endpoint}/files/swap/${cid}`, { method: "DELETE", headers: headers, }); diff --git a/src/core/gateway/swapCid.ts b/src/core/files/swapCid.ts similarity index 95% rename from src/core/gateway/swapCid.ts rename to src/core/files/swapCid.ts index f181523..ebf7c81 100644 --- a/src/core/gateway/swapCid.ts +++ b/src/core/files/swapCid.ts @@ -49,7 +49,7 @@ export const swapCid = async ( } const data = JSON.stringify({ - swapCid: options.swapCid, + swap_cid: options.swapCid, }); let headers: Record; @@ -64,14 +64,14 @@ export const swapCid = async ( }; } - let endpoint: string = "https://api.pinata.cloud"; + let endpoint: string = "https://api.pinata.cloud/v3"; if (config.endpointUrl) { endpoint = config.endpointUrl; } try { - const request = await fetch(`${endpoint}/v3/ipfs/swap/${options.cid}`, { + const request = await fetch(`${endpoint}/files/swap/${options.cid}`, { method: "PUT", headers: headers, body: data, diff --git a/src/core/gateway/swapHistory.ts b/src/core/files/swapHistory.ts similarity index 96% rename from src/core/gateway/swapHistory.ts rename to src/core/files/swapHistory.ts index 0c0950d..91822e5 100644 --- a/src/core/gateway/swapHistory.ts +++ b/src/core/files/swapHistory.ts @@ -64,7 +64,7 @@ export const swapHistory = async ( }; } - let endpoint: string = "https://api.pinata.cloud"; + let endpoint: string = "https://api.pinata.cloud/v3"; if (config.endpointUrl) { endpoint = config.endpointUrl; @@ -72,7 +72,7 @@ export const swapHistory = async ( try { const request = await fetch( - `${endpoint}/v3/ipfs/swap/${options.cid}?domain=${options.domain}`, + `${endpoint}/files/swap/${options.cid}?domain=${options.domain}`, { method: "GET", headers: headers, diff --git a/src/core/pinataSDK.ts b/src/core/pinataSDK.ts index f20465d..bdc4f12 100644 --- a/src/core/pinataSDK.ts +++ b/src/core/pinataSDK.ts @@ -65,9 +65,9 @@ import { deleteGroup } from "./groups/deleteGroup"; // import { removeSignature } from "./signatures/removeSignature"; import { analyticsTopUsage } from "./gateway/analyticsTopUsage"; import { analyticsDateInterval } from "./gateway/analyticsDateInterval"; -import { swapCid } from "./gateway/swapCid"; -import { swapHistory } from "./gateway/swapHistory"; -import { deleteSwap } from "./gateway/deleteSwap"; +import { swapCid } from "./files/swapCid"; +import { swapHistory } from "./files/swapHistory"; +import { deleteSwap } from "./files/deleteSwap"; import { containsCID } from "../utils/gateway-tools"; import { createSignedURL } from "./gateway/createSignedURL"; @@ -146,6 +146,18 @@ class Files { update(options: UpdateFileOptions): Promise { return updateFile(this.config, options); } + + addSwap(options: SwapCidOptions): Promise { + return swapCid(this.config, options); + } + + getSwapHistory(options: SwapHistoryOptions): Promise { + return swapHistory(this.config, options); + } + + deleteSwap(cid: string): Promise { + return deleteSwap(this.config, cid); + } } class UploadBuilder { @@ -383,18 +395,6 @@ class Gateways { return new OptimizeImageCreateSignedURL(this.config, options); } - // get(cid: string): OptimizeImage { - // return new OptimizeImage(this.config, cid); - // } - - // convert(url: string, gatewayPrefix?: string): Promise { - // return convertIPFSUrl(this.config, url, gatewayPrefix); - // } - - // containsCID(cid: string): Promise { - // return containsCID(cid); - // } - // topUsageAnalytics(options: { // domain: string; // start: string; @@ -432,18 +432,6 @@ class Gateways { // options.interval, // ); // } - - // swapCid(options: SwapCidOptions): Promise { - // return swapCid(this.config, options); - // } - - // swapHistory(options: SwapHistoryOptions): Promise { - // return swapHistory(this.config, options); - // } - - // deleteSwap(cid: string): Promise { - // return deleteSwap(this.config, cid); - // } } class OptimizeImageGetCid { diff --git a/src/core/types.ts b/src/core/types.ts index 73e234b..e9b31ef 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -358,8 +358,8 @@ export type SwapHistoryOptions = { }; export type SwapCidResponse = { - mappedCid: string; - createdAt: string; + mapped_cid: string; + created_at: string; }; export type ContainsCIDResponse = {