Search in sources :

Example 1 with Credentials

use of com.github.robozonky.common.secrets.Credentials in project robozonky by RoboZonky.

the class OperatingMode method configure.

public Optional<InvestmentMode> configure(final CommandLine cli, final Authenticated auth) {
    final SecretProvider secretProvider = auth.getSecretProvider();
    final boolean isDryRun = cli.getTweaksFragment().isDryRunEnabled();
    // initialize SessionInfo before the robot potentially sends the first notification
    Events.initialize(new SessionInfo(secretProvider.getUsername(), cli.getName(), isDryRun));
    // and now initialize the chosen mode of operation
    return cli.getConfirmationFragment().getConfirmationCredentials().map(value -> new Credentials(value, secretProvider)).map(credentials -> this.getZonkyProxyBuilder(credentials, secretProvider)).orElse(Optional.of(new Investor.Builder())).map(builder -> {
        if (isDryRun) {
            LOGGER.info("RoboZonky is doing a dry run. It will not invest any real money.");
            builder.asDryRun();
        }
        builder.asUser(secretProvider.getUsername());
        return this.getInvestmentMode(cli, auth, builder);
    }).orElse(Optional.empty());
}
Also used : SessionInfo(com.github.robozonky.api.notifications.SessionInfo) ToStringBuilder(com.github.robozonky.internal.api.ToStringBuilder) Investor(com.github.robozonky.app.investing.Investor) Logger(org.slf4j.Logger) Events(com.github.robozonky.app.Events) ConfirmationProviderLoader(com.github.robozonky.common.extensions.ConfirmationProviderLoader) Authenticated(com.github.robozonky.app.authentication.Authenticated) Credentials(com.github.robozonky.common.secrets.Credentials) LoggerFactory(org.slf4j.LoggerFactory) Optional(java.util.Optional) SecretProvider(com.github.robozonky.common.secrets.SecretProvider) ConfirmationProvider(com.github.robozonky.api.confirmations.ConfirmationProvider) ToStringBuilder(com.github.robozonky.internal.api.ToStringBuilder) SessionInfo(com.github.robozonky.api.notifications.SessionInfo) Credentials(com.github.robozonky.common.secrets.Credentials) SecretProvider(com.github.robozonky.common.secrets.SecretProvider)

Aggregations

ConfirmationProvider (com.github.robozonky.api.confirmations.ConfirmationProvider)1 SessionInfo (com.github.robozonky.api.notifications.SessionInfo)1 Events (com.github.robozonky.app.Events)1 Authenticated (com.github.robozonky.app.authentication.Authenticated)1 Investor (com.github.robozonky.app.investing.Investor)1 ConfirmationProviderLoader (com.github.robozonky.common.extensions.ConfirmationProviderLoader)1 Credentials (com.github.robozonky.common.secrets.Credentials)1 SecretProvider (com.github.robozonky.common.secrets.SecretProvider)1 ToStringBuilder (com.github.robozonky.internal.api.ToStringBuilder)1 Optional (java.util.Optional)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1