private async Task <MetaDataBase> GetVersions(DropBoxMetaDataInternal internalObj, string path, int limit)
        {
            path = FixPath(path);

            var queryParams = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("rev_limit", limit.ToString( ))
            };

            var response = await this._client.GetAsync(string.Format("{0}/{1}/revisions/{2}{3}{4}", ApiBaseUrl, Version, this.RootString,
                                                                     path,
                                                                     queryParams.ToQueryString( ))
                                                       );

            switch (response.StatusCode)
            {
            case HttpStatusCode.OK:
                break;

            case HttpStatusCode.NotFound:
                throw new CloudStorageItemNotFoundException( );

            default:
                throw new HttpException((int)response.StatusCode, response.Content.ReadAsStringAsync( ).Result);
            }

            // Read response asynchronously as JsonValue and write out objects
            var l = await response.Content.ReadAsAsync <List <DropBoxMetaDataInternal> >(this._mediaTypeFormatters);

            var ret = (DropBoxFile)this.ConvertInternalToMetaData(internalObj);

            ret.Versions = l.Select(i => (FileVersionMetaDataBase)this.ConvertInternalToVersionedMetaData(i)).ToList( );

            return(ret);
        }
 private MetaDataBase ConvertInternalToVersionedMetaData(DropBoxMetaDataInternal i)
 {
     return(new DropBoxFileVersion( )
     {
         Path = i.Path,
         Name = i.Path.Split('/').Last( ),
         IsFolder = i.Is_Dir,
         Checksum = i.Hash,
         ThumbExists = i.Thumb_Exists,
         NumberOfBytes = i.Bytes,
         LastModified = i.Modified,
         IsDeleted = i.Is_Deleted,
         Size = i.Size,
         Root = i.Root,
         Icon = i.Icon,
         Revision = i.Revision,
     });
 }
 private MetaDataBase ConvertInternalToMetaData(DropBoxMetaDataInternal i)
 {
     if (i.Is_Dir)
     {
         return(new DropBoxFolder {
             Path = i.Path,
             Name = i.Path.Split('/').Last( ),
             IsFolder = i.Is_Dir,
             Checksum = i.Hash,
             ThumbExists = i.Thumb_Exists,
             NumberOfBytes = i.Bytes,
             LastModified = i.Modified,
             IsDeleted = i.Is_Deleted,
             Size = i.Size,
             Root = i.Root,
             Icon = i.Icon,
             Revision = i.Revision,
             Files = i.Contents == null ? new List <FileMetaDataBase>() : i.Contents.Where(c => c.Is_Dir == false).Select(c => (FileMetaDataBase)this.ConvertInternalToMetaData(c)).ToList( ),
             Folders = i.Contents == null ? new List <FolderMetaDataBase>( ) : i.Contents.Where(c => c.Is_Dir).Select(c => (FolderMetaDataBase)this.ConvertInternalToMetaData(c)).ToList( )
         });
     }
     return(new DropBoxFile( )
     {
         Path = i.Path,
         Name = i.Path.Split('/').Last( ),
         IsFolder = i.Is_Dir,
         Checksum = i.Hash,
         ThumbExists = i.Thumb_Exists,
         NumberOfBytes = i.Bytes,
         LastModified = i.Modified,
         IsDeleted = i.Is_Deleted,
         Size = i.Size,
         Root = i.Root,
         Icon = i.Icon,
         Revision = i.Revision
     });
 }