Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a configuration for UK #218

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MangoPay.SDK/Core/APIs/ApiOAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public async Task<OAuthTokenDTO> 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<OAuthTokenDTO, CreateOAuthTokenPostDTO>(endPoint, null, entity);
}
Expand Down
3 changes: 3 additions & 0 deletions MangoPay.SDK/Core/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class Configuration
/// <summary>Timeout in miliseconds to use for API calls, set to zero to use the default .NET <see cref="HttpWebRequest"/> timeout of 100 seconds</summary>
public int Timeout = 0;

/// <summary>Set to true for uk traffic</summary>
public bool UKHeaderFlag = false;

/// <summary>API version (added in dashboard's SDK only in order to handle both old and new address fields).</summary>
public string ApiVersion = "v2.01";

Expand Down
3 changes: 3 additions & 0 deletions MangoPay.SDK/Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,8 @@ public static class Constants

/// <summary>Resolves to "WalletId" string.</summary>
public const string WALLET_ID = "WalletId";

/// <summary>Tenant header</summary>
public const string TENANT_ID = "x-tenant-id";
}
}
5 changes: 5 additions & 0 deletions MangoPay.SDK/Core/RestTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ private async Task<Dictionary<string, string>> 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;

Expand Down
Loading