About Virtual Folders

About Virtual Folders

Contents

Introduction

The iOS SDK allows you to create, rename, and delete virtual folders. The following examples provide detailed steps that describe how to use supported methods and include code samples to help you get started with virtual folders.

Examples

createVirtualFolder

This example illustrates a call to createVirtualFolder:withCompletionHandler: API. This API is used create virtual folders.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCAPISDK object and call the createVirtualFolder:withCompletionHandler: method.
  4. Perform the createVirtualFolder:withCompletionHandler: API call using the code sample in this example.
  5. Retrieve the results in the completion block.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call authenticate:fromViewController:withCompletionHandler: API to get a new access token.

Code Sample

@try {
        PCCreateVFolderAPIParams *params = [[PCCreateVFolderAPIParams alloc] init];
        params.folderName = @"Test Virtual Folder";  //folderName is required to create a virtual folder. (required)
            
        [[PCAPISDK sharedInstance] createVirtualFolder:params withCompletionHandler:^(PCResource *metadata, PCAPIQueryResponse *response){
             switch (response.urlResponse.statusCode){
                case PCAPIResponseCodeResourceCreated:
                    NSLog(@"Virtual folder is created");
                    break;
                case PCAPIResponseCodeUnauthorized:
                    NSLog(@"Session is no longer valid.");
                    break;
                case PCAPIResponseCodeServiceUnavailable:
                    NSLog(@"Server Unavailable");
                    break;
                default:
                    NSLog(@"failed. Please try again!");
                    break;
                }
            }];
    }
    @catch (NSException * e) {
        NSLog(@"catching %@ reason %@", [e name], [e reason]);
    }

deleteVirtualFolder

This example illustrates a call to deleteVirtualFolder:withCompletionHandler: API. This API call is used to delete a specified virtual folder.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCAPISDK object and call the deleteVirtualFolder:withCompletionHandler: method.
  4. Perform the deleteVirtualFolder:withCompletionHandler: API call using the code sample in this example.
  5. Retrieve the results in the completion block.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call authenticate:fromViewController:withCompletionHandler: API to get a new access token.

Code Sample

@try {
	PCDeleteVFolderAPIParams *params = [[PCDeleteVFolderAPIParams alloc] init];
    params.folderName = @"Virtual_Folder_Name"; //Name of the virtual folder. (required)
                                                     
    [[PCAPISDK sharedInstance] deleteVirtualFolder:params withCompletionHandler:^(PCAPIQueryResponse *response) {
        
       	switch (response.urlResponse.statusCode){
            case PCAPIResponseCodeNoContent:
                NSLog(@"Virtual folder is deleted");
                break;
            case PCAPIResponseCodeUnauthorized:
                NSLog(@"Session is no longer valid.");
                break;
            case PCAPIResponseCodeServiceUnavailable:
                NSLog(@"Server Unavailable");
                break;
            default:
                NSLog(@"failed. Please try again!");
                break;
        }
    }];
}
@catch (NSException * e) {
    NSLog(@"catching %@ reason %@", [e name], [e reason]);
}

renameVirtualFolder

This example illustrates a call to renameVirtualFolder:withCompletionHandler: API. This API call is used rename a specified virtual folder.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCAPISDK object and call the renameVirtualFolder:withCompletionHandler: method.
  4. Perform the renameVirtualFolder:withCompletionHandler: API call using the code sample in this example.
  5. Retrieve the result in the completion block.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call authenticate:fromViewController:withCompletionHandler: API to get a new access token.

Code Sample

@try {
            PCRenameVFolderAPIParams *params = [[PCRenameVFolderAPIParams alloc] init];
            params.src = @"old_name";     //src is required to rename a virtual folder. (required)
            params.target = @"new_name";  //target is required to rename a virtual folder. (required)
                
            [[PCAPISDK sharedInstance] renameVirtualFolder:params withCompletionHandler:^(PCResource *metadata, PCAPIQueryResponse *response) {
                switch (response.urlResponse.statusCode){
                    case PCAPIResponseCodeOK:
                        NSLog(@"Virtual folder renamed");
                        break;
                    case PCAPIResponseCodeUnauthorized:
                        NSLog(@"Session is no longer valid.");
                        break;
                    case PCAPIResponseCodeServiceUnavailable:
                        NSLog(@"Server Unavailable");
                        break;
                    default:
                        NSLog(@"failed. Please try again!");
                        break;
                }
            }];
        }
        @catch (NSException * e) {
            NSLog(@"catching %@ reason %@", [e name], [e reason]);
        }

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