internal static async Task CreateBlobElementTranslation(CommandExecutionContext context, Dictionary <string, List <string> > options, List <string> values)
        {
            OnshapeBlobTranslationParameters translationParameters = new OnshapeBlobTranslationParameters()
            {
                formatName    = options.ContainsKey(Constants.FORMAT) ? options[Constants.FORMAT][0] : null,
                versionString = options.ContainsKey(Constants.FORMAT_VERSION) ? options[Constants.FORMAT_VERSION][0] : null
            };
            string flattenAssembliesStr = options.GetOptionValue(Constants.FLATTEN_ASSEMBLIES);
            string storeInDocumentStr   = options.GetOptionValue(Constants.STORE_IN_DOCUMENT);
            string yAxisIsUpStr         = options.GetOptionValue(Constants.Y_AXIS_IS_UP);

            if (!String.IsNullOrEmpty(flattenAssembliesStr))
            {
                translationParameters.flattenAssemblies = Boolean.Parse(flattenAssembliesStr);
            }
            if (!String.IsNullOrEmpty(storeInDocumentStr))
            {
                translationParameters.storeInDocument = Boolean.Parse(storeInDocumentStr);
            }
            if (!String.IsNullOrEmpty(yAxisIsUpStr))
            {
                translationParameters.yAxisIsUp = Boolean.Parse(yAxisIsUpStr);
            }
            OnshapeTranslationStatus status = await context.Client.CreateBlobelementTranslation(options[Constants.DOCUMENT_ID][0], options[Constants.WORKSPACE_ID][0], options[Constants.ELEMENT_ID][0], translationParameters);

            Console.WriteLine(JsonConvert.SerializeObject(status, Formatting.Indented));
        }
        public async Task <OnshapeTranslationStatus> GetTranslationStatus(String translationId)
        {
            OnshapeTranslationStatus result = null;
            var response = await HttpGet(String.Format(Constants.TRANSLATION_API_URI, translationId));

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                result = await response.Content.ReadAsAsync <OnshapeTranslationStatus>();
            }
            return(result);
        }
        public async Task <OnshapeTranslationStatus> CreateTranslation(String documentId, String workspaceId, Dictionary <string, string> fields, String fileName, byte[] fileData = null)
        {
            OnshapeTranslationStatus result = null;
            var response = await HttpPostMultipartFormData(String.Format(Constants.CREATE_TRANSLATION_API_URI, documentId, workspaceId), fields, fileName, fileData);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                result = await response.Content.ReadAsAsync <OnshapeTranslationStatus>();
            }
            return(result);
        }
        internal static async Task CreateAssemblyTranslation(CommandExecutionContext context, Dictionary <string, List <string> > options, List <string> values)
        {
            OnshapeTranslationParameters translationParameters = new OnshapeTranslationParameters()
            {
                formatName    = options.GetOptionValue(Constants.FORMAT),
                versionString = options.GetOptionValue(Constants.FORMAT_VERSION)
            };
            string storeInDocumentStr = options.GetOptionValue(Constants.STORE_IN_DOCUMENT);

            if (!String.IsNullOrEmpty(storeInDocumentStr))
            {
                translationParameters.storeInDocument = Boolean.Parse(storeInDocumentStr);
            }
            OnshapeTranslationStatus status = await context.Client.CreateAssemblyTranslation(options[Constants.DOCUMENT_ID][0], options[Constants.WORKSPACE_ID][0], options[Constants.ELEMENT_ID][0], translationParameters);

            Console.WriteLine(JsonConvert.SerializeObject(status, Formatting.Indented));
        }
        internal static async Task CreateTranslation(CommandExecutionContext context, Dictionary <string, List <string> > options, List <string> values)
        {
            Dictionary <String, String> formFields = new Dictionary <String, String> {
                { "encodedFileName", HttpUtility.UrlEncode(System.IO.Path.GetFileName(options[Constants.FILE][0])) },
                { "formatName", options[Constants.FORMAT][0].ToUpperInvariant() },
                { "name", HttpUtility.UrlEncode(System.IO.Path.GetFileNameWithoutExtension(options[Constants.FILE][0])) }
            };
            string flattenAssembliesStr = options.GetOptionValue(Constants.FLATTEN_ASSEMBLIES);
            string yAxisIsUpStr         = options.GetOptionValue(Constants.Y_AXIS_IS_UP);
            string fileExtension        = System.IO.Path.GetExtension(options[Constants.FILE][0]);

            if (flattenAssembliesStr != null)
            {
                formFields["flattenAssemblies"] = flattenAssembliesStr;
            }
            if (yAxisIsUpStr != null)
            {
                formFields["yAxisIsUp"] = yAxisIsUpStr;
            }
            OnshapeTranslationStatus status = await context.Client.CreateTranslation(options[Constants.DOCUMENT_ID][0], options[Constants.WORKSPACE_ID][0], formFields, options[Constants.FILE][0]);

            Console.WriteLine(JsonConvert.SerializeObject(status, Formatting.Indented));
        }
        internal static async Task GetTranslationStatus(CommandExecutionContext context, Dictionary <string, List <string> > options, List <string> values)
        {
            OnshapeTranslationStatus status = await context.Client.GetTranslationStatus(options[Constants.TRANSLATION_ID][0]);

            Console.WriteLine(JsonConvert.SerializeObject(status, Formatting.Indented));
        }