public HalClientTestContext()
        {
            _fixture = new Fixture().Customize(new AutoRhinoMockCustomization());

            _http = _fixture.Freeze <IJsonHttpClient>();

            _version   = _fixture.Create <Version>();
            _order     = _fixture.Build <Order>().With(x => x.DeliveryDate, null).Create();
            _orderItem = _fixture.Create <OrderItem>();
            _paged     = _fixture.Create <PagedList>();
            OrderAdd   = _fixture.Create <OrderAdd>();
            OrderEdit  = _fixture.Create <OrderEdit>();
            _resourceWithJsonAttribute = _fixture.Create <ResourceWithJsonAttribute>();

            _sut = new HalClient(_http);

            _curies =
                new[]
            {
                new
                {
                    href      = "https://retail.com/v1/docs/{rel}",
                    name      = Curie,
                    templated = true
                }
            };
            _hasCurie = true;
        }
Пример #2
0
 /// <summary>
 /// Creates an instance of the <see cref="HalClient"/> class.
 /// </summary>
 /// <param name="client">The implementation of <see cref="IJsonHttpClient"/> to use.</param>
 /// <param name="formatters">
 /// Specifies the list of <see cref="MediaTypeFormatter"/>s to use.
 /// Default is <see cref="HalJsonMediaTypeFormatter"/>.
 /// </param>
 public HalClient(
     IJsonHttpClient client,
     ICollection <MediaTypeFormatter> formatters)
 {
     _client     = client;
     _formatters = formatters == null || !formatters.Any() ? _defaultFormatters : formatters;
 }
        public HalClientTestContext()
        {
            _fixture = new Fixture().Customize(new AutoRhinoMockCustomization());

            _http = _fixture.Freeze<IJsonHttpClient>();

            _version = _fixture.Create<Version>();
            _order = _fixture.Create<Order>();
            _orderItem = _fixture.Create<OrderItem>();
            _paged = _fixture.Create<PagedList>();
            OrderAdd = _fixture.Create<OrderAdd>();
            OrderEdit = _fixture.Create<OrderEdit>();

            _sut = new HalClient(_http);

            _curies =
                new[]
                {
                    new
                    {
                        href = "https://retail.com/v1/docs/{rel}",
                        name = Curie,
                        templated = true
                    }
                };
            _hasCurie = true;
        }
        public ForceClient(string instanceUrl, string accessToken, string apiVersion, HttpClient httpClientForJson, HttpClient httpClientForXml)
        {
            if (string.IsNullOrEmpty(instanceUrl))
            {
                throw new ArgumentNullException("instanceUrl");
            }
            if (string.IsNullOrEmpty(accessToken))
            {
                throw new ArgumentNullException("accessToken");
            }
            if (string.IsNullOrEmpty(apiVersion))
            {
                throw new ArgumentNullException("apiVersion");
            }
            if (httpClientForJson == null)
            {
                throw new ArgumentNullException("httpClientForJson");
            }
            if (httpClientForXml == null)
            {
                throw new ArgumentNullException("httpClientForXml");
            }

            _jsonHttpClient = new JsonHttpClient(instanceUrl, apiVersion, accessToken, httpClientForJson);
            _xmlHttpClient  = new XmlHttpClient(instanceUrl, apiVersion, accessToken, httpClientForXml);
        }
Пример #5
0
        public ChatterClient(string instanceUrl, string accessToken, string apiVersion, HttpClient httpClient)
        {
            _jsonHttpClient = _fullJsonHttpClient = new JsonHttpClient(instanceUrl, apiVersion, accessToken, httpClient);

            // A change in endpoint for feed item was introduced in v31 of the API.
            _itemsOrElements = float.Parse(_fullJsonHttpClient.GetApiVersion().Substring(1)) > 30 ? "feed-elements" : "feed-items";
        }
Пример #6
0
 public AsyncExecutionProcessor(
     TAdapter execAdapter,
     IJsonHttpClient jsonHttpClient,
     ILogger <AsyncExecutionProcessor <TAdapter> > logger,
     IOptionsSnapshot <ExecutionProcessorOptions <AsyncExecutionProcessor <TAdapter> > > processorOptionsSnapshot)
     : this(execAdapter, jsonHttpClient, logger, processorOptionsSnapshot.Value)
 {
 }
Пример #7
0
 public JiraService(IHttpManager httpManager, IJsonHttpClient jsonClient, IDialogService dialogService, ICacheService cacheDataService)
 {
     this.httpManager   = httpManager;
     this.jsonClient    = jsonClient;
     this.dialogService = dialogService;
     cacheService       = cacheDataService;
     TokenSource        = new CancellationTokenSource();
 }
