About Favorites

About Favorites

Contents

Introduction

For all the API calls, first create an object of the SDK class so that you can access the SDK functions.

To create an object of the SDK class, pass the following information to the SDK constructor:

  • clientKey - obtained when you created an application in Key Management
  • clientSecret - obtained when you created an application in Key Management
  • callbackUrl - HTTP callback address where the user can access the application. Your app must specify it exactly as you have entered it in Key Management as it is case sensitive.
$sdk = new Thingspace\Cloud\Sdk(clientKey,clientSecret,callbackUrl);

Examples

deleteFavorites

deleteFavorites removes a favorite mark from a file or a folder. Request Parameters

  • uri - the URI of the resource obtained from a response to a getFullview or getMetadata api call.
  • createVersion - If set to true, creates a new version of the file or folder. Defaults to false.

Code Sample

try {
	$response = $sdk->deleteFavorites($uri,$createVersion);
	
	} catch (Exception $e) {
	 	try
		{
	  	   return $e->getResponse();	
		}
		finally {
		   if(is_object($e->getResponse()))
			{
		   		return $e->getResponse()->getBody()->getContents();
			}
			else
			{
				return false;
			}
		}
	}
	return $response;

getFavorites

getFavorites retrieves a list of favorite files and folders in a specified virtual folder sorted by last modified date.

Request Parameters

  • filetype - The type of the favorite. Possible values are:
    • all (default)
    • documents1
    • image
    • music
    • video
  • type - Used to restrict the search results. Possible values are:
    • file&folder (default)
    • file
    • folder
  • virtualfolder - Folder that represents various client types at the root level and contains their respective data.

1 Documents list all file types other than image, music, or video. They are categorized by the mime-type, such as application/pdf, application/octet-stream.

Code Sample

try {
		$response = $sdk->getFavorites($virtualfolder, $type, $filetype);
		$response = json_decode($response->getBody()->getContents(),true);
	} catch (Exception $e) {
	 	try
		{
	  	   return $e->getResponse();	
		}
		finally {
		   if(is_object($e->getResponse()))
			{
		   		return $e->getResponse()->getBody()->getContents();
			}
			else
			{
				return false;
			}
		}
	}
	return $response;

Example Return Response

{
	"count": 0,
	"file": [{
		"name": "string",
		"parentPath": "string",
		"checksum": "string",
		"contentAccessible": true,
		"contentToken": "string",
		"deleted": true,
		"extension": "string",
		"size": 0,
		"systemAttributes": {},
		"version": 0,
		"versionCreated": "string",
		"viewUid": [{
			"type": "string",
			"viewType": "string",
			"uid": "string"
		}],
		"uri": "string",
		"shareAssociation": [{
			"uid": "string",
			"visibility": "string",
			"name": "string",
			"type": "string"
		}]
	}],
	"folder": [{
		"name": "string",
		"parentPath": "string",
		"size": 0,
		"version": 0,
		"versionCreated": "string",
		"count": 0,
		"deleted": true,
		"viewUid": [{
			"type": "string",
			"viewType": "string",
			"uid": "string"
		}],
		"uri": "string",
		"shareAssociation": [{
			"uid": "string",
			"visibility": "string",
			"name": "string",
			"type": "string"
		}]
	}]
}

setFavorites

setFavorites marks a file and folder as a favorite .

Request Parameters

  • Update Favorites - Allows you to mark the list of files or folders as favorites.

Code Sample

try {
		$response = $sdk->setFavorites($uri, $createVersion);
		$response = json_decode($response->getBody()->getContents(),true);
	} catch (Exception $e) {
	 	try
		{
	  	   return $e->getResponse();	
		}
		finally {
		   if(is_object($e->getResponse()))
			{
		   		return $e->getResponse()->getBody()->getContents();
			}
			else
			{
				return false;
			}
		}
	}
	return $response;

Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.