Exemplo n.º 1
0
        public ShrimpyApiFixture()
        {
            var secrets       = new Secrets();
            var configuration = new ShrimpyApiConfiguration
            {
                ApiKey    = secrets.ShrimpyApiKey,
                ApiSecret = secrets.ShrimpyApiSecret,
                BaseUrl   = "https://api.shrimpy.io"
            };

            var devSecrets = new SecretsDev();
            var devConfig  = new ShrimpyDevApiConfiguration
            {
                ApiKey    = devSecrets.ShrimpyApiKey,
                ApiSecret = devSecrets.ShrimpyApiSecret,
                BaseUrl   = "https://dev-api.shrimpy.io"
            };

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddCoreDependencies();
            serviceCollection.AddApiCredentialsProvider <ShrimpyDevApiConfiguration>();
            serviceCollection.AddApiCredentialsProvider <ShrimpyApiConfiguration>();

            serviceCollection.AddShrimpyClients(configuration);
            serviceCollection.AddShrimpyDeveloperClients(devConfig);
            ServiceProvider = serviceCollection.BuildServiceProvider();
        }
Exemplo n.º 2
0
    public ApiKeyCredentialsProvider(ShrimpyApiConfiguration configuration,
                                     IDateTimeProvider dateTimeProvider)
    {
        _configuration    = configuration;
        _dateTimeProvider = dateTimeProvider;

        _tokenSource    = new CancellationTokenSource();
        _encodingSecret = Convert.FromBase64String(_configuration.ApiSecret);
    }
 public static IServiceCollection AddShrimpyClient(
     this IServiceCollection serviceCollection, ShrimpyApiConfiguration apiConfiguration)
 {
     serviceCollection.AddSingleton <IDateTimeProvider, DateTimeProvider>();
     serviceCollection.AddSingleton <IShrimpyCredentialsProvider, ApiKeyCredentialsProvider>();
     serviceCollection.AddSingleton(apiConfiguration);
     serviceCollection.AddSingleton <ClientConfigurator>();
     AddClients(serviceCollection);
     return(serviceCollection);
 }
Exemplo n.º 4
0
        public static IServiceCollection AddShrimpyClients(
            this IServiceCollection serviceCollection, ShrimpyApiConfiguration apiConfiguration)
        {
            serviceCollection.AddApiCredentialsProvider <ShrimpyApiConfiguration>();
            var options = Options.Create(apiConfiguration);

            serviceCollection.AddSingleton(options);
            serviceCollection.AddSingleton(s => new ClientConfigurator(s));
            AddClients(serviceCollection);
            return(serviceCollection);
        }
 public ClientConfigurator(ShrimpyApiConfiguration apiConfiguration,
                           IShrimpyCredentialsProvider credentialsProvider)
 {
     ApiConfiguration     = apiConfiguration;
     _credentialsProvider = credentialsProvider;
 }