/// <summary> /// Submits a series of jobs for translation /// </summary> /// <param name="requireSameTranslator"> /// Wether the jobs may be split among several translators /// </param> /// <param name="allowTranslatorChange"> /// Wether Gengo may assign a new translator if the original /// becomes unavailable /// </param> /// <param name="jobs">Jobs for translation</param> /// <returns>Task yielding the resulting order /// </returns> public async Task <Confirmation> Submit( bool requireSameTranslator, bool allowTranslatorChange, IEnumerable <Job> jobs) { if (jobs == null) { throw new ArgumentNullException("jobs"); } var tpl = jobs.ToJsonJobsList(); var jobsObj = tpl.Item1; var mapping = tpl.Item2; if (!jobsObj.HasValues) { throw new ArgumentException( Resources.AtLeastOneJobRequired); } var payload = new JObject(); payload["jobs"] = jobsObj; payload["as_group"] = Convert.ToInt32(requireSameTranslator); payload["allow_fork"] = Convert.ToInt32(allowTranslatorChange); var response = await _client.PostJsonAsync <JObject>( UriPartJobsEndpoint, payload); return(new Confirmation(mapping, response)); }
/// <summary> /// Posts a new comment /// </summary> /// <param name="jobID">The job ID</param> /// <param name="body">Comment body (mandatory)</param> /// <returns>Task yielding no value</returns> public async Task PostComment(int jobID, string body) { if (String.IsNullOrWhiteSpace(body)) { throw new ArgumentException("Comment body not provided", "body"); } var json = new JObject(new JProperty("body", body)); await _client.PostJsonAsync <JToken>(string.Format(UriPartComment, jobID), json); }
/// <summary> /// Gets a price quote for a sequence of jobs /// </summary> /// <param name="requireSameTranslator"> /// Wether the jobs may be split among several translators /// </param> /// <param name="jobs">Jobs to get quote for</param> /// <returns>Task yielding job quotes</returns> public async Task <Quote[]> GetQuote( bool requireSameTranslator, IEnumerable <Job> jobs) { if (jobs == null) { throw new ArgumentNullException("jobs"); } var payload = new JObject(); payload["jobs"] = jobs.ToJsonJobsArray(); payload["as_group"] = Convert.ToInt32(requireSameTranslator); var response = await _client.PostJsonAsync <JObject>( UriPartQuote, payload); var quotes = response.Value <JArray>("jobs"); return(quotes.Select(o => new Quote((JObject)o)).ToArray()); }