/// <summary> /// Internal constructor used for unit tests that initializes a new instance of the Tikkie API Client injecting the needed dependencies. /// Note that with this constructor the values of <see cref="Configuration"/> and <see cref="AuthorizationTokenInfo"/> will remain null. /// </summary> /// <param name="platformRequestsHandler">Used for injecting the PlatformRequestHandler</param> /// <param name="userRequestsHandler">Used for injecting the UserRequestHandler</param> /// <param name="paymentRequestsHandler">Used for injecting the PaymentRequestHandler</param> internal TikkieClient( IPlatformRequestsHandler platformRequestsHandler, IUserRequestsHandler userRequestsHandler, IPaymentRequestsHandler paymentRequestsHandler) { _platformRequestsHandler = platformRequestsHandler ?? throw new ArgumentNullException(nameof(platformRequestsHandler)); _userRequestsHandler = userRequestsHandler ?? throw new ArgumentNullException(nameof(userRequestsHandler)); _paymentRequestsHandler = paymentRequestsHandler ?? throw new ArgumentNullException(nameof(paymentRequestsHandler)); }
/// <summary> /// Initializes a new instance of the Tikkie API Client. /// </summary> /// <param name="apiKey">The API key that allows the usage of the Tikkie API.</param> /// <param name="privateKeyPath">The directory path where the RSA private key PEM file can be found.</param> /// <param name="useTestEnvironment">True if the connexion is made to the development/sandbox Tikkie API environment, false if it uses the production environment. False by default.</param> /// <exception cref="ArgumentException">If the API Key is null or empty.</exception> /// <exception cref="FileNotFoundException">If the private key pem file doesn't exist in the specified location.</exception> /// <exception cref="InvalidDataException">If the RSA private key PEM file cannot be read.</exception> public TikkieClient( string apiKey, string privateKeyPath, bool useTestEnvironment = false) { Configuration = new TikkieConfiguration(apiKey, privateKeyPath, useTestEnvironment); var authorizedRequestsHandler = new AuthorizedRequestsHandler(Configuration); AuthorizationTokenInfo = authorizedRequestsHandler.AuthorizationTokenInfo; _platformRequestsHandler = new PlatformRequestsHandler(authorizedRequestsHandler); _userRequestsHandler = new UserRequestsHandler(authorizedRequestsHandler); _paymentRequestsHandler = new PaymentRequestsHandler(authorizedRequestsHandler); }