Пример #8
0
        public RoomieApiClient(string apiUrl, string accessKey)
        {
            var httpClient = new HttpClient
            {
                BaseAddress = new Uri(apiUrl),
            };

            _jsonHttpClient = new JsonHttpClient(httpClient);

            _accessKey = accessKey;
        }
Пример #9
0
 public AsyncExecutionProcessor(
     IExecutionAdapter execAdapter,
     IJsonHttpClient jsonHttpClient,
     ILogger logger,
     IExecutionProcessorOptions processorOptions)
 {
     this.execAdapter      = execAdapter;
     this.jsonHttpClient   = jsonHttpClient;
     this.logger           = logger;
     this.processorOptions = processorOptions;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WebhookService"/> class.
 /// </summary>
 /// <param name="loggerFactory">The logger factory.</param>
 /// <param name="mediator">The mediator.</param>
 /// <param name="configuration">The API configuration.</param>
 /// <param name="httpClient">The HTTP client.</param>
 public WebhookService(
     ILoggerFactory loggerFactory,
     IMediator mediator,
     IApiConfiguration configuration,
     IJsonHttpClient httpClient)
 {
     logger             = loggerFactory?.CreateLogger <WebhookService>() ?? throw new ArgumentNullException(nameof(loggerFactory));
     this.mediator      = mediator ?? throw new ArgumentNullException(nameof(mediator));
     this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     this.httpClient    = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
 }
Пример #11
0
 public JsonHttpExecutionAdapter(
     ILogger <JsonHttpExecutionAdapter> logger,
     IJsonHttpClient jsonHttpClient,
     IExecutionServiceProvider execServiceProvider,
     IInputObjectAccessorProvider inputObjectAccessorProvider,
     IOutputObjectAccessorProvider outputObjectAccessorProvider,
     ISigner <HttpExecutionRequest> httpExecRequestSigner)
     : base(inputObjectAccessorProvider, outputObjectAccessorProvider)
 {
     this.logger                = logger;
     this.jsonHttpClient        = jsonHttpClient;
     this.execServiceProvider   = execServiceProvider;
     this.httpExecRequestSigner = httpExecRequestSigner;
 }
        public void Init()
        {
            if (string.IsNullOrEmpty(_consumerKey) && string.IsNullOrEmpty(_consumerSecret) && string.IsNullOrEmpty(_username) && string.IsNullOrEmpty(_password))
            {
                _consumerKey    = Environment.GetEnvironmentVariable("ConsumerKey");
                _consumerSecret = Environment.GetEnvironmentVariable("ConsumerSecret");
                _username       = Environment.GetEnvironmentVariable("Username");
                _password       = Environment.GetEnvironmentVariable("Password");
            }

            // Use TLS 1.2 (instead of defaulting to 1.0)

            const int SecurityProtocolTypeTls11 = 768;
            const int SecurityProtocolTypeTls12 = 3072;

            ServicePointManager.SecurityProtocol |= (SecurityProtocolType)(SecurityProtocolTypeTls12 | SecurityProtocolTypeTls11);

            //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            _auth = new AuthenticationClient();
            _auth.UsernamePasswordAsync(_consumerKey, _consumerSecret, _username, _password, TokenRequestEndpointUrl).Wait();

            _jsonHttpClient = new JsonHttpClient(_auth.InstanceUrl, _auth.ApiVersion, _auth.AccessToken, new HttpClient());
        }
Пример #13
0
 /// <summary>
 /// Creates an instance of the <see cref="HalClient"/> class.
 /// </summary>
 /// <param name="client">The implementation of <see cref="IJsonHttpClient"/> to use.</param>
 public HalClient(
     IJsonHttpClient client)
     : this(client, _defaultFormatters)
 {
 }
 public ProxyOutputObjectAccessorProvider(IJsonHttpClient jsonHttpClient, ProxyConfiguration proxyConfig)
 {
     this.jsonHttpClient = jsonHttpClient;
     this.proxyConfig    = proxyConfig;
 }
Пример #15
0
 public ProxyExecutionServiceProvider(IJsonHttpClient jsonHttpClient, ProxyConfiguration proxyConfig)
 {
     this.jsonHttpClient = jsonHttpClient;
     this.proxyConfig    = proxyConfig;
 }
Пример #16
0
 public ProxyExecutionAdapter(IJsonHttpClient jsonHttpClient, ProxyConfiguration proxyConfig)
 {
     this.jsonHttpClient = jsonHttpClient;
     this.proxyConfig    = proxyConfig;
 }