public IActionResult UpdateSynonyms([FromHeader(Name = "googleFileId")] string googleFileId, [FromHeader(Name = "sheetName")] string sheetName, [FromHeader(Name = "sheetRange")] string sheetRange, [FromHeader(Name = "googleApiKey")] string googleApiKey) { try { //if (string.IsNullOrEmpty(AccessToken)) // return BadRequest("no access_token cookie found in the request"); if (string.IsNullOrEmpty(googleFileId)) { googleFileId = Environment.GetEnvironmentVariable("SYNONYMS_GOOGLE_FILE_ID") ?? "1V89AxVH-SXGloTmX6T2o-FG-any14qah-WOi3eaYelE"; } if (string.IsNullOrEmpty(sheetName)) { sheetName = Environment.GetEnvironmentVariable("SYNONYMS_SHEET_NAME") ?? "Synonyms"; } if (string.IsNullOrEmpty(sheetRange)) { sheetRange = Environment.GetEnvironmentVariable("SYNONYMS_SHEET_RANGE") ?? "A:AU"; } if (string.IsNullOrEmpty(googleApiKey)) { googleApiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY") ?? "LongApiGoogleKeyFromGoogleConsoleGoesHere"; } SynonymUpdateRequest synonymsRequest = new SynonymUpdateRequest { GoogleFileId = googleFileId, SheetName = sheetName, SheetRange = sheetRange, GoogleApiKey = googleApiKey }; var response = _synonymsUseCase.ExecuteUpdate(AccessToken, synonymsRequest); if (response != null) { return(Ok(response)); } } catch (UseCaseException e) { return(BadRequest(e)); } // Validations return(BadRequest( new ErrorResponse($"Invalid request. ") { Status = "Bad request", Errors = new List <string> { "Unable to create organisation." } })); }
public async Task UpdateSynonyms() { var updateRequest = new SynonymUpdateRequest { GoogleFileId = Environment.GetEnvironmentVariable("SYNONYMS_GOOGLE_FILE_ID"), SheetName = Environment.GetEnvironmentVariable("SYNONYMS_SHEET_NAME"), SheetRange = Environment.GetEnvironmentVariable("SYNONYMS_SHEET_RANGE"), GoogleApiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY") }; LoggingHandler.LogInfo("Starting process of updating synonyms."); await _synonymsUseCase.ExecuteUpdate(null, updateRequest).ConfigureAwait(false); }