public static NtxToken call(AccessToken accessToken, string taskId, string taskLabel) { using (RESTLongConnection wc = new RESTLongConnection()) { wc.Headers.Add("ntx-token", accessToken.accessToken); var data = Newtonsoft.Json.JsonConvert.SerializeObject( new { id = taskId, //"ntx.v2t.engine.EngineService/cz/t-broadcast/v2t", label = taskLabel //"vad+v2t+ppc+pnc", } ); var ntxToken = Newtonsoft.Json.JsonConvert.DeserializeObject <NtxToken>(wc.UploadString(accessToken.Audience + "store/ntx-token", data)); ntxToken.accessToken = accessToken; ntxToken.TaskId = taskId; ntxToken.TaskLabel = taskLabel; return(ntxToken); } }
private static AccessToken call(string username, string password, string audience) { using (RESTLongConnection wc = new RESTLongConnection()) { wc.Headers[HttpRequestHeader.ContentType] = "application/json"; var data = Newtonsoft.Json.JsonConvert.SerializeObject( new { username = username, password = password, } ); var res = wc.UploadString(audience + "login/access-token", data); var accessToken = Newtonsoft.Json.JsonConvert.DeserializeObject <AccessToken>(res); accessToken.Audience = audience; accessToken.username = username; accessToken.password = password; return(accessToken); } }
public bool Convert() { if (mp3file == null) { throw new ArgumentNullException("mp3file", "is null"); } if (System.IO.File.Exists(mp3file) == false) { throw new ArgumentNullException("mp3file", "no file on path " + mp3file); } using (RESTLongConnection wc = new RESTLongConnection()) { string url = this.accessToken.Audience + "api/v1/file/v2t"; wc.Headers.Add("ntx-token", ntxToken.ntxToken); var resbyte = wc.UploadFile(url, "POST", this.mp3file); var res = System.Text.Encoding.UTF8.GetString(resbyte); converted = true; this.Raw = res; this.Chunks = RawToChunks(this.Raw); this.Terms = ChunksToTerms(this.Chunks); } return(true); }