Beispiel #1
0
        public PayInternalClient(PayInternalServiceClientSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (string.IsNullOrEmpty(settings.ServiceUrl))
            {
                throw new Exception("Service URL required");
            }

            _httpClient = new HttpClient
            {
                BaseAddress           = new Uri(settings.ServiceUrl),
                DefaultRequestHeaders =
                {
                    {
                        "User-Agent",
                        $"{PlatformServices.Default.Application.ApplicationName}/{PlatformServices.Default.Application.ApplicationVersion}"
                    }
                }
            };

            _payInternalApi     = RestService.For <IPayInternalApi>(_httpClient);
            _merchantsApi       = RestService.For <IMerchantsApi>(_httpClient);
            _ordersApi          = RestService.For <IOrdersApi>(_httpClient);
            _paymentRequestsApi = RestService.For <IPaymentRequestsApi>(_httpClient);
            _assetsApi          = RestService.For <IAssetsApi>(_httpClient);
            _markupsApi         = RestService.For <IMarkupsApi>(_httpClient);
            _runner             = new ApiRunner();
        }