示例#1
0
 public Settings()
 {
     App     = new App();
     Format  = new Format();
     Peloton = new Peloton();
     Garmin  = new Garmin();
 }
示例#2
0
 public Configuration()
 {
     App           = new App();
     Format        = new Format();
     Peloton       = new Peloton();
     Garmin        = new Garmin();
     Observability = new Observability();
     Developer     = new Developer();
 }
        public static void ValidateConfig(Common.Peloton config)
        {
            if (string.IsNullOrEmpty(config.Email))
            {
                Log.Error("Peloton Email required, check your configuration {@ConfigSection}.{@ConfigProperty} is set.", nameof(Peloton), nameof(config.Email));
                throw new ArgumentException("Peloton Email must be set.", nameof(config.Email));
            }

            if (string.IsNullOrEmpty(config.Password))
            {
                Log.Error("Peloton Password required, check your configuration {@ConfigSection}.{@ConfigProperty} is set.", nameof(Peloton), nameof(config.Password));
                throw new ArgumentException("Peloton Password must be set.", nameof(config.Password));
            }
        }
    public async Task <SettingsPelotonGetResponse> PelotonPost([FromBody] Common.Peloton updatedPelotonSettings)
    {
        using var tracing = Tracing.Trace($"{nameof(SettingsController)}.{nameof(PelotonPost)}");

        // TODO: Validation

        var settings = await _settingsService.GetSettingsAsync();

        settings.Peloton = updatedPelotonSettings;

        await _settingsService.UpdateSettings(settings);

        var updatedSettings = await _settingsService.GetSettingsAsync();

        var settingsResponse = new SettingsGetResponse(updatedSettings);

        settingsResponse.Peloton.Password = null;

        return(settingsResponse.Peloton);
    }