Utils methods

Utils methods

Utils are available for you to avoid direct access to our rest API and an integrated usage directly from the SharinPix package in Apex from Salesforce.

Methods

Utils Method Example

renameAlbum

global Boolean renameAlbum(String oldAlbumId, String newAlbumId)

  • Renames an album.

renameAlbum

global Boolean renameAlbum(String oldAlbumId, String newAlbumId, Boolean mergeAlbum)

  • Renames an album. The mergeAlbum parameter is used to specify whether to merge the old and new albums or not.

Image below shows the albums before using the renameAlbum method.

After using the method renameAlbum with mergeAlbum parameter 'true', all the images from the old Album have been merged in the new Album as shown below.

duplicateAlbum

duplicateAlbum with no Tags or Tags equals to false

global String duplicateAlbum(String sourceAlbumId, String destinationAlbumId)

  • Copies all images from a source album to a destination album.

The code below shows the code without tags.

Image below shows the source record where the album an image with the tag "object".

The image below shows the destination record where the image from the source record has been populated without the tags because in the code snippet we have not mentioned if "Tags" is true or false.

DuplicateAlbum with Tags True

global String duplicateAlbum(String sourceAlbumId, String destinationAlbumId, Boolean includeTags)

  • Copies all images from a source album to a destination album. This method also allows the duplication of tags along with the images.

The image below shows the code where tags is true.

Image below shows the source record where the album an image with the tag "object".

The image below shows the destination record where the image from the source record has been populated and has been assign the tag "object" when the code snippet was executed.

duplicateAlbum with Einstein Boxes (DEPRECATED)

triangle-exclamation

global String duplicateAlbum(String sourceAlbumId, String destinationAlbumId, Map<String,Object> params)

  • Copies all images from a source album to a destination album if einstein_boxes equals to true. This method also allows the duplication of labels along with the images.

circle-check

getAlbumImages

global List<Object> getAlbumImages(String albumId)

  • Gets all images from an album.

Below code shows how to get the details from an image (e.g: brightness, color, contrast, created_at,...)

getImageDetails

global Map<String, Object> getImageDetails(String imageId)

  • Gets image details.

duplicateImageToAlbum

global string duplicateImageToAlbum(string imageId, string albumId, map<string, object> options)

  • Duplicates an image to a specified album. The options parameter can be used to enable tag and image sync while duplicating the image. An example on how to call this method has been given at the end of this article.

duplicateImages

duplicateImages with no Tags or Tags equals to false

global List<Object> duplicateImages(List<String> imageIds, String destinationAlbumId)

  • Duplicates one or more images to another album.

duplicateImages with Tags True

global List<Object> duplicateImages(List<String> imageIds, String destinationAlbumId, Map<String, Object> options)

  • Duplicates one or more images to another album. This method also allows the duplication of tags along with the images.

circle-check

getImageUrl

global String getImageUrl(String imageId, Map<String, Object> sharinpix, List<Object> transformations)

  • Gets the URL of a transformed image.

  • Get the original url of an image (This url is a direct expiring url to the storage)

getImageEndpoint

global String getImageEndpoint (String imageId, Map<String, Object> sharinpix, List<Object> transformations)

  • Get endpoint of transformed image

croppedImageUrl

global String croppedImageUrl(String imageId, String cropStyle, Integer width, Integer height)

  • Crops or resizes images.

getImageExternalUrl

global Map<String, Object> getImageExternalUrl(Map<String, Object> imageTransformation)

  • Applies transformations on an image and get an external URL.

getImageExternalUrls

global List<Object> getImageExternalUrls(List<Map<String, Object>> imageTransformations)

  • Applies transformations on images and get external images URLs.

getOrgTags

global List<Object> getOrgTags()

  • Retrieves all tags present in your Organization.

getAlbumTagImages

global List<Object> getAlbumTagImages(String albumId)

  • Retrieves the list of images having tags from an album.

getAlbumTagImages

global List<Object> getAlbumTagImages(String albumId, String tagName)

  • Retrieves all tagged images having a specific tag name from an album.

getTagsOnImage

global List<Object> getTagsOnImage(String imageId)

  • Retrieves all tags applied to an image.

getTagNamesOnImage

global List<String> getTagNamesOnImage(String imageId)

  • Retrieves all tag names available on an image.

addTag

global Object addTag(String imageId, String tagName)

  • Adds a tag on an image.

removeTags

global Boolean (String imageId, String[] tags)

  • Removes tags from a tagged image.

clearTags

global Boolean clearTags(String imageId)

  • Clears all tags applied to an image.

uploadAttachment

