Beispiel #1
0
 public AniListClient(IJsonConnection jsonConnection, IAniListToken aniListToken,
                      IAnilistConfiguration anilistConfiguration)
 {
     _jsonConnection       = jsonConnection;
     _aniListToken         = aniListToken;
     _anilistConfiguration = anilistConfiguration;
 }
Beispiel #2
0
 public TvDbClient(IJsonConnection jsonConnection, IFileCache fileCache, IApplicationPaths applicationPaths,
                   ILogManager logManager, ICustomJsonSerialiser jsonSerialiser, PluginConfiguration configuration)
 {
     _log              = logManager.GetLogger(nameof(TvDbClient));
     _jsonConnection   = jsonConnection;
     _fileCache        = fileCache;
     _applicationPaths = applicationPaths;
     _jsonSerialiser   = jsonSerialiser;
     _token            = new TvDbToken(_jsonConnection, configuration.TvDbApiKey, logManager);
 }
Beispiel #3
0
 public TvDbClientV2(IJsonConnection jsonConnection, IFileCache fileCache, IApplicationPaths applicationPaths,
                     ILogManager logManager, ICustomJsonSerialiser jsonSerialiser, PluginConfiguration configuration)
 {
     this.log              = logManager.GetLogger(nameof(TvDbClientV2));
     this.jsonConnection   = jsonConnection;
     this.fileCache        = fileCache;
     this.applicationPaths = applicationPaths;
     this.jsonSerialiser   = jsonSerialiser;
     this.token            = new TvDbToken(this.jsonConnection, configuration.TvDbApiKey, logManager);
 }
 public TvDbClientV3(IJsonConnection jsonConnection, IFileCache fileCache, IApplicationPaths applicationPaths,
                     ILogManager logManager, ICustomJsonSerialiser jsonSerialiser, PluginConfiguration configuration)
 {
     this.log              = logManager.GetLogger(nameof(TvDbClientV2));
     this.fileCache        = fileCache;
     this.applicationPaths = applicationPaths;
     this.jsonSerialiser   = jsonSerialiser;
     this.tvDbClient       = new TvDbClient();
     this.tvDbClient.Authentication.AuthenticateAsync(configuration.TvDbApiKey).GetAwaiter().GetResult();
     this.dataMapper = this.CreateDataMapper();
 }
        private Task <Either <FailedRequest, string> > RequestToken(IJsonConnection jsonConnection,
                                                                    IAnilistConfiguration anilistConfiguration)
        {
            var response = jsonConnection
                           .PostAsync(new GetTokenRequest(362, "NSjmeTEekFlV9OZuZo9iR0BERNe3KS83iaIiI7EQ",
                                                          "http://localhost:8096/web/configurationpage?name=AniMetadata",
                                                          anilistConfiguration.AuthorisationCode), Option <string> .None);

            var token = response.MapAsync(r =>
            {
                anilistConfiguration.AccessToken = r.Data.AccessToken;
                return(r.Data.AccessToken);
            });

            return(token);
        }
 private Task <Either <FailedRequest, string> > GetTokenFromCacheOrRequest(IJsonConnection jsonConnection,
                                                                           IAnilistConfiguration anilistConfiguration)
 {
     return(GetCachedToken(anilistConfiguration.AuthorisationCode,
                           () => RequestToken(jsonConnection, anilistConfiguration)));
 }
 public Task <Either <FailedRequest, string> > GetToken(IJsonConnection jsonConnection,
                                                        IAnilistConfiguration anilistConfiguration, ProcessResultContext resultContext)
 {
     return(anilistConfiguration.AccessToken.MapAsync(Right <FailedRequest, string>)
            .IfNone(() => GetTokenFromCacheOrRequest(jsonConnection, anilistConfiguration)));
 }
 public TvDbToken(IJsonConnection jsonConnection, string apiKey, ILogManager logManager)
 {
     this.jsonConnection = jsonConnection;
     this.apiKey         = apiKey;
     this.log            = logManager.GetLogger(nameof(TvDbToken));
 }