protected T Process <T>(Uri requestUrl, HttpMethod httpMethod, object content = default(HttpContent), TrustedMerchant trustedMerchant = null) where T : class { try { var token = this.cache.GetTokenFromCache <PayUToken>(this.settings, this.clientFactory, trustedMerchant); var request = PayUClientRequestBuilder.BuildRequestMessage(requestUrl, httpMethod, token.AccessToken, content); var communicator = new PayUApiHttpCommunicator <T>(this.clientFactory, this.settings); return(communicator.Send(request)); } catch { throw; } }
protected async Task <T> ProcessAsync <T>(Uri requestUrl, HttpMethod httpMethod, CancellationToken ct, object content = default(HttpContent), TrustedMerchant trustedMerchant = null) where T : class { try { var token = await this.cache.GetTokenFromCacheAsync <PayUToken>(this.settings, this.clientFactory, trustedMerchant, ct); var request = PayUClientRequestBuilder.BuildRequestMessage(requestUrl, httpMethod, token.AccessToken, content); var communicator = new PayUApiHttpCommunicator <T>(this.clientFactory, this.settings); return(await communicator.SendAsync(request, ct)); } catch { throw; } }
public void BuildOAuthTokenUrl_DeleteMethod_CorrectBuildedRequest() { var result = PayUClientRequestBuilder.BuildRequestMessage(new Uri("http://localhost"), HttpMethod.Delete, "fakeToken"); this.AssertBuildRequestMessage(result, HttpMethod.Delete, false); }
public void BuildOAuthTokenUrl_PutMethod_CorrectBuildedRequest() { var result = PayUClientRequestBuilder.BuildRequestMessage(new Uri("http://localhost"), HttpMethod.Put, "fakeToken", new object()); this.AssertBuildRequestMessage(result, HttpMethod.Put, true); }