/// <summary> /// Creates an instance of market data rest client. /// Either <paramref name="httpClientFactory"/> or <paramref name="httpClient"/> should be specified. /// If both are present, <paramref name="httpClientFactory"/> will be used. /// </summary> /// <param name="restSerializer">Rest serializer.</param> /// <param name="httpClientFactory">Http client factory.</param> /// <param name="httpClient">Http client.</param> public MarketDataRestClient( IRestSerializer restSerializer, IHttpClientFactory httpClientFactory = null, HttpClient httpClient = null) : base(httpClientFactory, httpClient) { _restSerializer = restSerializer; }
public RestSerializerFactory(IEnumerable <IRestSerializer> serializers = null) { var realSerializers = serializers.IsNullOrEmpty() ? new[] { new JsonRestSerializer() } : serializers; _serializersByMediaTypes = LoadSerializers(realSerializers); _defaultSerializer = realSerializers.FirstOrDefault(); }
/// <summary> /// Creates an instance of trading rest client. /// Either <paramref name="httpClientFactory"/> or <paramref name="httpClient"/> should be specified. /// If both are present, <paramref name="httpClientFactory"/> will be used. /// </summary> /// <param name="options">Trading rest client options.</param> /// <param name="serializer">Rest serializer.</param> /// <param name="httpClientFactory">Http client factory.</param> /// <param name="httpClient">Http client.</param> public TradingRestClient( TradingRestClientOptions options, IRestSerializer serializer, IHttpClientFactory httpClientFactory = null, HttpClient httpClient = null) : base(httpClientFactory, httpClient) { _options = options; _serializer = serializer; }
public RestProcessParameters(HttpContext context, RequestHeaders headers, string[] pathSegments, IModel model, IRestSerializer requestSerializer, IRestSerializer responseSerializer) { Context = context; Headers = headers; PathSegments = pathSegments; Model = model; RequestSerializer = requestSerializer; ResponseSerializer = responseSerializer; }
/// <summary> /// Initializes a new instance of the <see cref="SerializerClientFactoryDecorator"/> class. /// </summary> /// <param name="clientFactory">The instance to decorate</param> /// <param name="serializer">The serializer</param> public SerializerClientFactoryDecorator( IClientFactory clientFactory, IRestSerializer serializer) : base(clientFactory) { Argument.NotNull(clientFactory, nameof(clientFactory)); Argument.NotNull(serializer, nameof(serializer)); _clientFactory = clientFactory; _serializer = serializer; }
/// <summary> /// Initializes an instance of <see cref="Client{TInterface}"/> with the given parameters. /// </summary> /// <param name="baseUri">The base URI that all routes on <typeparamref name="TInterface"/> will be executed against.</param> /// <param name="httpClient">An implementation of an HTTP client (if null, the default implementation will be used).</param> /// <param name="serializer">An implementation of a complex object serializer (if null, the default implementation will be used).</param> public Client(Uri baseUri, IHttpClient httpClient = null, IRestSerializer serializer = null) { this.baseUri = baseUri; this.httpClient = httpClient ?? new DefaultHttpClient(); this.serializer = serializer ?? new DefaultSerializer(); if (!typeof(TInterface).IsInterface) { throw new InvalidOperationException($"The generic type parameter TInterface must correspond to an interface but the provided type {typeof(TInterface).Name} is not an interface"); } }
public RequestSender(IRestSerializer serializer, ApplicationProperties properties, IRestClient client, UnAuthorizedHandler unAuthorizedHandler) { _serializer = serializer; _properties = properties; _client = client; _client.AddHandler("application/json", () => _serializer); _client.AddHandler("text/json", () => _serializer); _client.AddHandler("text/x-json", () => _serializer); _client.AddHandler("text/javascript", () => _serializer); _client.AddHandler("*+json", () => _serializer); _unAuthorizedHandler = unAuthorizedHandler; }
/// <summary> /// REST API client constructor /// <summary>/ /// <param name="authenticator"> /// authentication API authentication method /// </param> public RestApiClient(IAuthenticator authenticator) { SetAppSettings(); JsonSerializer = new CallfireJsonConverter(); RestClient = new RestClient(_ClientConfig.ApiBasePath).UseSerializer(JsonSerializer); RestClient.Authenticator = authenticator; RestClient.UserAgent = this.GetType().Assembly.GetName().Name + "-csharp-" + this.GetType().Assembly.GetName().Version; RestClient.AddHandler("application/json", JsonSerializer); Filters = new SortedSet <RequestFilter>(); SetUpRestClientProxy(); }
public FirebaseWrapper(JsonSerializerSettings serializerSettings) { _serializerSettings = serializerSettings; _authClient = new FirebaseAuthClient(new FirebaseAuthConfig() { ApiKey = API_KEY, AuthDomain = AUTH_DOMAIN, Providers = new FirebaseAuthProvider[] { new EmailProvider() }, UserRepository = new FileUserRepository("User") }); SetUser(_authClient.User); _dataClient = new RestClient(DATA_URL) { ThrowOnAnyError = true, ThrowOnDeserializationError = true, FailOnDeserializationError = true }; _restSerializer = new NewtonWrapper(_serializerSettings); Func <IDeserializer> getRestSerializer = () => _restSerializer; _dataClient.AddHandler("application/json", getRestSerializer); _dataClient.AddHandler("text/json", getRestSerializer); _dataClient.AddHandler("text/x-json", getRestSerializer); _dataClient.AddHandler("text/javascript", getRestSerializer); _dataClient.AddHandler("*+json", getRestSerializer); _dataClient.AddHandler(ContentType.Json, getRestSerializer); foreach (string contentType in ContentType.JsonAccept) { _dataClient.AddHandler(contentType, getRestSerializer); } }
public RestFactory(IBambooOptions bambooOptions, IRestSerializer serializer) { _bambooOptions = bambooOptions; _serializer = serializer; }
public IRestClient UseSerializer(IRestSerializer serializer) { return(_innerClient.UseSerializer(serializer)); }
public IRestClient UseSerializer(IRestSerializer serializer) { return(this.With(x => x.UseSerializer(() => serializer))); }