async public Task <dynamic> PairsAsync(string srtName) { string url = String.Format("ai/text/translate/routing/{0}/pairs", srtName); dynamic jsonResult; using (HttpConnector conn = new HttpConnector(Intento)) jsonResult = await conn.GetAsync(url); return(jsonResult); }
/// <summary> /// Detailed information on provider features /// </summary> /// <param name="provider">Provider id</param> /// <returns>dynamic (json) with requested information</returns> async public Task <dynamic> ProviderAsync(string providerId, Dictionary <string, string> additionalParams = null) { string path = string.Format("ai/text/translate/{0}", providerId); dynamic jsonResult; // Call to Intento API and get json result using (HttpConnector conn = new HttpConnector(Intento)) jsonResult = await conn.GetAsync(path, additionalParams : additionalParams); return(jsonResult); }
async public Task <IList <dynamic> > ProvidersAsync(string to = null, string from = null, bool lang_detect = false, bool bulk = false, Dictionary <string, string> filter = null) { Dictionary <string, string> f = filter == null ? new Dictionary <string, string>() : new Dictionary <string, string>(filter); if (!string.IsNullOrEmpty(to)) { f["to"] = to; } if (!string.IsNullOrEmpty(from)) { f["from"] = from; } if (lang_detect) { f["lang_detect"] = "true"; } if (bulk) { f["bulk"] = "true"; } List <string> p = new List <string>(); foreach (KeyValuePair <string, string> pair in f) { p.Add(string.Format("{0}={1}", pair.Key, HttpUtility.UrlEncode(pair.Value))); } string url = "ai/text/translate"; if (p.Count != 0) { url += "?" + string.Join("&", p); } dynamic jsonResult; // Call to Intento API and get json result using (HttpConnector conn = new HttpConnector(Intento)) jsonResult = await conn.GetAsync(url); List <dynamic> providers = new List <dynamic>(); foreach (dynamic providerInfo in jsonResult) { providers.Add(providerInfo); } return(providers); }
/// <summary> /// Detailed information on provider features /// </summary> /// <param name="provider">Provider id</param> /// <returns>dynamic (json) with requested information</returns> async public Task <dynamic> ProviderAsync(string providerId, string additionalParams = null) { string path = string.Format("ai/text/translate/{0}", providerId); if (additionalParams != null) { path += additionalParams; } // Call to Intento API and get json result HttpConnector conn = new HttpConnector(Intento); dynamic jsonResult = await conn.GetAsync(path); return(jsonResult); }
async public Task <dynamic> CheckAsyncJobAsync(string asyncId) { // Open connection to Intento API and set ApiKey Log(string.Format("CheckAsyncJobAsync-1: {0}ms", asyncId)); HttpConnector client = new HttpConnector(this); Log(string.Format("CheckAsyncJobAsync-2: {0}ms", asyncId)); // async operations inside Log(string.Format("CheckAsyncJobAsync-3: {0}ms", asyncId)); dynamic result = await client.GetAsync(string.Format("operations/{0}", asyncId)); Log(string.Format("CheckAsyncJobAsync-4: {0}ms", asyncId)); return(result); }
async public Task <IList <dynamic> > LanguagesAsync() { string url = "ai/text/translate/languages"; // Call to Intento API and get json result HttpConnector conn = new HttpConnector(Intento); dynamic jsonResult = await conn.GetAsync(url); List <dynamic> languages = new List <dynamic>(); foreach (dynamic languageInfo in jsonResult) { languages.Add(languageInfo); } return(languages); }
public async Task <IList <dynamic> > AgnosticGlossariesTypesAsync() { var path = $"ai/text/glossaries/v2/cs_types"; dynamic jsonResult; // Call to Intento API and get json result using (HttpConnector conn = new HttpConnector(Intento)) { jsonResult = await conn.GetAsync(path); } var types = new List <dynamic>(); foreach (dynamic type in jsonResult.types) { types.Add(type); } return(types); }
async public Task <IList <dynamic> > DelegatedCredentialsAsync(Dictionary <string, string> additionalParams = null) { string path = "delegated_credentials"; dynamic jsonResult; // Call to Intento API and get json result using (HttpConnector conn = new HttpConnector(Intento)) jsonResult = await conn.GetAsync(path, additionalParams : additionalParams); List <dynamic> credentials = new List <dynamic>(); foreach (dynamic credential in jsonResult) { credentials.Add(credential); } return(credentials); }
/// <summary> /// Details of the models stored by the provider /// </summary> /// <param name="provider">Provider id</param> /// <param name="additionalParams">additional url params</param> /// <returns>dynamic (json) with requested information</returns> async public Task <IList <dynamic> > RoutingAsync(Dictionary <string, string> additionalParams = null) { string path = "ai/text/translate/routing"; dynamic jsonResult; // Call to Intento API and get json result using (HttpConnector conn = new HttpConnector(Intento)) jsonResult = await conn.GetAsync(path, additionalParams : additionalParams); List <dynamic> models = new List <dynamic>(); foreach (dynamic model in ((JContainer)jsonResult).First.First) { models.Add(model); } return(models); }
/// <summary> /// Details of the models stored by the provider /// </summary> /// <param name="provider">Provider id</param> /// <param name="additionalParams">additional url params</param> /// <returns>dynamic (json) with requested information</returns> async public Task <IList <dynamic> > AccountsAsync(string providerId = null, Dictionary <string, string> additionalParams = null) { string path = string.Format("accounts" + (providerId != null ? $"?provider={providerId}" : null)); dynamic jsonResult; // Call to Intento API and get json result using (HttpConnector conn = new HttpConnector(Intento)) jsonResult = await conn.GetAsync(path, additionalParams : additionalParams); List <dynamic> models = new List <dynamic>(); foreach (dynamic model in ((JContainer)jsonResult).First.First) { models.Add(model); } return(models); }
/// <summary> /// Get a list of available delegated credentials /// </summary> /// <param name="additionalParams">additional url params</param> /// <returns>dynamic (json) with requested information</returns> async public Task <IList <dynamic> > DelegatedCredentialsAsync(string additionalParams = null) { string path = "delegated_credentials"; if (additionalParams != null) { path += additionalParams; } // Call to Intento API and get json result HttpConnector conn = new HttpConnector(Intento); dynamic jsonResult = await conn.GetAsync(path); List <dynamic> credentials = new List <dynamic>(); foreach (dynamic credential in jsonResult) { credentials.Add(credential); } return(credentials); }
/// <summary> /// Details of the glossaries stored by the provider /// </summary> /// <param name="provider">Provider id</param> /// <param name="credential_id">Credential id</param> /// <param name="additionalParams">additional url params</param> /// <returns>dynamic (json) with requested information</returns> async public Task <IList <dynamic> > GlossariesAsync(string providerId, Dictionary <string, string> credential_id, string additionalParams = null) { string path = string.Format("ai/text/translate/glossaries?provider={0}", providerId); if (credential_id != null) { string json; if (credential_id.Count != 0) { if (credential_id.Count == 1 && credential_id.ContainsKey("credential_id")) { json = credential_id["credential_id"]; } else { json = JsonConvert.SerializeObject(credential_id, Formatting.Indented); json = HttpUtility.UrlEncode(json); } path += String.Format("&credential_id={0}", json); } } if (additionalParams != null) { path += additionalParams; } // Call to Intento API and get json result HttpConnector conn = new HttpConnector(Intento); dynamic jsonResult = await conn.GetAsync(path); List <dynamic> glossaries = new List <dynamic>(); foreach (dynamic glossary in ((JContainer)jsonResult).First.First) { glossaries.Add(glossary); } return(glossaries); }
/// <summary> /// Details of the models stored by the provider /// </summary> /// <param name="provider">Provider id</param> /// <param name="credential_id">Credential id</param> /// <param name="additionalParams">additional url params</param> /// <returns>dynamic (json) with requested information</returns> async public Task <IList <dynamic> > ModelsAsync(string providerId, Dictionary <string, string> credentials, Dictionary <string, string> additionalParams = null) { string path = string.Format("ai/text/translate/models?provider={0}", providerId); if (credentials != null) { string json; if (credentials.Count != 0) { if (credentials.Count == 1 && credentials.ContainsKey("credential_id")) { json = credentials["credential_id"]; } else { json = JsonConvert.SerializeObject(credentials, Formatting.None); json = HttpUtility.UrlEncode(json); } path += String.Format("&credential_id={0}", json); } } dynamic jsonResult; // Call to Intento API and get json result using (HttpConnector conn = new HttpConnector(Intento)) jsonResult = await conn.GetAsync(path, additionalParams : additionalParams); List <dynamic> models = new List <dynamic>(); foreach (dynamic model in ((JContainer)jsonResult).First.First) { models.Add(model); } return(models); }