コード例 #1
0
 public PersonServiceApi(
     IRestClient restClient,
     IOptions <RestOptions> restOptions)
 {
     _restClient  = restClient;
     _restOptions = restOptions.Value;
 }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        public static IServiceCollection AddIntrospectedRest(
            this IServiceCollection services,
            Action <RestOptions>?restOptionsSettings = null)
        {
            var options = new RestOptions();

            restOptionsSettings?.Invoke(options);

            return(services
                   .AddSingleton(options)
                   .RegisterDefaultServices());
        }
コード例 #4
0
 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
     });
 }
コード例 #5
0
ファイル: TelligentManager.cs プロジェクト: netojoa/blog
        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);
        }
コード例 #6
0
        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");
        }
コード例 #7
0
ファイル: GuildCache.cs プロジェクト: Navy-gif/CBot
 public override Guild Create(RestOptions Options)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
ファイル: BaseTelligentClient.cs プロジェクト: netojoa/blog
 protected dynamic CallEndpoint(string endpoint, RestOptions options, out bool threwException)
 {
     return(telligentManager.CallEndpoint(Host, endpoint, options, out threwException));
 }
コード例 #9
0
 public RestClient(ILogger <RestClient> logger, HttpClient httpClient, IOptions <RestOptions> restOptions)
 {
     _logger      = logger;
     _httpClient  = httpClient;
     _restOptions = restOptions.Value;
 }
コード例 #10
0
 public JsonHyperSchemaIntrospection(RestOptions options)
 {
     _options = options;
 }
コード例 #11
0
 public RestMiddleware(RequestDelegate next, RestOptions restSettings)
 {
     _next         = next;
     _restSettings = restSettings;
 }
コード例 #12
0
 public LinksOnlyIntrospection(RestOptions options)
 {
     _options = options;
 }
コード例 #13
0
ファイル: GuildMembers.cs プロジェクト: Navy-gif/CBot
 public override GuildMember Create(RestOptions Data)
 {
     throw new NotImplementedException();
 }
コード例 #14
0
 public override AbstractGuildChannel Create(RestOptions Options)
 {
     throw new NotImplementedException();
 }
コード例 #15
0
 public DefaultRestOptions(RestOptions options)
     : base(() => options.GetHttpClient(), () => options.DefaultFormatter, options.Formatters)
 {
 }
コード例 #16
0
 public UsersGetterClient(HttpClient httpClient, RestOptions restSettings) : base(ServiceName, httpClient,
     restSettings)
 {
 }
コード例 #17
0
 public IntrospectionChooser(RestOptions options)
 {
     _options = options;
 }
コード例 #18
0
 public OverviewIntrospection(int statusCode, RestOptions options)
 {
     _statusCode = statusCode;
     _options    = options;
 }
コード例 #19
0
 public override IChannel Create(RestOptions Options)
 {
     throw new NotImplementedException();
 }
コード例 #20
0
ファイル: GuildRoles.cs プロジェクト: Navy-gif/CBot
 public override Role Create(RestOptions Data)
 {
     throw new NotImplementedException();
 }
コード例 #21
0
 public RestResultExecutor(RestOptions options)
 {
     _options = options;
 }