From 0a40655f2d17360938167e38bbb51f5e84d4e3f0 Mon Sep 17 00:00:00 2001 From: Zeeshaun Date: Mon, 20 Apr 2026 18:18:08 +0000 Subject: [PATCH] Moving uris to the configuration model --- .../Model/SpitConfiguration.cs | 10 ++++++++++ .../Services/AuthenticationService.cs | 7 +------ .../Services/VoiceService.cs | 7 +------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Model/SpitConfiguration.cs b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Model/SpitConfiguration.cs index ffe50fd..b3ccc52 100644 --- a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Model/SpitConfiguration.cs +++ b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Model/SpitConfiguration.cs @@ -34,5 +34,15 @@ namespace LCU.Webapps.Marketing.SPIT.Model return new Uri(SpeechEndpoint.Trim(), UriKind.Absolute); } + + public Uri ResolveSpeechTokenUri() + { + return new Uri(ResolveSpeechEndpointUri(), "/sts/v1.0/issueToken"); + } + + public Uri ResolveSpeechVoicesUri() + { + return new Uri(ResolveSpeechEndpointUri(), "/cognitiveservices/voices/list"); + } } } diff --git a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/AuthenticationService.cs b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/AuthenticationService.cs index b8bf152..1dbebec 100644 --- a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/AuthenticationService.cs +++ b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/AuthenticationService.cs @@ -17,7 +17,7 @@ public class AuthenticationService public async Task FetchTokenAsync() { - var uri = BuildTokenUri(); + var uri = _spitConfiguration.ResolveSpeechTokenUri(); var client = _lcuHttpClient.CreateClient(uri); client.DefaultRequestHeaders.Add(_spitConfiguration.OcpApimSubscriptionKey, _spitConfiguration.SpeechApiKey); @@ -25,9 +25,4 @@ public class AuthenticationService var result = await client.PostAsync(uri.AbsoluteUri, null); return await result.Content.ReadAsStringAsync(); } - - private Uri BuildTokenUri() - { - return new Uri(_spitConfiguration.ResolveSpeechEndpointUri(), "/sts/v1.0/issueToken"); - } } diff --git a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/VoiceService.cs b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/VoiceService.cs index 07e18c4..c920e97 100644 --- a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/VoiceService.cs +++ b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/VoiceService.cs @@ -29,7 +29,7 @@ namespace LCU.Webapps.Marketing.SPIT.Services try { - var uri = BuildVoicesUri(); + var uri = _spitConfiguration.ResolveSpeechVoicesUri(); var token = await _authenticationService.FetchTokenAsync(); var client = _lcuHttpClient.CreateClient(uri); @@ -47,10 +47,5 @@ namespace LCU.Webapps.Marketing.SPIT.Services return voices; } - - private Uri BuildVoicesUri() - { - return new Uri(_spitConfiguration.ResolveSpeechEndpointUri(), "/cognitiveservices/voices/list"); - } } }