private HttpRequestMessage PrepareRequest(HttpMethod method, string path, BaseAuthenticatedPayload payload) { var uri = PrepareUri(path); var request = new HttpRequestMessage(method, uri); if (payload != null) { payload.BranchKey = _config.BranchKey; payload.BranchSecret = _config.BranchSecret; var json = _serializer.Serialize(payload); request.Content = new StringContent(json); } return(request); }
public Task <HttpResponseMessage> RequestAsync(HttpMethod method, string path, BaseAuthenticatedPayload payload) { try { var request = PrepareRequest(method, path, payload); return(GetClient().SendAsync(request, HttpCompletionOption.ResponseContentRead)); } catch (Exception ex) { throw new BranchException( string.Format("An error occured while execute request. Path : {0} , Method : {1}", path, method), ex); } }