Skip to content

Commit

Permalink
added comments for Region.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
DjoykeAbyah committed Jan 7, 2025
1 parent 4b5ec21 commit 602c678
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
19 changes: 10 additions & 9 deletions Adyen.Test/RegionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ public void TestValidRegions()
{
// Get all valid regions from the Region enum
var validRegions = Enum.GetValues(typeof(Region))
.Cast<Region>()
.Select(r => r.ToString().ToLower())
.ToList();
.Cast<Region>()
.Select(r => r.ToString().ToLower())
.ToList();

// Define the expected list of valid regions
var expected = new List<string>
{
"eu",
"au",
"us",
"in",
"apse"
"apse",
"in"
};

// Assert that the valid regions match the expected list
Expand All @@ -37,10 +37,10 @@ public void TestTerminalApiEndpointsMapping()
{
// Convert TERMINAL_API_ENDPOINTS_MAPPING keys to lowercase strings for comparison
var actual = RegionMapping.TERMINAL_API_ENDPOINTS_MAPPING
.ToDictionary(
entry => entry.Key.ToString().ToLower(),
entry => entry.Value
);
.ToDictionary(
entry => entry.Key.ToString().ToLower(),
entry => entry.Value
);

// Define the expected map of region to endpoint mappings
var expected = new Dictionary<string, string>
Expand All @@ -54,5 +54,6 @@ public void TestTerminalApiEndpointsMapping()
// Assert that the TERMINAL_API_ENDPOINTS_MAPPING matches the expected map
CollectionAssert.AreEquivalent(expected, actual);
}

}
}
39 changes: 30 additions & 9 deletions Adyen/Constants/Region.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,53 @@
using System.Collections.Generic;

namespace Adyen.Constants
{
/// <summary>
/// Enum to set region based urls for terminal api
/// https://docs.adyen.com/point-of-sale/design-your-integration/terminal-api/
/// Enum to set region-based URLs for the Terminal API.
/// Reference: https://docs.adyen.com/point-of-sale/design-your-integration/terminal-api/
/// </summary>
public enum Region
{
//Europe
/// <summary>
/// European Union region
/// </summary>
EU = 0,

//Australia
/// <summary>
/// Australia region
/// </summary>
AU = 1,

//US
/// <summary>
/// United States region
/// </summary>
US = 2,

//East Asia
APSE = 3
/// <summary>
/// Asia-Pacific, South East region
/// </summary>
APSE = 3,

/// <summary>
/// India region
/// </summary>
IN = 4
}

/// <summary>
/// A static class that provides mapping of regions to their respective Terminal API endpoints.
/// </summary>
public static class RegionMapping
{
public static readonly Dictionary<Region, string> TERMINAL_API_ENDPOINTS_MAPPING = new()
/// <summary>
/// Maps regions to their respective Terminal API live endpoints.
/// </summary>
public static readonly Dictionary<Region, string> TERMINAL_API_ENDPOINTS_MAPPING = new Dictionary<Region, string>()
{
{ Region.EU, "https://terminal-api-live.adyen.com" },
{ Region.AU, "https://terminal-api-live-au.adyen.com" },
{ Region.US, "https://terminal-api-live-us.adyen.com" },
{ Region.APSE, "https://terminal-api-live-apse.adyen.com" }
};
}
}
}

0 comments on commit 602c678

Please sign in to comment.