Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions SaferPayClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public class SaferPayClient : ISaferPayClient
public SaferPayClient(SaferPaySettings settings) : this(settings, JsonSettings.Default) { }

public SaferPayClient(string customerId, string terminalId, string userName, string passWord, bool sandBox = false)
{
this._settings = new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox);
}
: this(new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox), JsonSettings.Default) { }

public SaferPayClient(SaferPaySettings settings, JsonSerializerSettings jsonSerializerSettings)
{
Expand Down Expand Up @@ -88,7 +86,7 @@ public virtual async Task<TResponse> SendAsync<TResponse, TRequest>(string path,
var opt = new RestClientOptions(uri);
opt.Authenticator = new HttpBasicAuthenticator(_settings.Username, _settings.Password);

var client = new RestClient(opt);
using var client = new RestClient(opt);
var req = new RestRequest();
req.Method = Method.Post;

Expand Down Expand Up @@ -131,7 +129,7 @@ public virtual async Task<TResponse> SendAsync<TResponse, TRequest>(string path,

if (_settings.ThrowExceptionOnFail)
{
throw spex;
throw;
}
}
catch (Exception ex)
Expand All @@ -146,7 +144,7 @@ public virtual async Task<TResponse> SendAsync<TResponse, TRequest>(string path,
return response;
}

throw ex;
throw;

}

Expand All @@ -155,7 +153,8 @@ public virtual async Task<TResponse> SendAsync<TResponse, TRequest>(string path,

public void Dispose()
{
this.Dispose();
// The client holds no long-lived disposable state. RestClient instances
// are created and disposed per request, so there is nothing to release here.
}

/// <summary>
Expand All @@ -177,7 +176,7 @@ public TResponse Send<TResponse, TRequest>(string path, TRequest request) where
var opt = new RestClientOptions(uri);
opt.Authenticator = new HttpBasicAuthenticator(_settings.Username, _settings.Password);

var client = new RestClient(opt);
using var client = new RestClient(opt);
var req = new RestRequest();
req.Method = Method.Post;

Expand Down Expand Up @@ -219,7 +218,7 @@ public async Task<TResponse> GetAsync<TResponse>(string path) where TResponse :
var opt = new RestClientOptions(uri);

opt.Authenticator = new HttpBasicAuthenticator(_settings.Username, _settings.Password);
var client = new RestClient(opt);
using var client = new RestClient(opt);

var req = new RestRequest();
req.Method = Method.Get;
Expand Down Expand Up @@ -294,7 +293,7 @@ public async Task<TResponse> GetAsync<TResponse, TRequest>(string path, TRequest
var opt = new RestClientOptions(_settings.BaseUri);

opt.Authenticator = new HttpBasicAuthenticator(_settings.Username, _settings.Password);
var client = new RestClient(opt);
using var client = new RestClient(opt);

var req = new RestRequest(path, Method.Get);

Expand Down Expand Up @@ -405,7 +404,7 @@ public async Task<TResponse> PostAsync<TResponse>(string path) where TResponse :
var opt = new RestClientOptions(uri);

opt.Authenticator = new HttpBasicAuthenticator(_settings.Username, _settings.Password);
var client = new RestClient(opt);
using var client = new RestClient(opt);

var req = new RestRequest();
req.Method = Method.Post;
Expand Down Expand Up @@ -480,7 +479,7 @@ public async Task<TResponse> PostAsync<TResponse, TRequest>(string path, TReques
var opt = new RestClientOptions(uri);

opt.Authenticator = new HttpBasicAuthenticator(_settings.Username, _settings.Password);
var client = new RestClient(opt);
using var client = new RestClient(opt);

var req = new RestRequest();
req.Method = Method.Post;
Expand Down Expand Up @@ -554,7 +553,7 @@ public async Task<TResponse> DeleteAsync<TResponse>(string path) where TResponse
var opt = new RestClientOptions(uri);

opt.Authenticator = new HttpBasicAuthenticator(_settings.Username, _settings.Password);
var client = new RestClient(opt);
using var client = new RestClient(opt);

// Client'ın sınıf düzeyinde tek bir instance olduğunu varsayıyoruz.
// Eğer metot içinde oluşturmak zorundaysanız bile RestRequest'i path ile başlatın.
Expand Down
Loading