public void GetFileMetadata()
        {
            mockServer.ExpectNewRequest()
            .AndExpectUri("https://api.dropbox.com/1/metadata/dropbox/Dir/File.txt?list=false")
            .AndExpectMethod(HttpMethod.GET)
            .AndRespondWith(EmbeddedResource("Metadata_File.json"), responseHeaders);

            MetadataParameters parameters = new MetadataParameters();

            parameters.IncludeContents = false;
#if NET_4_0 || SILVERLIGHT_5
            Entry metadata = dropbox.GetMetadataAsync("Dir/File.txt", parameters).Result;
#else
            Entry metadata = dropbox.GetMetadata("Dir/File.txt", parameters);
#endif
            Assert.AreEqual(230783, metadata.Bytes);
            Assert.IsNull(metadata.Hash);
            Assert.AreEqual("page_white_acrobat", metadata.Icon);
            Assert.AreEqual(false, metadata.IsDeleted);
            Assert.AreEqual(false, metadata.IsDirectory);
            Assert.AreEqual("application/pdf", metadata.MimeType);
            Assert.IsNotNull(metadata.ModifiedDate);
            Assert.AreEqual("19/07/2011 21:55:38", metadata.ModifiedDate.Value.ToUniversalTime().ToString("dd'/'MM'/'yyyy HH:mm:ss"));
            Assert.AreEqual("/Getting_Started.pdf", metadata.Path);
            Assert.AreEqual("35e97029684fe", metadata.Revision);
            Assert.AreEqual("dropbox", metadata.Root);
            Assert.AreEqual("225.4KB", metadata.Size);
            Assert.IsFalse(metadata.ThumbExists);
            Assert.IsNull(metadata.Contents);
        }
