public YandexTranslator(ApiDataFormat format, string apiKey)
        {
            Assertion.NotEmpty(apiKey);

            Format = format;
            ApiKey = apiKey;

            restClient = new RestClient(EndpointUrl);
            restClient.AddHandler("application/xml", xmlDeserializer);
            restClient.AddHandler("text/xml", xmlDeserializer);
            restClient.AddHandler("application/json", jsonDeserializer);
            restClient.AddHandler("text/json", jsonDeserializer);
            restClient.AddHandler("text/x-json", jsonDeserializer);
            restClient.AddHandler("text/javascript", jsonDeserializer);
            restClient.AddHandler("*", xmlDeserializer);

            switch (format)
            {
            case ApiDataFormat.Json:
                restClient.BaseUrl = string.Format(CultureInfo.InvariantCulture, EndpointUrl, ".json").ToUri();
                break;

            case ApiDataFormat.Xml:
                restClient.BaseUrl = string.Format(CultureInfo.InvariantCulture, EndpointUrl, string.Empty).ToUri();
                break;
            }

            restClient.AddDefaultParameter("key", apiKey);
        }
        public YandexTranslator(ApiDataFormat format, string apiKey)
        {
            Assertion.NotEmpty(apiKey);

            this.format = format;
            this.apiKey = apiKey;

            this.restClient = new RestClient(EndpointUrl);
            this.restClient.AddHandler("application/xml", this.xmlDeserializer);
            this.restClient.AddHandler("text/xml", this.xmlDeserializer);
            this.restClient.AddHandler("application/json", this.jsonDeserializer);
            this.restClient.AddHandler("text/json", this.jsonDeserializer);
            this.restClient.AddHandler("text/x-json", this.jsonDeserializer);
            this.restClient.AddHandler("text/javascript", this.jsonDeserializer);
            this.restClient.AddHandler("*", this.xmlDeserializer);

            switch (format)
            {
            case ApiDataFormat.Json:
                this.restClient.BaseUrl = EndpointUrl.FormatSelf(".json").ToUri();
                break;

            case ApiDataFormat.Xml:
                this.restClient.BaseUrl = EndpointUrl.FormatSelf(string.Empty).ToUri();
                break;
            }

            this.restClient.AddDefaultParameter("key", apiKey);
        }
 public TestCoachseekAuthenticatedApiClient(string username,
                                            string password,
                                            string scheme            = "https",
                                            ApiDataFormat dataFormat = ApiDataFormat.Json)
     : base(username, password, scheme, dataFormat)
 {
 }
Ejemplo n.º 4
0
 public TestCoachseekAnonymousApiClient(string scheme = "https", ApiDataFormat dataFormat = ApiDataFormat.Json)
     : base(scheme, dataFormat)
 {
 }
 public IApiConfigurator Format(ApiDataFormat format)
 {
   this.format = format;
   return this;
 }
 public IApiConfigurator Format(ApiDataFormat format)
 {
     this.format = format;
     return(this);
 }
Ejemplo n.º 7
0
 public TestCoachseekBusinessAnonymousApiClient(string businessDomain,
                                                string scheme            = "https",
                                                ApiDataFormat dataFormat = ApiDataFormat.Json)
     : base(businessDomain, scheme, dataFormat)
 {
 }