public PricingClient(IConfiguration configuration, IDiscoveryClient discoveryClient)
        {
            var handler    = new DiscoveryHttpClientHandler(discoveryClient);
            var httpClient = new HttpClient(handler, false)
            {
                BaseAddress = new Uri(configuration.GetValue <string>("PricingServiceUri"))
            };

            client = RestClient.For <IPricingClient>(httpClient);
        }
Example #2
0
        public PricingClient(IOptions <ServicesUrl> servicesUrl, IDiscoveryClient discoveryClient)
        {
            _servicesUrl = servicesUrl.Value;
            var handler = new DiscoveryHttpClientHandler(discoveryClient);

            //Certificado no valido
            handler.ServerCertificateCustomValidationCallback = delegate { return(true); };
            var httpClient = new HttpClient(handler, false)
            {
                BaseAddress = new Uri(_servicesUrl.PricingApiUrl)
            };

            client = RestClient.For <IPricingClient>(httpClient);
        }
        public PricingClient(IConfiguration configuration, Consul.IConsulClient consulClient)
        {
            //TODO: find better way to resolve hostname in http handler
            string baseUrl           = GetServiceUrl(consulClient, "pricing-service");
            string pricingServiceUrl = configuration.GetValue <string>("PricingServiceUri").Replace("pricing-service", baseUrl);

            HttpClient httpClient = new HttpClient()
            {
                BaseAddress = new Uri(pricingServiceUrl)
            };
            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            this._client = new RestClient(httpClient)
            {
                JsonSerializerSettings = settings
            }.For <IPricingClient>();
        }
Example #4
0
 public PricingAgent(IPricingClient pricingClient)
 {
     this.pricingClient = pricingClient;
 }
 public PricingService(IPricingClient pricingClient)
 {
     this.pricingClient = pricingClient;
 }
 public PricingService(IPricingClient pricingClient) =>
 this._pricingClient = pricingClient ?? throw new ArgumentNullException(nameof(pricingClient));