Skip to content

Commit

Permalink
Merge pull request #218 from Mangopay/feature/configuration_for_UK
Browse files Browse the repository at this point in the history
Add a configuration for UK
  • Loading branch information
iulian03 authored Mar 8, 2024
2 parents a61e531 + 4f6c0d7 commit 37c8d8c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
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

0 comments on commit 37c8d8c

Please sign in to comment.