private static async Task <int> GetAchievementImagesAsync(GetAchievevmentImagesOptions options)
        {
            Console.WriteLine("Getting achievement images.");
            Console.WriteLine();

            ConfigResponse <IEnumerable <AchievementImage> > response = await ConfigurationManager.GetAchievementImagesAsync(options.Scid);

            Console.WriteLine(ObjectPrinter.Print(response.Result));
            return(0);
        }
        private static async Task <int> GetSandboxesAsync(GetSandboxOptions options)
        {
            Console.WriteLine("Getting list of sandboxes.");
            Console.WriteLine();

            ConfigResponse <IEnumerable <string> > response = await ConfigurationManager.GetSandboxesAsync(options.AccountId);

            Console.WriteLine(ObjectPrinter.Print(response.Result));
            return(0);
        }
        private static async Task <int> GetWebServicesAsync(GetWebServicesOptions options)
        {
            Console.WriteLine("Obtaining web services.");
            Console.WriteLine();

            ConfigResponse <IEnumerable <WebService> > response = await ConfigurationManager.GetWebServicesAsync(options.AccountId);

            Console.WriteLine(ObjectPrinter.Print(response.Result));
            return(0);
        }
        private static async Task <int> GetRelyingPartiesAsync(GetRelyingPartiesOptions options)
        {
            Console.WriteLine("Obtaining relying parties.");
            Console.WriteLine();

            ConfigResponse <IEnumerable <RelyingParty> > response = await ConfigurationManager.GetRelyingPartiesAsync(options.AccountId);

            Console.WriteLine(ObjectPrinter.Print(response.Result));

            return(0);
        }
        private static async Task <int> GetProductAsync(GetProductOptions options)
        {
            Console.WriteLine("Obtaining product.");
            Console.WriteLine();

            ConfigResponse <Product> response = await ConfigurationManager.GetProductAsync(options.ProductId);

            Console.WriteLine(ObjectPrinter.Print(response.Result));

            return(0);
        }
        private static async Task <int> UploadAchievementImageAsync(UploadAchievementImageOptions options)
        {
            Console.WriteLine("Uploading achievement image.");
            Console.WriteLine();

            using (FileStream stream = File.OpenRead(options.Filename))
            {
                ConfigResponse <AchievementImage> response = await ConfigurationManager.UploadAchievementImageAsync(options.Scid, Path.GetFileName(stream.Name), stream);

                Console.WriteLine(ObjectPrinter.Print(response.Result));
            }

            return(0);
        }
        private static async Task <int> GetSchemasAsync(GetSchemasOptions options)
        {
            if (string.IsNullOrEmpty(options.Type))
            {
                // Get the schema types.
                Console.WriteLine("Obtaining document schema types.");
                Console.WriteLine();

                ConfigResponse <IEnumerable <string> > schemaTypes = await ConfigurationManager.GetSchemaTypesAsync();

                Console.WriteLine(ObjectPrinter.Print(schemaTypes.Result));
                if (!string.IsNullOrEmpty(options.Destination))
                {
                    foreach (string schemaType in schemaTypes.Result)
                    {
                        EnsureDirectory(options.Destination);
                        ConfigResponse <IEnumerable <SchemaVersion> > versions = await ConfigurationManager.GetSchemaVersionsAsync(schemaType);

                        foreach (SchemaVersion version in versions.Result)
                        {
                            ConfigResponse <Stream> schema = await ConfigurationManager.GetSchemaAsync(schemaType, version.Version);

                            string path = Path.Combine(options.Destination, $"{schemaType.ToLowerInvariant()}_{version.Version}.xsd");
                            using (FileStream fileStream = File.Create(path))
                            {
                                await schema.Result.CopyToAsync(fileStream);
                            }
                        }
                    }
                }
            }
            else if (options.Version <= 0)
            {
                // Get the schema versions.
                Console.WriteLine($"Obtaining document schema versions for type {options.Type}.");
                Console.WriteLine();

                ConfigResponse <IEnumerable <SchemaVersion> > schemaVersions = await ConfigurationManager.GetSchemaVersionsAsync(options.Type);

                Console.WriteLine(ObjectPrinter.Print(schemaVersions.Result));
            }
            else
            {
                Console.WriteLine($"Obtaining document schema {options.Type} for version {options.Version}.");
                Console.WriteLine();

                ConfigResponse <Stream> schema = await ConfigurationManager.GetSchemaAsync(options.Type, options.Version);

                if (string.IsNullOrEmpty(options.Destination))
                {
                    // The destination wasn't specified. Output the schema to stdout.
                    await schema.Result.CopyToAsync(Console.OpenStandardOutput());
                }
                else
                {
                    // The destination exists. Save the file to the directory.
                    EnsureDirectory(options.Destination);
                    string path = Path.Combine(options.Destination, $"{options.Type.ToLowerInvariant()}_{options.Version}.xsd");
                    using (FileStream fileStream = File.Create(path))
                    {
                        await schema.Result.CopyToAsync(fileStream);
                    }

                    Console.WriteLine($"Schema saved as {path}");
                }
            }

            return(0);
        }