public PersonServiceApi( IRestClient restClient, IOptions <RestOptions> restOptions) { _restClient = restClient; _restOptions = restOptions.Value; }
/// <summary> /// Search video for Imdb /// </summary> /// <param name="parameters">Search parameters</param> /// <returns>Returns an instance of VideSearchResponse which contains video search result or error information </returns> public VideoSearchResponse SearchVideo(VideoSearchRequest parameters) { if (parameters == null) { return(null); } if (string.IsNullOrWhiteSpace(parameters.SearchQuery)) { return(null); } string query = parameters.SearchQuery.Replace(" ", "+"); VideoSearchResponse response = new VideoSearchResponse(); this.RunSafely(() => { RestOptions arguments = new RestOptions(); arguments.Url = string.Format("{0}{1}", IMDB_API_URL, query); arguments.Method = RestMethod.Get; RestClient rest = new RestClient(arguments); ImdbResponseItemProxy restResult = rest.MakeReqeust <ImdbResponseItemProxy>(); IImdbVideoResponseAdapter imdbDataADapter = new ImdbAdapter(); VideoItemCollection viodeItems = imdbDataADapter.ToVideoItemCollection(restResult); response.Success(viodeItems); }, (ex) => { response.Error("IMDBVideoProvider_SearchVideo", ex.Message, false); }); return(response); }
public static IServiceCollection AddIntrospectedRest( this IServiceCollection services, Action <RestOptions>?restOptionsSettings = null) { var options = new RestOptions(); restOptionsSettings?.Invoke(options); return(services .AddSingleton(options) .RegisterDefaultServices()); }
private static TokenValidationParameters CreateTokenValidationParams(RestOptions restSettings) { return(new() { ValidateAudience = true, ValidAudience = restSettings.RestToken.Audience, ValidateIssuer = true, ValidIssuer = restSettings.RestToken.Issuer, ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(restSettings.RestToken.IssuerSigningKey)), ValidateLifetime = true }); }
public dynamic CallEndpoint(ClientCredentialsRestHost host, string endpoint, RestOptions options, out bool threwException) { dynamic response = null; threwException = false; try { if (options is RestDeleteOptions) { response = host.DeleteToDynamic(2, endpoint, true, (RestDeleteOptions)options); } else if (options is RestPutOptions) { response = host.PutToDynamic(2, endpoint, true, (RestPutOptions)options); } else if (options is RestPostOptions) { response = host.PostToDynamic(2, endpoint, true, (RestPostOptions)options); } else { response = host.GetToDynamic(2, endpoint, true, (RestGetOptions)options); } } catch (Exception ex) { if (options is RestDeleteOptions) { return(response); } threwException = true; var sb = new StringBuilder(); sb.AppendLine(string.Format("TelligentManager.CallEndpoint - Endpoint: {0}", endpoint)); sb.AppendLine("Options: "); sb.AppendLine(Newtonsoft.Json.JsonConvert.SerializeObject(options)); sb.AppendLine("Exception Messages: "); sb.AppendLine(ex.Message); sb.AppendLine("Stack Trace: "); sb.AppendLine(ex.StackTrace); Sitecore.Diagnostics.Log.Error(sb.ToString(), this); } return(response); }
protected RestClient(string serviceName, HttpClient httpClient, RestOptions restSettings) { if (string.IsNullOrEmpty(serviceName)) { throw new ArgumentNullException(nameof(serviceName)); } _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); _restSettings = restSettings; if (restSettings is null) { throw new ArgumentNullException(nameof(restSettings)); } _httpClient.BaseAddress = restSettings.GetUri(serviceName); _httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); _httpClient.DefaultRequestHeaders.Add("User-Agent", "OCS-Rest-Api"); }
public override Guild Create(RestOptions Options) { throw new NotImplementedException(); }
protected dynamic CallEndpoint(string endpoint, RestOptions options, out bool threwException) { return(telligentManager.CallEndpoint(Host, endpoint, options, out threwException)); }
public RestClient(ILogger <RestClient> logger, HttpClient httpClient, IOptions <RestOptions> restOptions) { _logger = logger; _httpClient = httpClient; _restOptions = restOptions.Value; }
public JsonHyperSchemaIntrospection(RestOptions options) { _options = options; }
public RestMiddleware(RequestDelegate next, RestOptions restSettings) { _next = next; _restSettings = restSettings; }
public LinksOnlyIntrospection(RestOptions options) { _options = options; }
public override GuildMember Create(RestOptions Data) { throw new NotImplementedException(); }
public override AbstractGuildChannel Create(RestOptions Options) { throw new NotImplementedException(); }
public DefaultRestOptions(RestOptions options) : base(() => options.GetHttpClient(), () => options.DefaultFormatter, options.Formatters) { }
public UsersGetterClient(HttpClient httpClient, RestOptions restSettings) : base(ServiceName, httpClient, restSettings) { }
public IntrospectionChooser(RestOptions options) { _options = options; }
public OverviewIntrospection(int statusCode, RestOptions options) { _statusCode = statusCode; _options = options; }
public override IChannel Create(RestOptions Options) { throw new NotImplementedException(); }
public override Role Create(RestOptions Data) { throw new NotImplementedException(); }
public RestResultExecutor(RestOptions options) { _options = options; }