From 4f6c0d7f36d405d5b40fb6f5f919d63a096028d7 Mon Sep 17 00:00:00 2001 From: Mihai Moiseanu Date: Tue, 5 Mar 2024 11:55:32 +0200 Subject: [PATCH] add header for uk traffic --- MangoPay.SDK/Core/APIs/ApiOAuth.cs | 4 ++++ MangoPay.SDK/Core/Configuration.cs | 3 +++ MangoPay.SDK/Core/Constants.cs | 3 +++ MangoPay.SDK/Core/RestTool.cs | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/MangoPay.SDK/Core/APIs/ApiOAuth.cs b/MangoPay.SDK/Core/APIs/ApiOAuth.cs index 3b66b943..7f87b005 100644 --- a/MangoPay.SDK/Core/APIs/ApiOAuth.cs +++ b/MangoPay.SDK/Core/APIs/ApiOAuth.cs @@ -27,6 +27,10 @@ public async Task CreateTokenAsync(CreateOAuthTokenPostDTO entity restTool.AddRequestHttpHeader(Constants.AUTHORIZATION, $"{Constants.BASIC} {authHelper.GetHttpHeaderBasicKey()}"); restTool.AddRequestHttpHeader(Constants.CONTENT_TYPE, Constants.APPLICATION_X_WWW_FORM_URLENCODED); + if (Root.Config.UKHeaderFlag) + { + restTool.AddRequestHttpHeader(Constants.TENANT_ID, "uk"); + } return await restTool.RequestAsync(endPoint, null, entity); } diff --git a/MangoPay.SDK/Core/Configuration.cs b/MangoPay.SDK/Core/Configuration.cs index 71386904..35e911cd 100644 --- a/MangoPay.SDK/Core/Configuration.cs +++ b/MangoPay.SDK/Core/Configuration.cs @@ -20,6 +20,9 @@ public class Configuration /// Timeout in miliseconds to use for API calls, set to zero to use the default .NET timeout of 100 seconds public int Timeout = 0; + /// Set to true for uk traffic + public bool UKHeaderFlag = false; + /// API version (added in dashboard's SDK only in order to handle both old and new address fields). public string ApiVersion = "v2.01"; diff --git a/MangoPay.SDK/Core/Constants.cs b/MangoPay.SDK/Core/Constants.cs index cc7f2ff2..f68e00c8 100644 --- a/MangoPay.SDK/Core/Constants.cs +++ b/MangoPay.SDK/Core/Constants.cs @@ -129,5 +129,8 @@ public static class Constants /// Resolves to "WalletId" string. public const string WALLET_ID = "WalletId"; + + /// Tenant header + public const string TENANT_ID = "x-tenant-id"; } } diff --git a/MangoPay.SDK/Core/RestTool.cs b/MangoPay.SDK/Core/RestTool.cs index a1826b98..975016e1 100644 --- a/MangoPay.SDK/Core/RestTool.cs +++ b/MangoPay.SDK/Core/RestTool.cs @@ -552,6 +552,11 @@ private async Task> GetHttpHeadersAsync(string restUr { Constants.USER_AGENT, $"MangoPay V2 SDK .NET {_root.GetVersion()}" } }; + if (_root.Config.UKHeaderFlag) + { + httpHeaders.Add(Constants.TENANT_ID, "uk"); + } + // AuthenticationHelper http header if (!this._authRequired) return httpHeaders;