Exemplo n.º 1
0
        public PayAuthClient(PayAuthServiceClientSettings 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}"
                    }
                }
            };

            _payAuthApi       = RestService.For <IPayAuthApi>(_httpClient);
            _employeesApi     = RestService.For <IEmployeesApi>(_httpClient);
            _resetPasswordApi = RestService.For <IResetPasswordApi>(_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();
        }