global Object uploadAttachment(Id attachmentId, String albumId)

  • Uploads Salesforce attachments to SharinPix albums.

uploadAttachment

global Object uploadAttachment(Id attachmentId, String albumId, Map<String, Object> userMetadatas)

  • Uploads Salesforce attachments to SharinPix albums.

uploadAttachment

global Object uploadAttachment(Id attachmentId, String albumId, Map<String, Object> userMetadatas, List<String> tags)

  • Uploads Attachments to SharinPix albums with tags. Using this method, you can also provide a list of tags to be applied to every image.

uploadContentDocument

global Object uploadContentDocument(Id contentDocumentId, String albumId)

  • Uploads Salesforce ContentDocuments to SharinPix albums.

uploadContentDocument

global Object uploadContentDocument(Id contentDocumentId, String albumId, Map<String, Object> userMetadatas)

  • Uploads Salesforce ContentDocuments to SharinPix albums.

uploadContentDocument

global Object uploadContentDocument(Id contentDocumentId, String albumId, Map<String, Object> userMetadatas, List<String> tags)

  • Uploads Salesforce ContentDocuments to SharinPix albums. Using this method, you can also provide a title and description within the userMetadatas parameter and a list of tags within the tags parameter to be applied to every image.

uploadFromUrl

global Object uploadFromUrl(String imageUrl, String albumId, String filename)

  • Uploads an image to SharinPix using an URL.

uploadFromUrl

global Object uploadFromUrl(String imageUrl, String albumId, String filename, map<string, object> metadatas)

  • Uploads an image to SharinPix using an URL. Using this method, you can also provide specific metadata as title, description and contentDocumentId within the userMetadatas parameter to be applied to the image.

uploadWebshot

global Object uploadWebshot(String url, String albumId)

  • Captures screenshot from website URL and uploads to SharinPix.

uploadWebshot

global Object uploadWebshot(String url, String albumId, Map<string, object> options)

  • Captures screenshot from website URL and uploads to SharinPix. Using this method you can also provide a list of tags to be applied on every image. For e.g : sharinpix.Utils.uploadWebshot('https:/test/maps/test', '00324000004GUxhAAG', new Map<string, object>{ 'tags' => new List<string> {'mapTag'}});

generateMobileAppUrl

global String generateMobileAppUrl(String albumId, Map<String, Object> options)

  • Generates the SharinPix URL used to launch the mobile application.

generateMobileAppUrl

global String generateMobileAppUrl(String albumId, String name, Map<String, Object> options, Integer linkExpiration)

  • Generates the SharinPix URL used to launch the mobile application.

splitToken

global static List<String> splitToken(String token, Integer sizeLimit)

  • Method used to split a token.

getAlbumImageIds

global List<String> getAlbumImageIds(Id albumId)

  • Retrieves all image IDs found in an album.

deleteImage

global List<String> deleteImage(String imageId)

  • Deletes image corresponding to the given ID

deleteImage

global List<String> deleteImage(String imageId, map<string, object> payload)

  • Deletes image corresponding to the given ID taking into consideration parameters passed in payload. Available options:

    • purge

      • Set to true to completely delete image from SharinPix. This action cannot be undone and image cannot be restored. Example usage: (new sharinpix.Utils()).deleteImage('imageIdHere', new map<string,object>{'purge' => true});

deleteImages

global List<String> deleteImages(List<String> imageIds)

  • Deletes images corresponding to the given IDs

deleteImages

global List<String> deleteImages(List<String> imageIds, map<string, object> payload)

  • Deletes images corresponding to the given IDs taking into consideration parameters passed in payload. Available options:

    • purge

      • Set to true to completely delete images from SharinPix. This action cannot be undone and images cannot be restored.

updateSessionIdValidity

global Object updateSessionIdValidity(String id, Boolean valid)

  • Validates or invalidates a session (corresponding to the given session Id in the parameters)

  • Updates valid to true to validate a session or false to invalidate a session.

createContentDocumentFromUrl

You can utilize this method to transform a public URL into a content document. It's applicable for converting SharinPix Images into content documents using SharinPix public image URLs.

createContentDocumentFromUrl without the option to add custom filename

global static Id createContentDocumentFromUrl(String url)

  • Download a file at a URL to Content Document

createContentDocumentFromUrl with option to add custom filename

global static Id createContentDocumentFromUrl(String url, Map<String, Object> options)

  • Download a file at a URL to Content Document with custom filename

Note: The custom filename should be added with its extension (e.g. jpg, png, jpeg, and so on) and the key should be 'filename' as shown in the example below.

circle-exclamation

Last updated

Was this helpful?