public async Task <AiurCollection <ContactInfo> > AllAsync() { var url = new AiurUrl(_kahlaLocation.ToString(), "Conversation", "All", new { }); var result = await _http.Get(url); var jsonResult = JsonConvert.DeserializeObject <AiurCollection <ContactInfo> >(result); if (jsonResult.Code != ErrorType.Success) { throw new AiurUnexceptedResponse(jsonResult); } return(jsonResult); }
public async Task CompleteRequestAsync(int requestId, bool accept) { var url = new AiurUrl(_kahlaLocation.ToString(), "Friendship", "CompleteRequest", new { }); var form = new AiurUrl(string.Empty, new CompleteRequestAddressModel { Id = requestId, Accept = accept }); var result = await _http.Post(url, form); var jsonResult = JsonConvert.DeserializeObject <AiurValue <AiurProtocol> >(result); if (jsonResult.Code != ErrorType.Success) { throw new AiurUnexceptedResponse(jsonResult); } }
public async Task <AiurValue <int> > JoinGroupAsync(string groupName, string joinPassword) { var url = new AiurUrl(_kahlaLocation.ToString(), "Groups", "JoinGroup", new { }); var form = new AiurUrl(string.Empty, new { groupName, joinPassword }); var result = await _http.Post(url, form); var jResult = JsonConvert.DeserializeObject <AiurValue <int> >(result); if (jResult.Code != ErrorType.Success) { throw new AiurUnexpectedResponse(jResult); } return(jResult); }
public async Task <string> OAuthAsync() { var url = new AiurUrl(_kahlaLocation.ToString(), "Auth", "OAuth", new { }); var result = await _http.Track(url); return(result); }
public async Task <IndexViewModel> IndexAsync() { var url = new AiurUrl(_kahlaLocation.ToString(), "Home", "Index", new { }); var result = await _http.Get(url); var JResult = JsonConvert.DeserializeObject <IndexViewModel>(result); if (JResult.Code != ErrorType.Success) { throw new AiurUnexceptedResponse(JResult); } return(JResult); }
public async Task <InitFileAccessViewModel> InitFileAccessAsync(int conversationId, bool canUpload, bool canDownload) { var url = new AiurUrl(_kahlaLocation.ToString(), "Storage", "InitFileAccess", new InitFileAccessAddressModel { ConversationId = conversationId, Upload = canUpload, Download = canDownload }); var result = await Http.Get(url); var jResult = JsonConvert.DeserializeObject <InitFileAccessViewModel>(result); if (jResult.Code != ErrorType.Success) { throw new AiurUnexpectedResponse(jResult); } return(jResult); }
public async Task <AiurValue <Message> > SendMessageAsync(string content, int conversationId) { var url = new AiurUrl(_kahlaLocation.ToString(), "Conversation", "SendMessage", new { }); var form = new AiurUrl(string.Empty, new SendMessageAddressModel { Content = content, Id = conversationId, MessageId = Guid.NewGuid().ToString("N"), RecordTime = DateTime.UtcNow + TimeSpan.FromSeconds(0.7) }); var result = await _http.Post(url, form); var JResult = JsonConvert.DeserializeObject <AiurValue <Message> >(result); if (JResult.Code != ErrorType.Success) { throw new AiurUnexceptedResponse(JResult); } return(JResult); }