/// <summary> /// Initializes a new instance of the <see cref="MollieClientBase" /> class. /// </summary> /// <param name="clientService">The client service.</param> /// <param name="options">The options.</param> /// <param name="logger">The logger.</param> protected MollieClientBase(IMollieClientService clientService, IOptions <MollieApiOptions> options, ILogger <MollieClientBase> logger) : base(logger) { Argument.IsNotNull(options); _clientService = clientService; _mollieApiOptions = options.Value; }
/// <summary> /// Initializes a new instance of the <see cref="MollieClientService" /> class. /// </summary> /// <param name="httpClientFactory">The HTTP client factory.</param> /// <param name="options">The options.</param> /// <param name="logger">The logger.</param> /// <param name="validatorService">The validator service.</param> public MollieClientService(IHttpClientFactory httpClientFactory, IOptions <MollieApiOptions> options, ILogger <MollieClientService> logger, IValidatorService validatorService = null) { Argument.IsNotNull(options); Argument.IsNotNullOrEmpty(options.Value?.ApiKey); _jsonConverterService = new JsonConverterService(); _httpClient = httpClientFactory.CreateClient(); _mollieApiOptions = options.Value; _logger = logger; _validatorService = validatorService ?? new ValidatorService(); }
/// <summary> /// Ensures the test API key. /// </summary> /// <param name="options">The options.</param> /// <exception cref="ArgumentException">Please enter you API key in the BaseMollieApiTestClass class</exception> /// <exception cref="ArgumentException">You should not run these tests on your live key!</exception> /// <autogeneratedoc /> private void EnsureTestApiKey(MollieApiOptions options) { if (string.IsNullOrEmpty(options.ApiKey)) { throw new ArgumentException("Please enter you API key in the BaseMollieApiTestClass class"); } if (!options.ApiKey.StartsWith("test")) { throw new ArgumentException("You should not run these tests on your live key!"); } }
/// <summary> /// Initializes a new instance of the <see cref="BaseApiTestFixture"/> class. /// </summary> /// <autogeneratedoc /> public BaseApiTestFixture() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); Configuration = builder.Build(); var services = new ServiceCollection(); services.Configure <MollieApiOptions>(Configuration.GetSection(nameof(MollieApiOptions))); var appSettings = new MollieApiOptions(); Configuration.GetSection(nameof(MollieApiOptions)).Bind(appSettings); services.AddPaymentGatewayMollie(); // Register all available forms services.AddTransient <PaymentClient>(); services.AddTransient <PaymentMethodClient>(); services.AddTransient <RefundClient>(); services.AddTransient <SubscriptionClient>(); services.AddTransient <MandateClient>(); services.AddTransient <CustomerClient>(); services.AddTransient <CustomerClient>(); services.AddTransient <ProfileClient>(); services.AddTransient <OrderClient>(); ServiceProvider = services.BuildServiceProvider(); ClientService = ServiceProvider.GetRequiredService <IMollieClientService>(); PaymentClient = ServiceProvider.GetRequiredService <PaymentClient>(); PaymentMethodClient = ServiceProvider.GetRequiredService <PaymentMethodClient>(); RefundClient = ServiceProvider.GetRequiredService <RefundClient>(); SubscriptionClient = ServiceProvider.GetRequiredService <SubscriptionClient>(); MandateClient = ServiceProvider.GetRequiredService <MandateClient>(); CustomerClient = ServiceProvider.GetRequiredService <CustomerClient>(); CustomerClient = ServiceProvider.GetRequiredService <CustomerClient>(); ProfileClient = ServiceProvider.GetRequiredService <ProfileClient>(); OrderClient = ServiceProvider.GetRequiredService <OrderClient>(); EnsureTestApiKey(appSettings); }