forked from azmikamis/checkout-net-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPIClient.cs
62 lines (52 loc) · 1.97 KB
/
APIClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using Checkout.ApiServices.Cards;
using Checkout.ApiServices.Charges;
using Checkout.ApiServices.Customers;
using Checkout.ApiServices.Tokens;
using Checkout.Helpers;
namespace Checkout
{
public sealed class APIClient
{
private TokenService _tokenService;
private CustomerService _customerService;
private CardService _cardService;
private ChargeService _chargeService;
public ChargeService ChargeService { get { return _chargeService ?? (_chargeService = new ChargeService()); } }
public CardService CardService { get { return _cardService ?? (_cardService = new CardService()); } }
public CustomerService CustomerService { get { return _customerService ?? (_customerService = new CustomerService()); } }
public TokenService TokenService { get { return _tokenService ?? (_tokenService = new TokenService()); } }
public APIClient()
{
if (AppSettings.Environment == Environment.Undefined)
{
AppSettings.SetEnvironmentFromConfig();
}
ContentAdaptor.Setup();
}
public APIClient(string secretKey, Environment env, bool debugMode, int connectTimeout)
: this(secretKey, env, debugMode)
{
AppSettings.RequestTimeout = connectTimeout;
}
public APIClient(string secretKey, Environment env, bool debugMode)
: this(secretKey, env)
{
AppSettings.DebugMode = debugMode;
}
public APIClient(string secretKey, Environment env)
{
AppSettings.SecretKey = secretKey;
AppSettings.Environment = env;
ContentAdaptor.Setup();
}
public APIClient(string secretKey, bool debugMode)
: this(secretKey)
{
AppSettings.DebugMode = debugMode;
}
public APIClient(string secretKey):this()
{
AppSettings.SecretKey = secretKey;
}
}
}