Пример #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();
        }
        public PayInvoiceClient(PayInvoiceServiceClientSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

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

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

            _invoicesApi         = RestService.For <IInvoicesApi>(_httpClient);
            _merchantsApi        = RestService.For <IMerchantsApi>(_httpClient);
            _draftsApi           = RestService.For <IDraftsApi>(_httpClient);
            _filesApi            = RestService.For <IFilesApi>(_httpClient);
            _employeesApi        = RestService.For <IEmployeesApi>(_httpClient);
            _merchantSettingsApi = RestService.For <IMerchantSettingsApi>(_httpClient);
            _runner = new ApiRunner();
        }