public ISerializer GetSerializer(ApiFormat format) { switch (format) { case ApiFormat.JSON: return(jsonSerializer); default: case ApiFormat.XML: return(xmlSerializer); } }
public string GetContentType(ApiFormat apiFormat) { switch (ApiFormat) { case Primitive.ApiFormat.JSON: return("application/json"); default: case Primitive.ApiFormat.XML: return("application/xml"); } }
public CampfireUrlBuilder(ISite campfireSite, ApiFormat format) { this.CampfireSite = campfireSite; switch (format) { case ApiFormat.Xml: Format = "xml"; break; default: Format = "json"; break; } }
public override System.Exception CreateApiException(ApiFormat format, string content, IResponse response) { try { var errors = GetSerializer(format).Deserialize <V2.Payload.Feed.Errors>(content); return(ApiException.Factory(errors, response)); } catch (Exception firstAttemptEx) { try { var errors = GetSerializer(format).Deserialize <V2.Payload.Feed.ErrorsWithoutNS>(content); return(ApiException.Factory(errors, response)); } catch (Exception secondAttempEx) { var exceptionList = new Exception[] { firstAttemptEx, secondAttempEx }; var aggrEx = new AggregateException("Unable to parse error response >" + content + "<", exceptionList); throw aggrEx; } } }
public void AddPayload(string payload, ApiFormat apiFormat) { HttpRequest.Content = new StringContent((string)payload, Encoding.UTF8, Config.GetContentType(ApiFormat)); }
public abstract System.Exception CreateApiException(ApiFormat format, string content, Base.Http.IResponse response);
public ISerializer GetSerializer(ApiFormat format) { return(serializerFactory.GetSerializer(format)); }
public ApiProxy(ApiFormat format) { _resourceRequester = new ResourceRequester(format, "http://localhost"); _representation = ResourceRequester.PerformRequest("/api"); }