コード例 #1
0
 public ViagogoClient(
     ProductHeaderValue product,
     IGogoKitConfiguration configuration,
     IOAuth2TokenStore tokenStore,
     ILocalizationProvider localizationProvider,
     IJsonSerializer serializer,
     HttpClientHandler httpClientHandler,
     IList <DelegatingHandler> customHandlers)
     : this(product,
            configuration,
            tokenStore,
            serializer,
            HttpConnectionBuilder.OAuthConnection(configuration, product, serializer)
            .LocalizationProvider(localizationProvider)
            .HttpClientHandler(httpClientHandler)
            .AdditionalHandlers(customHandlers)
            .Build(),
            HttpConnectionBuilder.ApiConnection(configuration, product, serializer)
            .TokenStore(tokenStore)
            .LocalizationProvider(localizationProvider)
            .HttpClientHandler(httpClientHandler)
            .AdditionalHandlers(customHandlers)
            .Build())
 {
 }
コード例 #2
0
        private static BearerTokenAuthenticationHandler CreateHandler(
            IOAuth2TokenStore tokenStore = null,
            IGogoKitConfiguration config = null,
            IOAuth2Client client         = null,
            OAuth2Token token            = null,
            HttpResponseMessage resp     = null)
        {
            var mockTokenStore = new Mock <IOAuth2TokenStore>(MockBehavior.Loose);

            mockTokenStore.Setup(s => s.GetTokenAsync()).Returns(Task.FromResult(token));

            var mockOAuthClient = new Mock <IOAuth2Client>(MockBehavior.Loose);

            mockOAuthClient.Setup(o => o.GetAccessTokenAsync(
                                      It.IsAny <string>(),
                                      It.IsAny <IEnumerable <string> >(),
                                      It.IsAny <IDictionary <string, string> >()))
            .Returns(Task.FromResult(token));
            return(new BearerTokenAuthenticationHandler(
                       client ?? mockOAuthClient.Object,
                       tokenStore ?? mockTokenStore.Object,
                       config ?? new GogoKitConfiguration("c", "s"))
            {
                InnerHandler = new FakeDelegatingHandler(resp: resp)
            });
        }
コード例 #3
0
        public HttpConnectionBuilder TokenStore(IOAuth2TokenStore tokenStore)
        {
            Requires.ArgumentNotNull(tokenStore, nameof(tokenStore));

            _tokenStore = tokenStore;
            return(this);
        }
コード例 #4
0
 public ViagogoClient(
     ProductHeaderValue product,
     IGogoKitConfiguration configuration,
     IOAuth2TokenStore tokenStore)
     : this(product,
            configuration,
            tokenStore,
            new ConfigurationLocalizationProvider(configuration),
            new DefaultJsonSerializer(),
            new HttpClientHandler(),
            new DelegatingHandler[] {})
 {
 }
コード例 #5
0
        public BearerTokenAuthenticationHandler(
            IOAuth2Client oauthClient,
            IOAuth2TokenStore tokenStore,
            IGogoKitConfiguration configuration)
        {
            Requires.ArgumentNotNull(oauthClient, nameof(oauthClient));
            Requires.ArgumentNotNull(tokenStore, nameof(tokenStore));
            Requires.ArgumentNotNull(configuration, nameof(configuration));

            _oauthClient   = oauthClient;
            _tokenStore    = tokenStore;
            _configuration = configuration;
        }
コード例 #6
0
        public ViagogoClient(
            ProductHeaderValue product,
            IGogoKitConfiguration configuration,
            IOAuth2TokenStore tokenStore,
            IJsonSerializer serializer,
            IHttpConnection oauthConnection,
            IHttpConnection apiConnection)
        {
            Requires.ArgumentNotNull(product, nameof(product));
            Requires.ArgumentNotNull(configuration, nameof(configuration));
            Requires.ArgumentNotNull(tokenStore, nameof(tokenStore));
            Requires.ArgumentNotNull(serializer, nameof(serializer));
            Requires.ArgumentNotNull(oauthConnection, nameof(oauthConnection));
            Requires.ArgumentNotNull(apiConnection, nameof(apiConnection));

            var halKitConfiguration = new HalKitConfiguration(configuration.ViagogoApiRootEndpoint)
            {
                CaptureSynchronizationContext = configuration.CaptureSynchronizationContext
            };

            Configuration = configuration;
            TokenStore    = tokenStore;
            Hypermedia    = new HalClient(halKitConfiguration, apiConnection);
            var linkFactory = new LinkFactory(configuration);

            OAuth2         = new OAuth2Client(oauthConnection, configuration);
            User           = new UserClient(Hypermedia);
            Search         = new SearchClient(Hypermedia);
            Addresses      = new AddressesClient(User, Hypermedia, linkFactory);
            Purchases      = new PurchasesClient(User, Hypermedia, linkFactory);
            Sales          = new SalesClient(Hypermedia, linkFactory);
            Shipments      = new ShipmentsClient(Hypermedia, linkFactory);
            PaymentMethods = new PaymentMethodsClient(User, Hypermedia, linkFactory);
            Countries      = new CountriesClient(Hypermedia, linkFactory);
            Currencies     = new CurrenciesClient(Hypermedia, linkFactory);
            Categories     = new CategoriesClient(Hypermedia, linkFactory);
            Events         = new EventsClient(Hypermedia);
            Listings       = new ListingsClient(Hypermedia);
            Venues         = new VenuesClient(Hypermedia);
            SellerListings = new SellerListingsClient(Hypermedia, linkFactory);
            Webhooks       = new WebhooksClient(Hypermedia, linkFactory);

            BatchClient = new BatchClient(apiConnection,
                                          new ApiResponseFactory(serializer, halKitConfiguration),
                                          serializer,
                                          new LinkResolver());
        }
コード例 #7
0
        private HttpConnectionBuilder(IGogoKitConfiguration configuration,
                                      ProductHeaderValue product,
                                      ConnectionType connectionType,
                                      IJsonSerializer serializer)
        {
            Requires.ArgumentNotNull(configuration, nameof(configuration));
            Requires.ArgumentNotNull(product, nameof(product));
            Requires.ArgumentNotNull(product, nameof(product));

            _configuration  = configuration;
            _product        = product;
            _connectionType = connectionType;
            _serializer     = serializer;

            _tokenStore           = new InMemoryOAuth2TokenStore();
            _localizationProvider = new ConfigurationLocalizationProvider(_configuration);
            _httpClientHandler    = new HttpClientHandler();
            _additionalHandlers   = new DelegatingHandler[] { };
        }