コード例 #1
0
ファイル: PetApi.cs プロジェクト: sidcode/swagger-codegen
        /// <summary>
        /// Finds Pets by status Multiple status values can be provided with comma seperated strings
        /// </summary>
        /// <param name="status">Status values that need to be considered for filter</param>
        /// <returns></returns>
        public List <Pet> findPetsByStatus(string status)
        {
            // create path and map variables
            var path = "/pet/findByStatus".Replace("{format}", "json");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();

            // verify required params are set
            if (status == null)
            {
                throw new ApiException(400, "missing required params");
            }
            string paramStr = null;

            if (status != null)
            {
                paramStr = (status != null && status is DateTime) ? ((DateTime)(object)status).ToString("u") : Convert.ToString(status);
                queryParams.Add("status", paramStr);
            }
            try {
                var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
                if (response != null)
                {
                    return((List <Pet>)ApiInvoker.deserialize(response, typeof(List <Pet>)));
                }
                else
                {
                    return(null);
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #2
0
ファイル: PetApi.cs プロジェクト: wingsun97/swagger-codegen
        /// <summary>
        /// Find pet by ID Returns a pet when ID &lt; 10.  ID &gt; 10 or nonintegers will simulate API error conditions
        /// </summary>
        /// <param name="PetId">ID of pet that needs to be fetched</param>

        /// <returns></returns>
        public Pet  getPetById(long?PetId)
        {
            // create path and map variables
            var path = "/pet/{petId}".Replace("{format}", "json").Replace("{" + "petId" + "}", apiInvoker.escapeString(PetId.ToString()));

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();



            try {
                if (typeof(Pet) == typeof(byte[]))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    return(((object)response) as Pet);
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((Pet)ApiInvoker.deserialize(response, typeof(Pet)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Place an order for a pet
        /// </summary>
        /// <param name="Body">order placed for purchasing the pet</param>

        /// <returns></returns>
        public Order  placeOrder(Order Body)
        {
            // create path and map variables
            var path = "/store/order".Replace("{format}", "json");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();



            try {
                if (typeof(Order) == typeof(byte[]))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    return(((object)response) as Order);
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, Body, headerParams, formParams);
                    if (response != null)
                    {
                        return((Order)ApiInvoker.deserialize(response, typeof(Order)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Get user by user name
        /// </summary>
        /// <param name="Username">The name that needs to be fetched. Use user1 for testing. </param>

        /// <returns></returns>
        public User  getUserByName(string Username)
        {
            // create path and map variables
            var path = "/user/{username}".Replace("{format}", "json").Replace("{" + "username" + "}", apiInvoker.escapeString(Username.ToString()));

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();



            try {
                if (typeof(User) == typeof(byte[]))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    return(((object)response) as User);
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((User)ApiInvoker.deserialize(response, typeof(User)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #5
0
ファイル: PetApi.cs プロジェクト: jpark800/swagger-codegen
        public List <Pet> findPetsByTags(string Tags)
        {
            // create path and map variables
            var path = "/pet.{format}/findByTags".Replace("{format}", "json");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();

            // verify required params are set
            if (Tags == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (Tags != null)
            {
                queryParams.Add("Tags", Tags);
            }
            try {
                var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
                if (response != null)
                {
                    return((List <Pet>)ApiInvoker.deserialize(response, typeof(List <Pet>)));
                }
                else
                {
                    return(null);
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Get all active instruments and instruments that have expired in &lt;24hrs.
        /// </summary>
        /// <returns></returns>
        public List <Instrument> getActive()
        {
            // create path and map variables
            var path = "/instrument/active".Replace("{format}", "json");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            try {
                if (typeof(List <Instrument>) == typeof(byte[]))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    return(((object)response) as List <Instrument>);
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((List <Instrument>)ApiInvoker.deserialize(response, typeof(List <Instrument>)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #7
0
ファイル: PetApi.cs プロジェクト: tkellogg/swagger-codegen
        /// <summary>
        /// Find pet by ID Returns a pet based on ID
        /// </summary>
        /// <param name="petId">ID of pet that needs to be fetched</param>
        /// <returns></returns>
        public Pet getPetById(string petId)
        {
            // create path and map variables
            var path = "/pet/{petId}".Replace("{format}", "json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString()));

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();

            // verify required params are set
            if (petId == null)
            {
                throw new ApiException(400, "missing required params");
            }
            string paramStr = null;

            try {
                var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
                if (response != null)
                {
                    return((Pet)ApiInvoker.deserialize(response, typeof(Pet)));
                }
                else
                {
                    return(null);
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Generate barcode. Generate barcode.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="type"></param>
        /// <param name="format"></param>
        /// <param name="resolutionX"></param>
        /// <param name="resolutionY"></param>
        /// <param name="dimensionX"></param>
        /// <param name="dimensionY"></param>
        /// <param name="enableChecksum"></param>
        /// <returns></returns>
        public ResponseMessage GetBarcodeGenerate(string text, string type, string format, float?resolutionX, float?resolutionY, float?dimensionX, float?dimensionY, string enableChecksum)
        {
            // create path and map variables
            var ResourcePath = "/barcode/generate/?appSid={appSid}&amp;text={text}&amp;type={type}&amp;toFormat={toFormat}&amp;resolutionX={resolutionX}&amp;resolutionY={resolutionY}&amp;dimensionX={dimensionX}&amp;dimensionY={dimensionY}&amp;enableChecksum={enableChecksum}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            if (text == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])text=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "text" + "}", apiInvoker.ToPathValue(text));
            }
            if (type == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])type=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "type" + "}", apiInvoker.ToPathValue(type));
            }
            if (format == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])format=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "format" + "}", apiInvoker.ToPathValue(format));
            }
            if (resolutionX == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])resolutionX=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "resolutionX" + "}", apiInvoker.ToPathValue(resolutionX));
            }
            if (resolutionY == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])resolutionY=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "resolutionY" + "}", apiInvoker.ToPathValue(resolutionY));
            }
            if (dimensionX == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])dimensionX=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "dimensionX" + "}", apiInvoker.ToPathValue(dimensionX));
            }
            if (dimensionY == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])dimensionY=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "dimensionY" + "}", apiInvoker.ToPathValue(dimensionY));
            }
            if (enableChecksum == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])enableChecksum=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "enableChecksum" + "}", apiInvoker.ToPathValue(enableChecksum));
            }
            try {
                if (typeof(ResponseMessage) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "GET", queryParams, null, headerParams, formParams);
                    return((ResponseMessage)ApiInvoker.deserialize(response, typeof(ResponseMessage)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "GET", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((ResponseMessage)ApiInvoker.deserialize(response, typeof(ResponseMessage)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Upload a specific file. Parameters: path - source file path e.g. /file.ext, versionID - source file's version, storage - user's source storage name, newdest - destination file path, destStorage - user's destination storage name. Upload a specific file. Parameters: path - source file path e.g. /file.ext, versionID - source file's version, storage - user's source storage name, newdest - destination file path, destStorage - user's destination storage name.
        /// </summary>
        /// <param name="Path"></param>
        /// <param name="versionId"></param>
        /// <param name="storage"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public ResponseMessage PutCreate(string Path, string versionId, string storage, byte[] file)
        {
            // create path and map variables
            var ResourcePath = "/storage/file/{Path}/?appSid={appSid}&amp;versionId={versionId}&amp;storage={storage}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (Path == null || file == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (Path == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])Path=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "Path" + "}", apiInvoker.ToPathValue(Path));
            }
            if (versionId == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])versionId=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "versionId" + "}", apiInvoker.ToPathValue(versionId));
            }
            if (storage == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage));
            }
            if (file != null)
            {
                if (file is byte[])
                {
                    formParams.Add("file", file);
                }
                else
                {
                    //string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file);
                    string paramStr = Convert.ToString(file);
                    formParams.Add("file", paramStr);
                }
            }
            try {
                //if (typeof(ResponseMessage) == typeof(ResponseMessage)) {
                //  var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "GET", queryParams, null, headerParams, formParams);
                //  return (ResponseMessage) ApiInvoker.deserialize(response, typeof(ResponseMessage));
                //} else {
                var response = apiInvoker.invokeAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams);
                if (response != null)
                {
                    return((ResponseMessage)ApiInvoker.deserialize(response, typeof(ResponseMessage)));
                }
                else
                {
                    return(null);
                }
                //}
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Copy a folder. Parameters: path - source folder path e.g. /Folder1, storage - user's source storage name, newdest - destination folder path e.g. /Folder2, destStorage - user's destination storage name. Copy a folder. Parameters: path - source folder path e.g. /Folder1, storage - user's source storage name, newdest - destination folder path e.g. /Folder2, destStorage - user's destination storage name.
        /// </summary>
        /// <param name="Path"></param>
        /// <param name="newdest"></param>
        /// <param name="storage"></param>
        /// <param name="destStorage"></param>
        /// <returns></returns>
        public ResponseMessage PutCopyFolder(string Path, string newdest, string storage, string destStorage)
        {
            // create path and map variables
            var ResourcePath = "/storage/folder/{Path}/?appSid={appSid}&amp;newdest={newdest}&amp;storage={storage}&amp;destStorage={destStorage}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (Path == null || newdest == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (Path == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])Path=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "Path" + "}", apiInvoker.ToPathValue(Path));
            }
            if (newdest == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])newdest=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "newdest" + "}", apiInvoker.ToPathValue(newdest));
            }
            if (storage == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage));
            }
            if (destStorage == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])destStorage=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "destStorage" + "}", apiInvoker.ToPathValue(destStorage));
            }
            try {
                if (typeof(ResponseMessage) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "GET", queryParams, null, headerParams, formParams);
                    return((ResponseMessage)ApiInvoker.deserialize(response, typeof(ResponseMessage)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((ResponseMessage)ApiInvoker.deserialize(response, typeof(ResponseMessage)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Get previous quotes in time buckets.
        /// </summary>
        /// <param name="symbol">Instrument symbol. Send a series (e.g. XBT) to get data for the nearest contract in that series.</param>
        /// <param name="filter">Generic table filter. Send JSON key/value pairs, such as {&quot;key&quot;: &quot;value&quot;}.</param>
        /// <param name="columns">Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect.</param>
        /// <param name="start">Starting point for results.</param>
        /// <param name="reverse">If true, will sort results newest first.</param>
        /// <param name="startTime">Starting date filter for results.</param>
        /// <param name="endTime">Ending date filter for results.</param>
        /// <param name="binSize">Time interval to bucket by. Available options: ['30s', '1m', '5m', '1h', '1d'].</param>
        /// <param name="count">Number of results to fetch.</param>
        /// <returns></returns>
        public List <Quote> getBucketed(string symbol, object filter, List <string> columns, double?start, bool?reverse, DateTime?startTime, DateTime?endTime, string binSize, double?count)
        {
            // create path and map variables
            var path = "/quote/bucketed".Replace("{format}", "json");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            if (binSize != null)
            {
                string paramStr = (binSize is DateTime) ? ((DateTime)(object)binSize).ToString("u") : Convert.ToString(binSize);
                queryParams.Add("binSize", paramStr);
            }
            if (symbol != null)
            {
                string paramStr = (symbol is DateTime) ? ((DateTime)(object)symbol).ToString("u") : Convert.ToString(symbol);
                queryParams.Add("symbol", paramStr);
            }
            if (filter != null)
            {
                string paramStr = (filter is DateTime) ? ((DateTime)(object)filter).ToString("u") : Convert.ToString(filter);
                queryParams.Add("filter", paramStr);
            }
            if (columns != null)
            {
                string paramStr = (columns is DateTime) ? ((DateTime)(object)columns).ToString("u") : Convert.ToString(columns);
                queryParams.Add("columns", paramStr);
            }
            if (count != null)
            {
                string paramStr = (count is DateTime) ? ((DateTime)(object)count).ToString("u") : Convert.ToString(count);
                queryParams.Add("count", paramStr);
            }
            if (start != null)
            {
                string paramStr = (start is DateTime) ? ((DateTime)(object)start).ToString("u") : Convert.ToString(start);
                queryParams.Add("start", paramStr);
            }
            if (reverse != null)
            {
                string paramStr = (reverse is DateTime) ? ((DateTime)(object)reverse).ToString("u") : Convert.ToString(reverse);
                queryParams.Add("reverse", paramStr);
            }
            if (startTime != null)
            {
                string paramStr = (startTime is DateTime) ? ((DateTime)(object)startTime).ToString("u") : Convert.ToString(startTime);
                queryParams.Add("startTime", paramStr);
            }
            if (endTime != null)
            {
                string paramStr = (endTime is DateTime) ? ((DateTime)(object)endTime).ToString("u") : Convert.ToString(endTime);
                queryParams.Add("endTime", paramStr);
            }
            try {
                if (typeof(List <Quote>) == typeof(byte[]))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    return(((object)response) as List <Quote>);
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((List <Quote>)ApiInvoker.deserialize(response, typeof(List <Quote>)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Move a specific file. Move a specific file.
        /// </summary>
        /// <param name="src">source file path e.g. /file.ext</param>
        /// <param name="dest"></param>
        /// <param name="versionId">source file's version,</param>
        /// <param name="storage">user's source storage name</param>
        /// <param name="destStorage">user's destination storage name</param>
        /// <returns></returns>
        public MoveFileResponse PostMoveFile(string src, string dest, string versionId, string storage, string destStorage)
        {
            // create path and map variables
            var ResourcePath = "/storage/file/{src}/?dest={dest}&amp;appSid={appSid}&amp;versionId={versionId}&amp;storage={storage}&amp;destStorage={destStorage}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (src == null || dest == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (src == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])src=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "src" + "}", apiInvoker.ToPathValue(src));
            }
            if (dest == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])dest=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "dest" + "}", apiInvoker.ToPathValue(dest));
            }
            if (versionId == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])versionId=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "versionId" + "}", apiInvoker.ToPathValue(versionId));
            }
            if (storage == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage));
            }
            if (destStorage == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])destStorage=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "destStorage" + "}", apiInvoker.ToPathValue(destStorage));
            }
            try {
                if (typeof(MoveFileResponse) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "GET", queryParams, null, headerParams, formParams);
                    return((MoveFileResponse)ApiInvoker.deserialize(response, typeof(MoveFileResponse)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((MoveFileResponse)ApiInvoker.deserialize(response, typeof(MoveFileResponse)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Create a new API Key. API Keys can also be created via&lt;a href=&quot;https://github.com/BitMEX/market-maker/blob/master/generate-api-key.py&quot;&gt;this Python script&lt;/a&gt;.
        /// </summary>
        /// <param name="name">Key name. This name is for reference only.</param>
        /// <param name="cidr">CIDR block to restrict this key to. To restrict to a single address, append &quot;/32&quot;, e.g. 207.39.29.22/32. Leave blank or set to 0.0.0.0/0 to allow all IPs. Only one block may be set. &lt;a href=&quot;http://software77.net/cidr-101.html&quot;&gt;More on CIDR blocks&lt;/a&gt;</param>
        /// <param name="enabled">Set to true to enable this key on creation. Otherwise, it must be explicitly enabled via /apiKey/enable.</param>
        /// <returns></returns>
        public ApiKey createKey(string name, string cidr, bool?enabled)
        {
            // create path and map variables
            var path = "/apiKey".Replace("{format}", "json");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            if (name != null)
            {
                if (name is byte[])
                {
                    formParams.Add("name", name);
                }
                else
                {
                    string paramStr = (name is DateTime) ? ((DateTime)(object)name).ToString("u") : Convert.ToString(name);
                    formParams.Add("name", paramStr);
                }
            }
            if (cidr != null)
            {
                if (cidr is byte[])
                {
                    formParams.Add("cidr", cidr);
                }
                else
                {
                    string paramStr = (cidr is DateTime) ? ((DateTime)(object)cidr).ToString("u") : Convert.ToString(cidr);
                    formParams.Add("cidr", paramStr);
                }
            }
            if (enabled != null)
            {
                if (enabled is byte[])
                {
                    formParams.Add("enabled", enabled);
                }
                else
                {
                    string paramStr = (enabled is DateTime) ? ((DateTime)(object)enabled).ToString("u") : Convert.ToString(enabled);
                    formParams.Add("enabled", paramStr);
                }
            }
            try {
                if (typeof(ApiKey) == typeof(byte[]))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
                    return(((object)response) as ApiKey);
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((ApiKey)ApiInvoker.deserialize(response, typeof(ApiKey)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Recognize image text from some url if provided or from the request body content, language can be selected, default dictionaries can be used for correction. Recognize image text from some url if provided or from the request body content, language can be selected, default dictionaries can be used for correction.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="language"></param>
        /// <param name="useDefaultDictionaries"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public OCRResponse PostOcrFromUrlOrContent(string url, string language, bool?useDefaultDictionaries, byte[] file)
        {
            // create path and map variables
            var ResourcePath = "/ocr/recognize/?appSid={appSid}&amp;url={url}&amp;language={language}&amp;useDefaultDictionaries={useDefaultDictionaries}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (!(file == null ^ url == null))
            {
                throw new ApiException(400, "missing required params");
            }
            if (url == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])url=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "url" + "}", apiInvoker.ToPathValue(url));
            }
            if (language == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])language=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "language" + "}", apiInvoker.ToPathValue(language));
            }
            if (useDefaultDictionaries == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])useDefaultDictionaries=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "useDefaultDictionaries" + "}", apiInvoker.ToPathValue(useDefaultDictionaries));
            }
            if (file != null)
            {
                if (file is byte[])
                {
                    var docFile = new FileInfo();
                    docFile.file     = file;
                    docFile.MimeType = "application/octet-stream";
                    formParams.Add("file", docFile);
                }
                else
                {
                    //string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file);
                    string paramStr = Convert.ToString(file);
                    formParams.Add("file", paramStr);
                }
            }
            try {
                if (typeof(OCRResponse) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams);
                    return((OCRResponse)ApiInvoker.deserialize(response, typeof(OCRResponse)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((OCRResponse)ApiInvoker.deserialize(response, typeof(OCRResponse)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// Recognition of a barcode from file on server with parameters in body. Recognition of a barcode from file on server with parameters in body.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <param name="folder"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public BarcodeResponseList PutBarcodeRecognizeFromBody(string name, string type, string folder, BarcodeReader body)
        {
            // create path and map variables
            var ResourcePath = "/barcode/{name}/recognize/?appSid={appSid}&amp;type={type}&amp;folder={folder}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (name == null || body == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (name == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])name=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "name" + "}", apiInvoker.ToPathValue(name));
            }
            if (type == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])type=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "type" + "}", apiInvoker.ToPathValue(type));
            }
            if (folder == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder));
            }
            try {
                if (typeof(BarcodeResponseList) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams);
                    return((BarcodeResponseList)ApiInvoker.deserialize(response, typeof(BarcodeResponseList)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "PUT", queryParams, body, headerParams, formParams);
                    if (response != null)
                    {
                        return((BarcodeResponseList)ApiInvoker.deserialize(response, typeof(BarcodeResponseList)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// Generate image with multiple barcodes and put new file on server Generate image with multiple barcodes and put new file on server
        /// </summary>
        /// <param name="name"></param>
        /// <param name="format"></param>
        /// <param name="folder"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public SaaSposeResponse PutGenerateMultiple(string name, string format, string folder, BarcodeBuilders body)
        {
            // create path and map variables
            var ResourcePath = "/barcode/{name}/generateMultiple/?appSid={appSid}&amp;toFormat={toFormat}&amp;folder={folder}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (name == null || body == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (name == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])name=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "name" + "}", apiInvoker.ToPathValue(name));
            }
            if (format == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])format=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "format" + "}", apiInvoker.ToPathValue(format));
            }
            if (folder == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder));
            }
            //if (file != null){
            // if(file is byte[]) {

            //     var docFile = new FileInfo();
            //     docFile.file = file;
            //     docFile.MimeType = "application/octet-stream";
            //     formParams.Add("file", docFile);
            // } else {
            //   //string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file);
            //    string paramStr = Convert.ToString(file);
            //   formParams.Add("file", paramStr);
            // }
            //}
            try {
                if (typeof(SaaSposeResponse) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams);
                    return((SaaSposeResponse)ApiInvoker.deserialize(response, typeof(SaaSposeResponse)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "PUT", queryParams, body, headerParams, formParams);
                    if (response != null)
                    {
                        return((SaaSposeResponse)ApiInvoker.deserialize(response, typeof(SaaSposeResponse)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// Generate barcode and save on server. Generate barcode and save on server.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="text"></param>
        /// <param name="type"></param>
        /// <param name="format"></param>
        /// <param name="resolutionX"></param>
        /// <param name="resolutionY"></param>
        /// <param name="dimensionX"></param>
        /// <param name="dimensionY"></param>
        /// <param name="codeLocation"></param>
        /// <param name="grUnit"></param>
        /// <param name="autoSize"></param>
        /// <param name="barHeight"></param>
        /// <param name="imageHeight"></param>
        /// <param name="imageWidth"></param>
        /// <param name="imageQuality"></param>
        /// <param name="rotAngle"></param>
        /// <param name="topMargin"></param>
        /// <param name="bottomMargin"></param>
        /// <param name="leftMargin"></param>
        /// <param name="rightMargin"></param>
        /// <param name="enableChecksum"></param>
        /// <param name="storage"></param>
        /// <param name="folder"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public SaaSposeResponse PutBarcodeGenerateFile(string name, string text, string type, string format, float?resolutionX, float?resolutionY, float?dimensionX, float?dimensionY, string codeLocation, string grUnit, string autoSize, float?barHeight, float?imageHeight, float?imageWidth, string imageQuality, float?rotAngle, float?topMargin, float?bottomMargin, float?leftMargin, float?rightMargin, string enableChecksum, string storage, string folder, byte[] file)
        {
            // create path and map variables
            var ResourcePath = "/barcode/{name}/generate/?appSid={appSid}&amp;text={text}&amp;type={type}&amp;toFormat={toFormat}&amp;resolutionX={resolutionX}&amp;resolutionY={resolutionY}&amp;dimensionX={dimensionX}&amp;dimensionY={dimensionY}&amp;codeLocation={codeLocation}&amp;grUnit={grUnit}&amp;autoSize={autoSize}&amp;barHeight={barHeight}&amp;imageHeight={imageHeight}&amp;imageWidth={imageWidth}&amp;imageQuality={imageQuality}&amp;rotAngle={rotAngle}&amp;topMargin={topMargin}&amp;bottomMargin={bottomMargin}&amp;leftMargin={leftMargin}&amp;rightMargin={rightMargin}&amp;enableChecksum={enableChecksum}&amp;storage={storage}&amp;folder={folder}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (name == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (name == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])name=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "name" + "}", apiInvoker.ToPathValue(name));
            }
            if (text == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])text=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "text" + "}", apiInvoker.ToPathValue(text));
            }
            if (type == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])type=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "type" + "}", apiInvoker.ToPathValue(type));
            }
            if (format == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])format=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "format" + "}", apiInvoker.ToPathValue(format));
            }
            if (resolutionX == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])resolutionX=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "resolutionX" + "}", apiInvoker.ToPathValue(resolutionX));
            }
            if (resolutionY == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])resolutionY=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "resolutionY" + "}", apiInvoker.ToPathValue(resolutionY));
            }
            if (dimensionX == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])dimensionX=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "dimensionX" + "}", apiInvoker.ToPathValue(dimensionX));
            }
            if (dimensionY == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])dimensionY=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "dimensionY" + "}", apiInvoker.ToPathValue(dimensionY));
            }
            if (codeLocation == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])codeLocation=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "codeLocation" + "}", apiInvoker.ToPathValue(codeLocation));
            }
            if (grUnit == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])grUnit=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "grUnit" + "}", apiInvoker.ToPathValue(grUnit));
            }
            if (autoSize == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])autoSize=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "autoSize" + "}", apiInvoker.ToPathValue(autoSize));
            }
            if (barHeight == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])barHeight=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "barHeight" + "}", apiInvoker.ToPathValue(barHeight));
            }
            if (imageHeight == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])imageHeight=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "imageHeight" + "}", apiInvoker.ToPathValue(imageHeight));
            }
            if (imageWidth == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])imageWidth=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "imageWidth" + "}", apiInvoker.ToPathValue(imageWidth));
            }
            if (imageQuality == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])imageQuality=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "imageQuality" + "}", apiInvoker.ToPathValue(imageQuality));
            }
            if (rotAngle == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rotAngle=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rotAngle" + "}", apiInvoker.ToPathValue(rotAngle));
            }
            if (topMargin == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])topMargin=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "topMargin" + "}", apiInvoker.ToPathValue(topMargin));
            }
            if (bottomMargin == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])bottomMargin=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "bottomMargin" + "}", apiInvoker.ToPathValue(bottomMargin));
            }
            if (leftMargin == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])leftMargin=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "leftMargin" + "}", apiInvoker.ToPathValue(leftMargin));
            }
            if (rightMargin == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rightMargin=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rightMargin" + "}", apiInvoker.ToPathValue(rightMargin));
            }
            if (enableChecksum == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])enableChecksum=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "enableChecksum" + "}", apiInvoker.ToPathValue(enableChecksum));
            }
            if (storage == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage));
            }
            if (folder == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder));
            }
            if (file != null)
            {
                if (file is byte[])
                {
                    var docFile = new FileInfo();
                    docFile.file     = file;
                    docFile.MimeType = "application/octet-stream";
                    formParams.Add("file", docFile);
                }
                else
                {
                    //string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file);
                    string paramStr = Convert.ToString(file);
                    formParams.Add("file", paramStr);
                }
            }
            try {
                if (typeof(SaaSposeResponse) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams);
                    return((SaaSposeResponse)ApiInvoker.deserialize(response, typeof(SaaSposeResponse)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((SaaSposeResponse)ApiInvoker.deserialize(response, typeof(SaaSposeResponse)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Recognize image text, language and text region can be selected, default dictionaries can be used for correction. Recognize image text, language and text region can be selected, default dictionaries can be used for correction.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="language"></param>
        /// <param name="rectX"></param>
        /// <param name="rectY"></param>
        /// <param name="rectWidth"></param>
        /// <param name="rectHeight"></param>
        /// <param name="useDefaultDictionaries"></param>
        /// <param name="storage"></param>
        /// <param name="folder"></param>
        /// <returns></returns>
        public OCRResponse GetRecognizeDocument(string name, string language, int?rectX, int?rectY, int?rectWidth, int?rectHeight, bool?useDefaultDictionaries, string storage, string folder)
        {
            // create path and map variables
            var ResourcePath = "/ocr/{name}/recognize/?appSid={appSid}&amp;language={language}&amp;rectX={rectX}&amp;rectY={rectY}&amp;rectWidth={rectWidth}&amp;rectHeight={rectHeight}&amp;useDefaultDictionaries={useDefaultDictionaries}&amp;storage={storage}&amp;folder={folder}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (name == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (name == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])name=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "name" + "}", apiInvoker.ToPathValue(name));
            }
            if (language == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])language=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "language" + "}", apiInvoker.ToPathValue(language));
            }
            if (rectX == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rectX=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rectX" + "}", apiInvoker.ToPathValue(rectX));
            }
            if (rectY == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rectY=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rectY" + "}", apiInvoker.ToPathValue(rectY));
            }
            if (rectWidth == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rectWidth=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rectWidth" + "}", apiInvoker.ToPathValue(rectWidth));
            }
            if (rectHeight == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rectHeight=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rectHeight" + "}", apiInvoker.ToPathValue(rectHeight));
            }
            if (useDefaultDictionaries == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])useDefaultDictionaries=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "useDefaultDictionaries" + "}", apiInvoker.ToPathValue(useDefaultDictionaries));
            }
            if (storage == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage));
            }
            if (folder == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder));
            }
            try {
                if (typeof(OCRResponse) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "GET", queryParams, null, headerParams, formParams);
                    return((OCRResponse)ApiInvoker.deserialize(response, typeof(OCRResponse)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "GET", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((OCRResponse)ApiInvoker.deserialize(response, typeof(OCRResponse)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #19
0
        /// <summary>
        /// Recognize barcode from an url. Recognize barcode from an url.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="checksumValidation"></param>
        /// <param name="stripFnc"></param>
        /// <param name="rotationAngle"></param>
        /// <param name="url"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public BarcodeResponseList PostBarcodeRecognizeFromUrlorContent(string type, string checksumValidation, bool?stripFnc, int?rotationAngle, string url, byte[] file)
        {
            // create path and map variables
            var ResourcePath = "/barcode/recognize/?appSid={appSid}&amp;type={type}&amp;checksumValidation={checksumValidation}&amp;stripFnc={stripFnc}&amp;rotationAngle={rotationAngle}&amp;url={url}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            //if (file == null ) {
            //   throw new ApiException(400, "missing required params");
            //}
            if (type == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])type=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "type" + "}", apiInvoker.ToPathValue(type));
            }
            if (checksumValidation == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])checksumValidation=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "checksumValidation" + "}", apiInvoker.ToPathValue(checksumValidation));
            }
            if (stripFnc == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])stripFnc=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "stripFnc" + "}", apiInvoker.ToPathValue(stripFnc));
            }
            if (rotationAngle == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rotationAngle=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rotationAngle" + "}", apiInvoker.ToPathValue(rotationAngle));
            }
            if (url == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])url=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "url" + "}", apiInvoker.ToPathValue(url));
            }
            if (file != null)
            {
                if (file is byte[])
                {
                    var docFile = new FileInfo();
                    docFile.file     = file;
                    docFile.MimeType = "application/octet-stream";
                    formParams.Add("file", docFile);
                }
                else
                {
                    //string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file);
                    string paramStr = Convert.ToString(file);
                    formParams.Add("file", paramStr);
                }
            }
            try {
                if (typeof(BarcodeResponseList) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams);
                    return((BarcodeResponseList)ApiInvoker.deserialize(response, typeof(BarcodeResponseList)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((BarcodeResponseList)ApiInvoker.deserialize(response, typeof(BarcodeResponseList)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #20
0
        /// <summary>
        /// Recognize barcode from a file on server. Recognize barcode from a file on server.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <param name="checksumValidation"></param>
        /// <param name="stripFnc"></param>
        /// <param name="rotationAngle"></param>
        /// <param name="barcodesCount"></param>
        /// <param name="rectX"></param>
        /// <param name="rectY"></param>
        /// <param name="rectWidth"></param>
        /// <param name="rectHeight"></param>
        /// <param name="storage"></param>
        /// <param name="folder"></param>
        /// <returns></returns>
        public BarcodeResponseList GetBarcodeRecognize(string name, string type, string checksumValidation, bool?stripFnc, int?rotationAngle, int?barcodesCount, int?rectX, int?rectY, int?rectWidth, int?rectHeight, string storage, string folder)
        {
            // create path and map variables
            var ResourcePath = "/barcode/{name}/recognize/?appSid={appSid}&amp;type={type}&amp;checksumValidation={checksumValidation}&amp;stripFnc={stripFnc}&amp;rotationAngle={rotationAngle}&amp;barcodesCount={barcodesCount}&amp;rectX={rectX}&amp;rectY={rectY}&amp;rectWidth={rectWidth}&amp;rectHeight={rectHeight}&amp;storage={storage}&amp;folder={folder}".Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&amp;", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}");

            // query params
            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();
            var formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (name == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (name == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])name=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "name" + "}", apiInvoker.ToPathValue(name));
            }
            if (type == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])type=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "type" + "}", apiInvoker.ToPathValue(type));
            }
            if (checksumValidation == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])checksumValidation=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "checksumValidation" + "}", apiInvoker.ToPathValue(checksumValidation));
            }
            if (stripFnc == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])stripFnc=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "stripFnc" + "}", apiInvoker.ToPathValue(stripFnc));
            }
            if (rotationAngle == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rotationAngle=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rotationAngle" + "}", apiInvoker.ToPathValue(rotationAngle));
            }
            if (barcodesCount == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])barcodesCount=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "barcodesCount" + "}", apiInvoker.ToPathValue(barcodesCount));
            }
            if (rectX == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rectX=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rectX" + "}", apiInvoker.ToPathValue(rectX));
            }
            if (rectY == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rectY=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rectY" + "}", apiInvoker.ToPathValue(rectY));
            }
            if (rectWidth == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rectWidth=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rectWidth" + "}", apiInvoker.ToPathValue(rectWidth));
            }
            if (rectHeight == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])rectHeight=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "rectHeight" + "}", apiInvoker.ToPathValue(rectHeight));
            }
            if (storage == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage));
            }
            if (folder == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder));
            }
            try {
                if (typeof(BarcodeResponseList) == typeof(ResponseMessage))
                {
                    var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "GET", queryParams, null, headerParams, formParams);
                    return((BarcodeResponseList)ApiInvoker.deserialize(response, typeof(BarcodeResponseList)));
                }
                else
                {
                    var response = apiInvoker.invokeAPI(basePath, ResourcePath, "GET", queryParams, null, headerParams, formParams);
                    if (response != null)
                    {
                        return((BarcodeResponseList)ApiInvoker.deserialize(response, typeof(BarcodeResponseList)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (ApiException ex) {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #21
0
        /// <summary>
        /// PostRunOmrTask
        /// </summary>
        /// <param name="name"></param>
        /// <param name="actionName"></param>
        /// <param name="functionParams"></param>
        /// <param name="additionalParams"></param>
        /// <param name="storage"></param>
        /// <param name="folder"></param>
        /// <returns></returns>
        public OMRResponse PostRunOmrTask(string name, string actionName, OMRFunctionParam functionParam,
                                          string storage, string folder)
        {
            // create path and map variables
            string ResourcePath =
                "/omr/{name}/runOmrTask/?appSid={appSid}&amp;actionName={actionName}&amp;storage={storage}&amp;folder={folder}"
                .Replace("{format}", "json");

            ResourcePath = Regex.Replace(ResourcePath, "\\*", "")
                           .Replace("&amp;", "&")
                           .Replace("/?", "?")
                           .Replace("toFormat={toFormat}", "format={format}");

            // query params
            Dictionary <string, string> queryParams  = new Dictionary <String, String>();
            Dictionary <string, string> headerParams = new Dictionary <String, String>();
            Dictionary <string, object> formParams   = new Dictionary <String, object>();

            // verify required params are set
            if (name == null)
            {
                throw new ApiException(400, "missing required params");
            }
            if (name == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])name=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "name" + "}", apiInvoker.ToPathValue(name));
            }
            if (actionName == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])actionName=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "actionName" + "}", apiInvoker.ToPathValue(actionName));
            }
            if (storage == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage));
            }
            if (folder == null)
            {
                ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", "");
            }
            else
            {
                ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder));
            }
            try
            {
                if (typeof(OMRResponse) == typeof(ResponseMessage))
                {
                    byte[] response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "POST", queryParams,
                                                                 functionParam, headerParams, formParams);
                    return((OMRResponse)ApiInvoker.deserialize(response, typeof(OMRResponse)));
                }
                else
                {
                    string response = apiInvoker.invokeAPI(basePath, ResourcePath, "POST", queryParams, functionParam,
                                                           headerParams, formParams);
                    if (response != null)
                    {
                        return((OMRResponse)ApiInvoker.deserialize(response, typeof(OMRResponse)));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
        }