/// <summary> /// Get an enumerable of chat rooms. /// </summary> /// <returns> Enumerable of chat rooms. </returns> public IEnumerable <ChatRoom> GetChatRooms() { // todo: take dto model and do this with mapping var rooms = _jsonServiceClient.Get <IEnumerable <ChatRoom> >("/ChatRoom/GetAll"); foreach (var room in rooms) { foreach (var message in room.ChatMessages) { message.User = room.Users.SingleOrDefault(i => i.Id == message.UserId); } } return(rooms); }
public void CheckServiceHealth_ShouldBeHealthy() { HealthCheckRequest request = new HealthCheckRequest(); Console.WriteLine($"Calling Health Check..."); try { _jsonClient.Get(request); } catch (WebServiceException ex) { IEnumerable <string> unresolvedDependencies = ex.ResponseStatus?.Errors?.Select(responseError => responseError.Message); if (unresolvedDependencies != null && unresolvedDependencies.Any()) { Console.WriteLine($"Found {unresolvedDependencies.Count()} unresolved dependencies"); foreach (string unresolvedDependency in unresolvedDependencies) { Console.WriteLine($"Dependency that was unresolved: {unresolvedDependency}"); } Assert.IsTrue(false); } else { Console.WriteLine($"Health check failed but no unresolved dependencies were found"); Assert.IsTrue(false); } return; } Console.WriteLine("Healthy Health Check Returned."); Assert.IsTrue(true); }
/// <summary> /// create a JSON clientrequest object /// post the request /// and parse the result /// </summary> /// <param name="url">basic url of rest service</param> /// <param name="request">specific request parameter of the API</param> public cJSON(string url, string request) { this._url = url; this._request = request; client = new JsonServiceClient(url); this._rss = JObject.Parse(client.Get <String>(this._request)); }
public ServiceModel.Types.ProductData GetProduct(int productId) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string parms = "excludes=taxonomy,price,promotion,bulk_ship,rating_and_review_reviews,rating_and_review_statistics,question_answer_statistics,available_to_promise_network,deep_red_labels"; string clientUri = string.Format("{0}?{1}", productId, parms); var response = _jsonServiceClient.Get <Messages.ReadRedskyProductInfoResponse>(clientUri); return(_redskyProductMapper.MapToInternalProductModel(response.product)); }
public cJSON(string url, string request, string username, string password) { this._url = url; this._request = request; client = new JsonServiceClient(url) { UserName = username, Password = password, }; this._rss = JObject.Parse(client.Get <String>(this._request)); }
/// <summary> /// Sometimes, Ingenia break their pattern of request/metaresponse for collections, and we stick to our standard request/response /// by simply parsing the dirty result and pushing it into our standardized response wrapper /// </summary> /// <typeparam name="TRequest"></typeparam> /// <typeparam name="TResponse"></typeparam> /// <param name="request"></param> /// <returns></returns> private TResponse DirtyGetWhatever <TRequest, TResponse>(TRequest request) { return(_jsonClient.Get <TResponse>(request)); }
/// <summary> /// Deletes a chat message. /// </summary> /// <param name="id"></param> public void Delete(int id) { _jsonServiceClient.Get <IReturnVoid>($"/ChatMessage/Delete/{id}"); }