Skip to content

feat(arcgis-rest-portal): add removeItemThumbnail() #1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/arcgis-rest-portal/src/items/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,31 @@ export function removeFolder(requestOptions: IFolderIdOptions): Promise<{
return request(url, requestOptions);
});
}

/**
* Delete an item's thumbnail. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/delete-item-thumbnail.htm) for more information.
*
* ```js
* import { removeItemThumbnail } from "@esri/arcgis-rest-portal";
*
* removeItemThumbnail({
* id: "3ef",
* owner: "c@sey",
* authentication
* })
* .then(response)
* ```
*
* @param requestOptions - Options for the request
* @returns A Promise that deletes a thumbnail.
*/
export function removeItemThumbnail(
requestOptions: IUserItemOptions
): Promise<{ success: boolean }> {
return determineOwner(requestOptions).then((owner) => {
const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
requestOptions.id
}/deleteThumbnail`;
return request(url, requestOptions);
});
}
26 changes: 25 additions & 1 deletion packages/arcgis-rest-portal/test/items/remove.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
removeFolder,
removeItem,
removeItemResource,
removeItemRelationship
removeItemRelationship,
removeItemThumbnail
} from "../../src/items/remove.js";

import { ItemSuccessResponse } from "../mocks/items/item.js";
Expand Down Expand Up @@ -255,5 +256,28 @@ describe("search", () => {
fail(e);
});
});

it("should delete an item's thumbnail successfully", (done) => {
fetchMock.once("*", { success: true });

removeItemThumbnail({
id: "3ef",
owner: "dbouwman",
...MOCK_USER_REQOPTS
})
.then((response) => {
const [url, options] = fetchMock.lastCall("*");
expect(url).toEqual(
"https://myorg.maps.arcgis.com/sharing/rest/content/users/dbouwman/items/3ef/deleteThumbnail"
);
expect(options.method).toBe("POST");
expect(options.body).toContain(encodeParam("f", "json"));
expect(options.body).toContain(encodeParam("token", "fake-token"));
done();
})
.catch((e) => {
fail(e);
});
});
}); // auth requests
});