コード例 #1
0
        public IVippsApi Create(VippsConfiguration configuration)
        {
            if (_vippsApi == null)
            {
                _configuration = configuration;
                var client = new HttpClient(new AuthenticatedHttpClientHandler(GetToken))
                {
                    BaseAddress = new Uri(_configuration.ApiUrl)
                };

                client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", _configuration.SubscriptionKey);

                _vippsApi = RestService.For <IVippsApi>(client);
            }

            return(_vippsApi);
        }
コード例 #2
0
        public IVippsApi Create(VippsConfiguration configuration)
        {
            var vippsApi = _marketApiDictionary.FirstOrDefault(x => x.Key == configuration.MarketId).Value;

            if (vippsApi == null)
            {
                _configuration = configuration;
                var client = new HttpClient(new AuthenticatedHttpClientHandler(GetToken))
                {
                    BaseAddress = new Uri(_configuration.ApiUrl)
                };

                AddDefaultHeaders(client.DefaultRequestHeaders);

                vippsApi = RestService.For <IVippsApi>(client);
                _marketApiDictionary.Add(configuration.MarketId, vippsApi);
            }

            return(vippsApi);
        }