public void Tags_UnsupportedFormat()
        {
            var testFile = TestFiles.Json;
            var options  = new TagsOptions
            {
                FileInfo = testFile.ToFileInfo()
            };

            var request = new TagsRequest(options);
            var ex      = Assert.Throws <ApiException>(() => { InfoApi.Tags(request); });

            Assert.AreEqual($"The specified file '{testFile.FullName}' has type which is not currently supported.", ex.Message);
        }
        public void Tags_DocumentProtectedException()
        {
            var testFile = TestFiles.PasswordProtected;
            var options  = new TagsOptions
            {
                FileInfo = testFile.ToFileInfo(),
            };

            var request = new TagsRequest(options);
            var ex      = Assert.Throws <ApiException>(() => { InfoApi.Tags(request); });

            Assert.AreEqual($"The specified file '{testFile.FullName}' is protected.", ex.Message);
        }
        public void Tags_FileNotFound()
        {
            var testFile = TestFiles.NotExist;
            var options  = new TagsOptions
            {
                FileInfo = testFile.ToFileInfo(),
            };

            var request = new TagsRequest(options);

            var ex = Assert.Throws <ApiException>(() => { InfoApi.Tags(request); });

            Assert.AreEqual($"Can't find file located at '{testFile.FullName}'.", ex.Message);
        }
        public void TagsApiTest()
        {
            var options = new TagsOptions
            {
                FileInfo = TestFiles.Docx.ToFileInfo()
            };

            var request = new TagsRequest(options);

            var result = InfoApi.Tags(request);

            Assert.IsNotNull(result.RootPackage);
            Assert.IsNotEmpty(result.RootPackage.InnerPackages);
            Assert.IsTrue(result.RootPackage.InnerPackages.Any(x => string.Equals(x.PackageName, "FileFormat")));
            Assert.IsTrue(result.RootPackage.InnerPackages.Any(x => x.PackageProperties.First(p => p.Name == "FileFormat").Tags
                                                               .Select(s => s.Name).Any(e => string.Equals(e, "FileFormat"))));
        }
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new InfoApi(configuration);

            try
            {
                var fileInfo = new FileInfo
                {
                    FilePath    = "documents/input.docx",
                    StorageName = Common.MyStorage
                };

                var options = new TagsOptions
                {
                    FileInfo = fileInfo
                };

                var request = new TagsRequest(options);

                // Get tags
                var response = apiInstance.Tags(request);
                Console.WriteLine($"Root package: {response.RootPackage.PackageName}");
                foreach (var entry in response.RootPackage.InnerPackages[0].PackageProperties)
                {
                    Console.WriteLine($"{entry.Name}: {entry.Value}");
                    if (entry.Tags == null)
                    {
                        continue;
                    }
                    foreach (var tag in entry.Tags)
                    {
                        Console.WriteLine($"Tag for property: name - {tag.Name}, category - {tag.Category}");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling InfoApi: " + e.Message);
            }
        }