public async Task Save(BotAccess accessData) { var jsonSettings = new JsonSerializerSettings { ContractResolver = new IgnoreJsonAttributesResolver() }; await File.WriteAllTextAsync(_path, JsonConvert.SerializeObject(accessData, jsonSettings)); }
private static async Task <MastodonClient> PrepareClient() { const string clientPath = "./.config/botAccessConfig.json"; var persistent = new BotAccessPersistent(clientPath); MastodonClient?preparedClient = (await persistent.Load())?.AsMastodonClient(); if (preparedClient == null) { BotAccess.BotAccess access = await BotAccessCreator.InteractiveConsoleRegister(); await persistent.Save(access); preparedClient = access.AsMastodonClient(); } if (preparedClient == null) { throw new Exception("client is null. somehow failed to create mastodon client."); } return(preparedClient); }