Exemplo n.º 2
0
        static void TestMetadata()
        {
            var parameters = new MetadataParameters()
            {
                Manufacturer = "Aerotech",
            };

            var results = services.Metadata(parameters);
        }
        public void DropboxPathSpecialCharacters()
        {
            mockServer.ExpectNewRequest()
            .AndExpectUri("https://api.dropbox.com/1/metadata/dropbox/%24%26%2B%2C%3B%3D%40%23%7B%7D%5E%7E%5B%5D%60%27%25%28%29%21-_/Spring%20Social.txt?list=false")
            .AndExpectMethod(HttpMethod.GET);

            MetadataParameters parameters = new MetadataParameters();

            parameters.IncludeContents = false;
#if NET_4_0 || SILVERLIGHT_5
            dropbox.GetMetadataAsync("$&+,;=@#{}^~[]`'%()!-_/Spring Social.txt", parameters).Wait();
#else
            dropbox.GetMetadata("$&+,;=@#{}^~[]`'%()!-_/Spring Social.txt", parameters);
#endif
        }
        public void GetFolderMetadata()
        {
            mockServer.ExpectNewRequest()
            .AndExpectUri("https://api.dropbox.com/1/metadata/dropbox/Dir/?file_limit=100&hash=a123z&include_deleted=true&rev=abcrev123")
            .AndExpectMethod(HttpMethod.GET)
            .AndRespondWith(EmbeddedResource("Metadata_Folder.json"), responseHeaders);

            MetadataParameters parameters = new MetadataParameters();

            parameters.FileLimit      = 100;
            parameters.Hash           = "a123z";
            parameters.IncludeDeleted = true;
            parameters.Revision       = "abcrev123";
#if NET_4_0 || SILVERLIGHT_5
            Entry metadata = dropbox.GetMetadataAsync("Dir/", parameters).Result;
#else
            Entry metadata = dropbox.GetMetadata("Dir/", parameters);
#endif
            Assert.AreEqual(0, metadata.Bytes);
            Assert.AreEqual("37eb1ba1849d4b0fb0b28caf7ef3af52", metadata.Hash);
            Assert.AreEqual("folder_public", metadata.Icon);
            Assert.AreEqual(false, metadata.IsDeleted);
            Assert.AreEqual(true, metadata.IsDirectory);
            Assert.IsNull(metadata.MimeType);
            Assert.IsNotNull(metadata.ModifiedDate);
            Assert.AreEqual("27/04/2011 22:18:51", metadata.ModifiedDate.Value.ToUniversalTime().ToString("dd'/'MM'/'yyyy HH:mm:ss"));
            Assert.AreEqual("/Public", metadata.Path);
            Assert.AreEqual("714f029684fe", metadata.Revision);
            Assert.AreEqual("dropbox", metadata.Root);
            Assert.AreEqual("0 bytes", metadata.Size);
            Assert.IsFalse(metadata.ThumbExists);
            Assert.IsNotNull(metadata.Contents);
            Assert.AreEqual(1, metadata.Contents.Count);
            Assert.AreEqual(0, metadata.Contents[0].Bytes);
            Assert.IsNull(metadata.Contents[0].Hash);
            Assert.AreEqual("page_white_text", metadata.Contents[0].Icon);
            Assert.AreEqual(false, metadata.Contents[0].IsDeleted);
            Assert.AreEqual(false, metadata.Contents[0].IsDirectory);
            Assert.AreEqual("text/plain", metadata.Contents[0].MimeType);
            Assert.IsNotNull(metadata.Contents[0].ModifiedDate);
            Assert.AreEqual("18/07/2011 20:13:43", metadata.Contents[0].ModifiedDate.Value.ToUniversalTime().ToString("dd'/'MM'/'yyyy HH:mm:ss"));
            Assert.AreEqual("/Public/latest.txt", metadata.Contents[0].Path);
            Assert.AreEqual("35c1f029684fe", metadata.Contents[0].Revision);
            Assert.AreEqual("dropbox", metadata.Contents[0].Root);
            Assert.AreEqual("0 bytes", metadata.Contents[0].Size);
            Assert.IsFalse(metadata.Contents[0].ThumbExists);
            Assert.IsNull(metadata.Contents[0].Contents);
        }
        public void GetFolderMetadata_304()
        {
            mockServer.ExpectNewRequest()
            .AndExpectUri("https://api.dropbox.com/1/metadata/dropbox/Dir/?hash=a123z")
            .AndExpectMethod(HttpMethod.GET)
            .AndRespondWith("", responseHeaders, HttpStatusCode.NotModified, "");

            MetadataParameters parameters = new MetadataParameters();

            parameters.Hash = "a123z";
#if NET_4_0 || SILVERLIGHT_5
            Entry metadata = dropbox.GetMetadataAsync("Dir/", parameters).Result;
#else
            Entry metadata = dropbox.GetMetadata("Dir/", parameters);
#endif
            Assert.IsNull(metadata);
        }
 /// <summary>
 /// Asynchronously retrieves file or folder metadata. 
 /// May return <see langword="null"/> if an hash is provided through parameters.
 /// </summary>
 /// <param name="path">The Dropbox path to the file or folder, relative to root.</param>
 /// <param name="parameters">The parameters for retrieving file and folder metadata.</param>
 /// <param name="operationCompleted">
 /// The <code>Action&lt;&gt;</code> to perform when the asynchronous request completes. 
 /// Provides a metadata <see cref="Entry"/> for the file or folder.
 /// </param>
 /// <returns>
 /// A <see cref="RestOperationCanceler"/> instance that allows to cancel the asynchronous operation.
 /// </returns>
 /// <exception cref="DropboxApiException">If there is an error while communicating with Dropbox.</exception>
 public RestOperationCanceler GetMetadataAsync(string path, MetadataParameters parameters, Action<RestOperationCompletedEventArgs<Entry>> operationCompleted)
 {
     return this.RestTemplate.GetForObjectAsync<Entry>(this.BuildMetadataUrl(path, parameters), operationCompleted);
 }
 /// <summary>
 /// Asynchronously retrieves file or folder metadata. 
 /// May return <see langword="null"/> if an hash is provided through parameters.
 /// </summary>
 /// <param name="path">The Dropbox path to the file or folder, relative to root.</param>
 /// <param name="parameters">The parameters for retrieving file and folder metadata.</param>
 /// <returns>
 /// A <code>Task</code> that represents the asynchronous operation that can return 
 /// a metadata <see cref="Entry"/> for the file or folder.
 /// </returns>
 /// <exception cref="DropboxApiException">If there is an error while communicating with Dropbox.</exception>
 public Task<Entry> GetMetadataAsync(string path, MetadataParameters parameters)
 {
     return this.RestTemplate.GetForObjectAsync<Entry>(this.BuildMetadataUrl(path, parameters));
 }
 /// <summary>
 /// Retrieves file or folder metadata. 
 /// May return <see langword="null"/> if an hash is provided through parameters.
 /// </summary>
 /// <param name="path">The Dropbox path to the file or folder, relative to root.</param>
 /// <param name="parameters">The parameters for retrieving file and folder metadata.</param>
 /// <returns>
 /// A metadata <see cref="Entry"/> for the file or folder.
 /// </returns>
 /// <exception cref="DropboxApiException">If there is an error while communicating with Dropbox.</exception>
 public Entry GetMetadata(string path, MetadataParameters parameters)
 {
     return this.RestTemplate.GetForObject<Entry>(this.BuildMetadataUrl(path, parameters));
 }
 private string BuildMetadataUrl(string dropboxPath, MetadataParameters metadataParameters)
 {
     NameValueCollection parameters = new NameValueCollection();
     if (metadataParameters.FileLimit > 0)
     {
         parameters.Add("file_limit", metadataParameters.FileLimit.ToString());
     }
     if (metadataParameters.Hash != null)
     {
         parameters.Add("hash", metadataParameters.Hash);
     }
     if (!metadataParameters.IncludeContents)
     {
         parameters.Add("list", "false");
     }
     if (metadataParameters.IncludeDeleted)
     {
         parameters.Add("include_deleted", "true");
     }
     if (metadataParameters.Revision != null)
     {
         parameters.Add("rev", metadataParameters.Revision);
     }
     this.AddLocaleTo(parameters);
     return this.BuildUrl("metadata/", dropboxPath, parameters);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Returns all static metadata for one or more cryptocurrencies including name, symbol, logo, and its various registered URLs.
 /// </summary>
 public Response <List <Metadata> > GetCryptocurrencyInfo(MetadataParameters request)
 {
     return(GetCryptocurrencyInfoAsync(request, CancellationToken.None).Result);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Returns all static metadata for one or more cryptocurrencies including name, symbol, logo, and its various registered URLs.
 /// </summary>
 public async Task <Response <List <Metadata> > > GetCryptocurrencyInfoAsync(MetadataParameters request, CancellationToken cancellationToken)
 {
     return(await SendApiRequest <List <Metadata> >(request, "cryptocurrency/info", cancellationToken));
 }
        public void GetFolderMetadata_304()
        {
            mockServer.ExpectNewRequest()
                .AndExpectUri("https://api.dropbox.com/1/metadata/dropbox/Dir/?hash=a123z")
                .AndExpectMethod(HttpMethod.GET)
                .AndRespondWith("", responseHeaders, HttpStatusCode.NotModified, "");

            MetadataParameters parameters = new MetadataParameters();
            parameters.Hash = "a123z";
            #if NET_4_0 || SILVERLIGHT_5
            Entry metadata = dropbox.GetMetadataAsync("Dir/", parameters).Result;
            #else
            Entry metadata = dropbox.GetMetadata("Dir/", parameters);
            #endif
            Assert.IsNull(metadata);
        }
        public void GetFolderMetadata()
        {
            mockServer.ExpectNewRequest()
                .AndExpectUri("https://api.dropbox.com/1/metadata/dropbox/Dir/?file_limit=100&hash=a123z&include_deleted=true&rev=abcrev123")
                .AndExpectMethod(HttpMethod.GET)
                .AndRespondWith(EmbeddedResource("Metadata_Folder.json"), responseHeaders);

            MetadataParameters parameters = new MetadataParameters();
            parameters.FileLimit = 100;
            parameters.Hash = "a123z";
            parameters.IncludeDeleted = true;
            parameters.Revision = "abcrev123";
            #if NET_4_0 || SILVERLIGHT_5
            Entry metadata = dropbox.GetMetadataAsync("Dir/", parameters).Result;
            #else
            Entry metadata = dropbox.GetMetadata("Dir/", parameters);
            #endif
            Assert.AreEqual(0, metadata.Bytes);
            Assert.AreEqual("37eb1ba1849d4b0fb0b28caf7ef3af52", metadata.Hash);
            Assert.AreEqual("folder_public", metadata.Icon);
            Assert.AreEqual(false, metadata.IsDeleted);
            Assert.AreEqual(true, metadata.IsDirectory);
            Assert.IsNull(metadata.MimeType);
            Assert.IsNotNull(metadata.ModifiedDate);
            Assert.AreEqual("27/04/2011 22:18:51", metadata.ModifiedDate.Value.ToUniversalTime().ToString("dd'/'MM'/'yyyy HH:mm:ss"));
            Assert.AreEqual("/Public", metadata.Path);
            Assert.AreEqual("714f029684fe", metadata.Revision);
            Assert.AreEqual("dropbox", metadata.Root);
            Assert.AreEqual("0 bytes", metadata.Size);
            Assert.IsFalse(metadata.ThumbExists);
            Assert.IsNotNull(metadata.Contents);
            Assert.AreEqual(1, metadata.Contents.Count);
            Assert.AreEqual(0, metadata.Contents[0].Bytes);
            Assert.IsNull(metadata.Contents[0].Hash);
            Assert.AreEqual("page_white_text", metadata.Contents[0].Icon);
            Assert.AreEqual(false, metadata.Contents[0].IsDeleted);
            Assert.AreEqual(false, metadata.Contents[0].IsDirectory);
            Assert.AreEqual("text/plain", metadata.Contents[0].MimeType);
            Assert.IsNotNull(metadata.Contents[0].ModifiedDate);
            Assert.AreEqual("18/07/2011 20:13:43", metadata.Contents[0].ModifiedDate.Value.ToUniversalTime().ToString("dd'/'MM'/'yyyy HH:mm:ss"));
            Assert.AreEqual("/Public/latest.txt", metadata.Contents[0].Path);
            Assert.AreEqual("35c1f029684fe", metadata.Contents[0].Revision);
            Assert.AreEqual("dropbox", metadata.Contents[0].Root);
            Assert.AreEqual("0 bytes", metadata.Contents[0].Size);
            Assert.IsFalse(metadata.Contents[0].ThumbExists);
            Assert.IsNull(metadata.Contents[0].Contents);
        }
        public void GetFileMetadata()
        {
            mockServer.ExpectNewRequest()
                .AndExpectUri("https://api.dropbox.com/1/metadata/dropbox/Dir/File.txt?list=false")
                .AndExpectMethod(HttpMethod.GET)
                .AndRespondWith(EmbeddedResource("Metadata_File.json"), responseHeaders);

            MetadataParameters parameters = new MetadataParameters();
            parameters.IncludeContents = false;
            #if NET_4_0 || SILVERLIGHT_5
            Entry metadata = dropbox.GetMetadataAsync("Dir/File.txt", parameters).Result;
            #else
            Entry metadata = dropbox.GetMetadata("Dir/File.txt", parameters);
            #endif
            Assert.AreEqual(230783, metadata.Bytes);
            Assert.IsNull(metadata.Hash);
            Assert.AreEqual("page_white_acrobat", metadata.Icon);
            Assert.AreEqual(false, metadata.IsDeleted);
            Assert.AreEqual(false, metadata.IsDirectory);
            Assert.AreEqual("application/pdf", metadata.MimeType);
            Assert.IsNotNull(metadata.ModifiedDate);
            Assert.AreEqual("19/07/2011 21:55:38", metadata.ModifiedDate.Value.ToUniversalTime().ToString("dd'/'MM'/'yyyy HH:mm:ss"));
            Assert.AreEqual("/Getting_Started.pdf", metadata.Path);
            Assert.AreEqual("35e97029684fe", metadata.Revision);
            Assert.AreEqual("dropbox", metadata.Root);
            Assert.AreEqual("225.4KB", metadata.Size);
            Assert.IsFalse(metadata.ThumbExists);
            Assert.IsNull(metadata.Contents);
        }
        public void DropboxPathSpecialCharacters()
        {
            mockServer.ExpectNewRequest()
                .AndExpectUri("https://api.dropbox.com/1/metadata/dropbox/%24%26%2B%2C%3B%3D%40%23%7B%7D%5E%7E%5B%5D%60%27%25%28%29%21-_/Spring%20Social.txt?list=false")
                .AndExpectMethod(HttpMethod.GET);

            MetadataParameters parameters = new MetadataParameters();
            parameters.IncludeContents = false;
            #if NET_4_0 || SILVERLIGHT_5
            dropbox.GetMetadataAsync("$&+,;=@#{}^~[]`'%()!-_/Spring Social.txt", parameters).Wait();
            #else
            dropbox.GetMetadata("$&+,;=@#{}^~[]`'%()!-_/Spring Social.txt", parameters);
            #endif
        }