diff --git a/UrlboxSDK.MsTest/DI/Extension/UrlboxExtensionTest.cs b/UrlboxSDK.MsTest/DI/Extension/UrlboxExtensionTest.cs index bed87cc..508f450 100644 --- a/UrlboxSDK.MsTest/DI/Extension/UrlboxExtensionTest.cs +++ b/UrlboxSDK.MsTest/DI/Extension/UrlboxExtensionTest.cs @@ -2,8 +2,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.VisualStudio.TestTools.UnitTesting; +using UrlboxSDK.Config.Resource; using UrlboxSDK.DI.Extension; -using UrlboxSDK.DI.Resource; namespace UrlboxSDK.MsTest.DI.Extension { diff --git a/UrlboxSDK.MsTest/DI/Resource/UrlboxConfigTest.cs b/UrlboxSDK.MsTest/DI/Resource/UrlboxConfigTest.cs index 01c173a..13e413c 100644 --- a/UrlboxSDK.MsTest/DI/Resource/UrlboxConfigTest.cs +++ b/UrlboxSDK.MsTest/DI/Resource/UrlboxConfigTest.cs @@ -1,6 +1,6 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; -using UrlboxSDK.DI.Resource; +using UrlboxSDK.Config.Resource; namespace UrlboxSDK.MsTest.DI.Resource { @@ -31,15 +31,6 @@ public void UrlboxConfig_ThrowsArgumentException_WhenSecretIsMissing() config.Validate(); } - [TestMethod] - [ExpectedException(typeof(ArgumentException))] - public void UrlboxConfig_ThrowsArgumentException_WhenBothKeyAndSecretAreMissing() - { - UrlboxConfig config = new(); - - config.Validate(); - } - [TestMethod] public void UrlboxConfig_CreatesInstance_WhenWebhookSecretIsNotProvided() { @@ -49,8 +40,6 @@ public void UrlboxConfig_CreatesInstance_WhenWebhookSecretIsNotProvided() Secret = "valid-secret" }; - config.Validate(); - Assert.IsNotNull(config); Assert.AreEqual("valid-key", config.Key); Assert.AreEqual("valid-secret", config.Secret); @@ -68,13 +57,32 @@ public void UrlboxConfig_CreatesInstance_WhenWebhookSecretIsProvided() WebhookSecret = "webhook-secret" }; - config.Validate(); - Assert.IsNotNull(config); Assert.AreEqual("valid-key", config.Key); Assert.AreEqual("valid-secret", config.Secret); Assert.AreEqual("webhook-secret", config.WebhookSecret); Assert.AreEqual(Urlbox.BASE_URL, config.BaseUrl); + Assert.IsTrue(config.ThrowOnUrlboxError); + } + + [TestMethod] + public void UrlboxConfig_CreatesInstance_BaseUrl_andThrowsSet() + { + UrlboxConfig config = new() + { + Key = "valid-key", + Secret = "valid-secret", + WebhookSecret = "webhook-secret", + BaseUrl = "https://example.com", + ThrowOnUrlboxError = false + }; + + Assert.IsNotNull(config); + Assert.AreEqual("valid-key", config.Key); + Assert.AreEqual("valid-secret", config.Secret); + Assert.AreEqual("webhook-secret", config.WebhookSecret); + Assert.AreEqual("https://example.com", config.BaseUrl); + Assert.IsFalse(config.ThrowOnUrlboxError); } } } \ No newline at end of file diff --git a/UrlboxSDK.MsTest/Factory/UrlboxFactoryTest.cs b/UrlboxSDK.MsTest/Factory/UrlboxFactoryTest.cs index 127d904..b15c78f 100644 --- a/UrlboxSDK.MsTest/Factory/UrlboxFactoryTest.cs +++ b/UrlboxSDK.MsTest/Factory/UrlboxFactoryTest.cs @@ -1,5 +1,6 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; +using UrlboxSDK.Config.Resource; using UrlboxSDK.Factory; namespace UrlboxSDK.MSTest.Factory @@ -21,7 +22,12 @@ public void Create_ShouldReturnInstanceOfIUrlbox() string key = "test-key"; string secret = "test-secret"; - var result = factory.Create(key, secret); + UrlboxConfig config = new() + { + Key = key, + Secret = secret + }; + var result = factory.Create(config); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IUrlbox)); @@ -33,25 +39,30 @@ public void Create_WithWebhookSecret_ShouldReturnValidInstance() string key = "test-key"; string secret = "test-secret"; string webhookSecret = "test-webhook-secret"; - - var result = factory.Create(key, secret, webhookSecret); + UrlboxConfig config = new() + { + Key = key, + Secret = secret, + WebhookSecret = webhookSecret + }; + var result = factory.Create(config); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IUrlbox)); } + [TestMethod] - [ExpectedException(typeof(ArgumentException))] - public void Create_ShouldThrowException_WhenKeyIsNull() + public void FromCredentials_Success() { - factory.Create(null!, "test-secret"); + Urlbox urlbox = UrlboxFactory.FromCredentials("test_key", "test_secret", "test_webhook"); + Assert.IsInstanceOfType(urlbox, typeof(Urlbox)); } [TestMethod] - [ExpectedException(typeof(ArgumentException))] - public void Create_ShouldThrowException_WhenSecretIsNull() + public void FromCredentials_Exception() { - factory.Create("test-key", null!); + Assert.ThrowsException(() => UrlboxFactory.FromCredentials("", "", "")); } } } \ No newline at end of file diff --git a/UrlboxSDK.MsTest/Resource/UrlboxBaseUrlTest.cs b/UrlboxSDK.MsTest/Resource/UrlboxBaseUrlTest.cs index 6218bd4..3d11bcd 100644 --- a/UrlboxSDK.MsTest/Resource/UrlboxBaseUrlTest.cs +++ b/UrlboxSDK.MsTest/Resource/UrlboxBaseUrlTest.cs @@ -1,4 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using UrlboxSDK.Config.Resource; +using UrlboxSDK.Factory; namespace UrlboxSDK.MsTest.Resource; @@ -8,18 +10,25 @@ public class UrlboxRegionTest [TestMethod] public void Baseurl_NotSet() { - Urlbox fromCredentials = Urlbox.FromCredentials("MY_API_KEY", "secret", "webhook_secret"); + Urlbox fromCredentials = UrlboxFactory.FromCredentials("MY_API_KEY", "secret", "webhook_secret"); Assert.IsInstanceOfType(fromCredentials, typeof(Urlbox)); - Urlbox fromNew = Urlbox.FromCredentials("MY_API_KEY", "secret", "webhook_secret"); + Urlbox fromNew = UrlboxFactory.FromCredentials("MY_API_KEY", "secret", "webhook_secret"); Assert.IsInstanceOfType(fromNew, typeof(Urlbox)); } [TestMethod] public void Baseurl_included() { - Urlbox fromCredentials = Urlbox.FromCredentials("MY_API_KEY", "secret", "webhook_secret", "someBaseUrl"); - Assert.IsInstanceOfType(fromCredentials, typeof(Urlbox)); - Urlbox fromNew = Urlbox.FromCredentials("MY_API_KEY", "secret", "webhook_secret", "someBaseUrl"); - Assert.IsInstanceOfType(fromNew, typeof(Urlbox)); + UrlboxFactory factory = new(); + UrlboxConfig config = new() + { + Key = "test-key", + Secret = "test-secret", + WebhookSecret = "test-webhook", + BaseUrl = "https://test-urlbox.com", + ThrowOnUrlboxError = false + }; + IUrlbox urlbox = factory.Create(config); + Assert.IsInstanceOfType(urlbox, typeof(Urlbox)); } } diff --git a/UrlboxSDK.MsTest/UrlboxTest.cs b/UrlboxSDK.MsTest/UrlboxTest.cs index ad8877d..a2d99fb 100644 --- a/UrlboxSDK.MsTest/UrlboxTest.cs +++ b/UrlboxSDK.MsTest/UrlboxTest.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using UrlboxSDK.Exception; using UrlboxSDK.MsTest.Utils; +using UrlboxSDK.Config.Resource; namespace UrlboxSDK.MsTest; @@ -134,28 +135,15 @@ public void TestInitialize() { client = new MockHttpClientFixture(); renderLinkFactory = new RenderLinkFactory("MY_API_KEY", "secret"); - urlbox = new(key: "MY_API_KEY", secret: "secret", webhookSecret: "webhook_secret", renderLinkFactory: renderLinkFactory, httpClient: client.HttpClient); - } - - [TestMethod] - public void FromCredentials_Success() - { - Urlbox urlbox = Urlbox.FromCredentials("test_key", "test_secret", "test_webhook"); - Assert.IsInstanceOfType(urlbox, typeof(Urlbox)); - } - - [TestMethod] - public void FromCredentials_Exception() - { - Assert.ThrowsException(() => Urlbox.FromCredentials("", "", "")); + UrlboxConfig config = new() + { + Key = "MY_API_KEY", + Secret = "secret", + WebhookSecret = "webhook_secret", + }; + urlbox = new(config, renderLinkFactory: renderLinkFactory, httpClient: client.HttpClient); } - [TestMethod] - public void WithBaseUrl_Exception() - { - Urlbox urlbox = Urlbox.FromCredentials("test_key", "test_secret", "test_webhook", baseUrl: "TEST"); - Assert.IsInstanceOfType(urlbox, typeof(Urlbox)); - } [TestMethod] public void GenerateRenderLink_WithAllOptions() @@ -305,7 +293,7 @@ public void GenerateRenderLink_IgnoreEmptyValuesAndFormat() [TestMethod] public void GenerateSignedRenderLink_Succeeds() { - UrlboxOptions options = new(url: "https://bbc.co.uk"); + UrlboxOptions options = Urlbox.Options(url: "https://bbc.co.uk").Build(); options.Format = Format.Jpeg; string output = urlbox.GenerateSignedRenderLink(options); Assert.AreEqual("https://api.urlbox.com/v1/MY_API_KEY/8e00ad9a8d7c4abcd462a9b8ec041c3661f13995/jpeg?url=https%3A%2F%2Fbbc.co.uk", output, "Not OK!"); @@ -314,8 +302,7 @@ public void GenerateSignedRenderLink_Succeeds() [TestMethod] public void GenerateRenderLink_FormatWorks() { - UrlboxOptions options = new(url: "https://bbc.co.uk"); - options.Format = Format.Avif; + UrlboxOptions options = Urlbox.Options(url: "https://bbc.co.uk").Format(Format.Avif).Build(); string output = urlbox.GenerateRenderLink(options); Assert.AreEqual("https://api.urlbox.com/v1/MY_API_KEY/8e00ad9a8d7c4abcd462a9b8ec041c3661f13995/avif?url=https%3A%2F%2Fbbc.co.uk", output, "Not OK!"); } @@ -323,10 +310,7 @@ public void GenerateRenderLink_FormatWorks() [TestMethod] public void GenerateRenderLink_WithHtml() { - UrlboxOptions options = new(html: "

test

") - { - FullPage = true - }; + UrlboxOptions options = Urlbox.Options(html: "

test

").FullPage().Build(); string output = urlbox.GenerateRenderLink(options); Assert.AreEqual("https://api.urlbox.com/v1/MY_API_KEY/931010e45a7936be4a6bc208e4ef0675fd216832/png?full_page=true&html=%3Ch1%3Etest%3C%2Fh1%3E", output); diff --git a/UrlboxSDK.MsTest/Webhook/Validator/UrlboxWebhookValidatorTest.cs b/UrlboxSDK.MsTest/Webhook/Validator/UrlboxWebhookValidatorTest.cs index 173c8af..245b4e8 100644 --- a/UrlboxSDK.MsTest/Webhook/Validator/UrlboxWebhookValidatorTest.cs +++ b/UrlboxSDK.MsTest/Webhook/Validator/UrlboxWebhookValidatorTest.cs @@ -1,5 +1,6 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; +using UrlboxSDK.Config.Resource; using UrlboxSDK.Webhook.Resource; namespace UrlboxSDK.MsTest.Webhook.Validator; @@ -12,7 +13,13 @@ public class UrlboxWebhookValidatorTests [TestInitialize] public void TestInitialize() { - urlbox = new Urlbox("key", "secret", "webhook_secret"); + UrlboxConfig config = new() + { + Key = "key", + Secret = "secret", + WebhookSecret = "webhook_secret" + }; + urlbox = new Urlbox(config); } [TestMethod] @@ -53,7 +60,6 @@ public void VerifyWebhookSignature_FailsNoSha() [TestMethod] public void Urlbox_createsWithWebhookValidator() { - Urlbox urlbox = new("key", "secret", "webhook"); // Shar of 'content' should not match 321, but method should run if 'webhook' passed. System.Exception result = Assert.ThrowsException(() => urlbox.VerifyWebhookSignature("t=123,sha256=321", "content")); @@ -66,7 +72,12 @@ public void Urlbox_createsWithWebhookValidator() [TestMethod] public void Urlbox_throwsWhenWithoutWebhookValidator() { - Urlbox urlbox = new("key", "secret"); + UrlboxConfig config = new() + { + Key = "key", + Secret = "secret" + }; + urlbox = new Urlbox(config); // Should throw bc no webhook set so no validator instance ArgumentException result = Assert.ThrowsException(() => urlbox.VerifyWebhookSignature("t=123,sha256=321", "content")); Assert.AreEqual(result.Message, "Please set your webhook secret in the Urlbox instance before calling this method."); diff --git a/UrlboxSDK/DI/Resource/UrlboxConfig.cs b/UrlboxSDK/Config/Resource/UrlboxConfig.cs similarity index 68% rename from UrlboxSDK/DI/Resource/UrlboxConfig.cs rename to UrlboxSDK/Config/Resource/UrlboxConfig.cs index 430c97b..7ebbe7f 100644 --- a/UrlboxSDK/DI/Resource/UrlboxConfig.cs +++ b/UrlboxSDK/Config/Resource/UrlboxConfig.cs @@ -1,6 +1,4 @@ -using UrlboxSDK; - -namespace UrlboxSDK.DI.Resource; +namespace UrlboxSDK.Config.Resource; /// /// Represents the config settings for Urlbox, specifically for DI. @@ -13,6 +11,7 @@ public class UrlboxConfig public string? Secret { get; set; } public string? WebhookSecret { get; set; } public string BaseUrl { get; set; } = Urlbox.BASE_URL; + public bool ThrowOnUrlboxError { get; set; } = true; /// /// Allows for parameterless construction of UrlboxConfig while still validating presence of key/secret @@ -20,14 +19,13 @@ public class UrlboxConfig /// public void Validate() { - if (string.IsNullOrWhiteSpace(Key)) + if (string.IsNullOrEmpty(Key)) { - throw new ArgumentException("UrlboxConfig.Key is required and cannot be null or empty."); + throw new ArgumentException("Please provide your Urlbox.com API Key"); } - - if (string.IsNullOrWhiteSpace(Secret)) + if (string.IsNullOrEmpty(Secret)) { - throw new ArgumentException("UrlboxConfig.Secret is required and cannot be null or empty."); + throw new ArgumentException("Please provide your Urlbox.com API Secret"); } } } \ No newline at end of file diff --git a/UrlboxSDK/DI/Extension/UrlboxExtension.cs b/UrlboxSDK/DI/UrlboxExtension.cs similarity index 81% rename from UrlboxSDK/DI/Extension/UrlboxExtension.cs rename to UrlboxSDK/DI/UrlboxExtension.cs index 405cd24..3848385 100644 --- a/UrlboxSDK/DI/Extension/UrlboxExtension.cs +++ b/UrlboxSDK/DI/UrlboxExtension.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using UrlboxSDK.DI.Resource; +using UrlboxSDK.Config.Resource; namespace UrlboxSDK.DI.Extension; /// @@ -26,11 +26,9 @@ public static IServiceCollection AddUrlbox( // Register Urlbox service with lifetime services.Add(new ServiceDescriptor(typeof(IUrlbox), serviceProvider => { - UrlboxConfig options = serviceProvider.GetRequiredService>().Value; - - options.Validate(); - - return new Urlbox(options.Key!, options.Secret!, options.WebhookSecret, options.BaseUrl); + UrlboxConfig config = serviceProvider.GetRequiredService>().Value; + config.Validate(); + return new Urlbox(config); }, lifetime)); return services; } diff --git a/UrlboxSDK/Factory/IUrlboxFactory.cs b/UrlboxSDK/Factory/IUrlboxFactory.cs index 433fcc3..beefa8b 100644 --- a/UrlboxSDK/Factory/IUrlboxFactory.cs +++ b/UrlboxSDK/Factory/IUrlboxFactory.cs @@ -1,14 +1,8 @@ +using UrlboxSDK.Config.Resource; + namespace UrlboxSDK.Factory; public interface IUrlboxFactory { - IUrlbox Create(string key, string secret, string? webhookSecret = null); -} - -public class UrlboxFactory : IUrlboxFactory -{ - public IUrlbox Create(string key, string secret, string? webhookSecret = null) - { - return new Urlbox(key, secret, webhookSecret); - } + IUrlbox Create(UrlboxConfig config); } diff --git a/UrlboxSDK/Factory/UrlboxFactory.cs b/UrlboxSDK/Factory/UrlboxFactory.cs new file mode 100644 index 0000000..5c8dca7 --- /dev/null +++ b/UrlboxSDK/Factory/UrlboxFactory.cs @@ -0,0 +1,37 @@ + +using UrlboxSDK.Config.Resource; + +namespace UrlboxSDK.Factory; + +public class UrlboxFactory : IUrlboxFactory +{ + public IUrlbox Create(UrlboxConfig config) + { + config.Validate(); + return new Urlbox(config); + } + + // STATIC + + /// + /// A static method to create a new instance of the Urlbox class + /// + /// + /// + /// + /// + /// A new instance of the Urlbox class. + /// Thrown when there is no api key or secret + public static Urlbox FromCredentials(string apiKey, string apiSecret, string? webhookSecret) + { + UrlboxConfig config = new() + { + Key = apiKey, + Secret = apiSecret, + WebhookSecret = webhookSecret, + ThrowOnUrlboxError = false + }; + config.Validate(); + return new Urlbox(config); + } +} diff --git a/UrlboxSDK/Urlbox.cs b/UrlboxSDK/Urlbox.cs index f4b7a01..cf2f62e 100644 --- a/UrlboxSDK/Urlbox.cs +++ b/UrlboxSDK/Urlbox.cs @@ -12,6 +12,7 @@ using System.Diagnostics.CodeAnalysis; using UrlboxSDK.Metadata.Resource; using System.Reflection; +using UrlboxSDK.Config.Resource; namespace UrlboxSDK; /// @@ -29,11 +30,10 @@ public sealed partial class Urlbox : IUrlbox private readonly string version = fullVersion.Split('+')[0]; // Trim the commit hash if present - private readonly string secret; + private readonly UrlboxConfig urlboxConfig; private readonly RenderLinkFactory renderLinkFactory; private readonly UrlboxWebhookValidator? urlboxWebhookValidator; private readonly HttpClient httpClient; - private readonly string baseUrl; public const string DOMAIN = "urlbox.com"; public const string BASE_URL = "https://api." + DOMAIN; private const string SYNC_ENDPOINT = "/v1/render/sync"; @@ -52,59 +52,33 @@ public static UrlboxOptionsBuilder Options( string? html = null ) => new(url, html); - public Urlbox(string key, string secret, string? webhookSecret = null, string? baseUrl = BASE_URL) + public Urlbox(UrlboxConfig config) { - if (string.IsNullOrEmpty(key)) - { - throw new ArgumentException("Please provide your Urlbox.com API Key"); - } - if (string.IsNullOrEmpty(secret)) - { - throw new ArgumentException("Please provide your Urlbox.com API Secret"); - } - this.secret = secret; - this.baseUrl = baseUrl ?? BASE_URL; + config.Validate(); + urlboxConfig = config; httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.UserAgent.ParseAdd($"Urlbox.net/{version}"); - renderLinkFactory = new RenderLinkFactory(key, secret); - if (!string.IsNullOrEmpty(webhookSecret)) + renderLinkFactory = new RenderLinkFactory(config.Key!, config.Secret!); + + if (!string.IsNullOrEmpty(config.WebhookSecret)) { - urlboxWebhookValidator = new UrlboxWebhookValidator(webhookSecret); + urlboxWebhookValidator = new UrlboxWebhookValidator(config.WebhookSecret); } } // Internal constructor (testable, allows injecting dependencies to mock http) [ExcludeFromCodeCoverage] - internal Urlbox(string key, string secret, RenderLinkFactory renderLinkFactory, HttpClient httpClient, string? webhookSecret = null, string? baseUrl = BASE_URL) + internal Urlbox(UrlboxConfig config, RenderLinkFactory renderLinkFactory, HttpClient httpClient) { - if (string.IsNullOrEmpty(key)) - { - throw new ArgumentException("Please provide your Urlbox.com API Key"); - } - if (string.IsNullOrEmpty(secret)) - { - throw new ArgumentException("Please provide your Urlbox.com API Secret"); - } - this.secret = secret; - this.baseUrl = baseUrl ?? BASE_URL; + config.Validate(); + urlboxConfig = config; this.renderLinkFactory = renderLinkFactory ?? throw new ArgumentNullException(nameof(renderLinkFactory)); this.httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); - } - // STATIC - - /// - /// A static method to create a new instance of the Urlbox class - /// - /// - /// - /// - /// - /// A new instance of the Urlbox class. - /// Thrown when there is no api key or secret - public static Urlbox FromCredentials(string apiKey, string apiSecret, string? webhookSecret, string? baseUrl = BASE_URL) - { - return new Urlbox(apiKey, apiSecret, webhookSecret, baseUrl); + if (!string.IsNullOrEmpty(config.WebhookSecret)) + { + urlboxWebhookValidator = new UrlboxWebhookValidator(config.WebhookSecret); + } } // PUBLIC @@ -446,7 +420,7 @@ public string GeneratePDFUrl(UrlboxOptions options, bool sign = true) /// A render link URL to render the content. public string GenerateRenderLink(UrlboxOptions options, bool sign = true) { - return renderLinkFactory.GenerateRenderLink(baseUrl, options, sign); + return renderLinkFactory.GenerateRenderLink(urlboxConfig.BaseUrl, options, sign); } /// @@ -457,7 +431,7 @@ public string GenerateRenderLink(UrlboxOptions options, bool sign = true) /// A render link URL to render the content. public string GenerateSignedRenderLink(UrlboxOptions options) { - return renderLinkFactory.GenerateRenderLink(baseUrl, options, sign: true); + return renderLinkFactory.GenerateRenderLink(urlboxConfig.BaseUrl, options, sign: true); } // ** Status and Validation Methods ** @@ -468,7 +442,7 @@ public string GenerateSignedRenderLink(UrlboxOptions options) /// public async Task GetStatus(string renderId) { - string statusUrl = $"{baseUrl}{STATUS_ENDPOINT}/{renderId}"; + string statusUrl = $"{urlboxConfig.BaseUrl}{STATUS_ENDPOINT}/{renderId}"; HttpResponseMessage response = await httpClient.GetAsync(statusUrl); if (response.IsSuccessStatusCode) @@ -593,7 +567,7 @@ private async Task MakeUrlboxPostRequest(string endpoint throw new ArgumentException("Response type must be Json when using POST methods in this SDK."); } - string url = baseUrl + endpoint; + string url = urlboxConfig.BaseUrl + endpoint; // UrlboxOptions uses it's own custom serialiser string optionsAsJson = Serialize.ToJson(options); @@ -603,7 +577,7 @@ private async Task MakeUrlboxPostRequest(string endpoint Content = new StringContent(optionsAsJson, Encoding.UTF8, "application/json") }; - request.Headers.Add("Authorization", $"Bearer {secret}"); + request.Headers.Add("Authorization", $"Bearer {urlboxConfig.Secret}"); JsonSerializerOptions deserializerOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, @@ -648,7 +622,7 @@ private async Task MakeUrlboxPostRequest(string endpoint { throw new ArgumentException("Endpoint must be one of /render/sync or /render/async."); } - string url = baseUrl + endpoint; + string url = urlboxConfig.BaseUrl + endpoint; JsonSerializerOptions serializeOptions = new() { PropertyNamingPolicy = new SnakeCaseNamingPolicy(), @@ -663,7 +637,7 @@ private async Task MakeUrlboxPostRequest(string endpoint Content = new StringContent(optionsAsJson, Encoding.UTF8, "application/json") }; - request.Headers.Add("Authorization", $"Bearer {secret}"); + request.Headers.Add("Authorization", $"Bearer {urlboxConfig.Secret}"); JsonSerializerOptions deserializerOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase,