private bool DeleteMsg(string MsgId) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs(); spark.Messages.Delete(MsgId, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(false); } if (response.IsSuccess == true) { return(true); } return(false); }
private static Person GetMe() { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <Person>(); spark.People.GetMe(rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess) { return(response.Data); } return(null); }
private bool DownloadThumbnail(RemoteFile file, string to) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs(); spark.Messages.DownloadThumbnail(file, to, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(false); } if (response.IsSuccess == true) { return(true); } return(false); }
public void AuthorizeTestInvalidJWT() { var completion = new ManualResetEvent(false); var auth = new JWTAuthenticator(); string jwt = "a.c"; var rspOfauth = new SparkApiEventArgs(); auth.AuthorizeWith(jwt, r => { rspOfauth = r; completion.Set(); }); if (false == completion.WaitOne(30000)) { Assert.Fail(); return; } Assert.IsFalse(rspOfauth.IsSuccess); }
private Message GetMsgByRoomIdAndMessageId(string roomId, string msgId) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <Message>(); spark.Messages.Get(roomId, msgId, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
public void AuthorizeTestInvalidJWTexpire() { var completion = new ManualResetEvent(false); var auth = new JWTAuthenticator(); //expired JWT string jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG5Eb2UiLCJleHAiOiIxNDA1OTc0ODczIiwiaXNzIjoiY2Q1YzlhZjctOGVkMy00ZTE1LTk3MDUtMDI1ZWYzMGIxYjZhIn0.brzUE0LYgEIkt4kK7s2QwrHkhgWPUwbj5XMVECAA_hQ"; var rspOfauth = new SparkApiEventArgs(); auth.AuthorizeWith(jwt, r => { rspOfauth = r; completion.Set(); }); if (false == completion.WaitOne(30000)) { Assert.Fail(); return; } Assert.IsFalse(rspOfauth.IsSuccess); }
private Membership UpdateMembership(string memshipId, bool isModerator) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <Membership>(); memberships.Update(memshipId, isModerator, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
private Room GetRoom(string roomId) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <Room>(); room.Get(roomId, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
private List <Membership> ListMembership(int?max = null) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <List <Membership> >(); memberships.List(max, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
private List <Membership> ListMembershipByEmail(string roomId, string email) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <List <Membership> >(); memberships.ListByPersonEmail(roomId, email, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
private Team UpdateTeam(string teamId, string name) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <Team>(); spark.Teams.Update(teamId, name, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
private bool DeleteMembership(string membershipId) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs(); memberships.Delete(membershipId, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(false); } if (response.IsSuccess == true) { return(true); } return(false); }
public Room CreateRoom(string title) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <Room>(); spark.Rooms.Create(title, null, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
private TeamMembership GetTeamMembership(string membershipId) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <TeamMembership>(); teamMemberships.Get(membershipId, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
public bool DeleteTeam(string teamId) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs(); spark.Teams.Delete(teamId, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(false); } if (response.IsSuccess == true) { return(true); } return(false); }
private List <Room> ListRooms(string teamId = null, int?max = null, RoomType?roomType = null) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <List <Room> >(); room.List(teamId, max, roomType, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
private bool DeleteWebHook(string webhookId) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs(); webhooks.Delete(webhookId, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(false); } if (response.IsSuccess == true) { return(true); } return(false); }
private Webhook UpdateWebHook(string webhookId, string name, string targetUrl) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <Webhook>(); webhooks.Update(webhookId, name, targetUrl, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
private Webhook CreateWebHook() { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <Webhook>(); webhooks.Create("test webhook", "https://example.com/test_webhook", "messages", "created", string.Format("roomId=" + myRoom.Id), null, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
public void GetMeTest() { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <Person>(); person.GetMe(rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { Assert.Fail(); return; } Assert.IsTrue(response.IsSuccess); Person me = response.Data; Assert.AreEqual(fixture.selfUser.Email, me.Emails[0]); Assert.AreEqual(fixture.selfUser.Name, me.DisplayName); Assert.AreEqual(fixture.selfUser.PersonId, me.Id); }
private List <Message> ListMsg(string roomId, string before = null, string beforeMsg = null, int?max = null) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <List <Message> >(); spark.Messages.List(roomId, before, beforeMsg, max, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { Console.WriteLine("listMsg outof time"); return(null); } if (response.IsSuccess == true) { return(response.Data); } Console.WriteLine($"listMsg faile {response.Error?.ErrorCode} {response.Error?.Reason}"); return(null); }
private bool Login(JWTAuthenticator auth) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs(); if (auth == null) { Console.WriteLine("jwt login: auth is null"); return(false); } auth.AuthorizeWith(jwt, r => { response = r; completion.Set(); }); if (false == completion.WaitOne(30000)) { Console.WriteLine("jwt login: timeout"); return(false); } Console.WriteLine($"jwt login: success is {response.IsSuccess}"); return(response.IsSuccess); }
public void ExecuteResponse401UnAuthorizedTest() { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <JWTAccessTokenInfo>(); var request = ServiceRequest401ResponseConfig(); request.Execute <JWTAccessTokenInfo>((r) => { response = r; completion.Set(); }); if (false == completion.WaitOne(30000)) { Console.WriteLine("Execute timeout."); Assert.Fail(); return; } Assert.IsFalse(response.IsSuccess); Assert.IsTrue(response.Error.ErrorCode == SparkErrorCode.ServiceFailed); Assert.IsTrue(response.Error.Reason == "401"); Assert.IsTrue(request.m401RetryCount == 2); }