Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/powershell_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Run Pester Tests
shell: pwsh
run: |
Invoke-Pester -Path ./Scripts/Tests -CI
Invoke-Pester -Path ./ScheduledTasks/SettlementProcessing/Scripts/Tests -CI
2 changes: 1 addition & 1 deletion .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ jobs:
- name: Run Pester Tests
shell: pwsh
run: |
Invoke-Pester -Path ./Scripts/Tests -CI
Invoke-Pester -Path ./ScheduledTasks/SettlementProcessing/Tests -CI
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Get-AccessToken {
foreach ($propertyName in 'access_token', 'AccessToken', 'token', 'Token') {
if ($tokenResponse.ContainsKey($propertyName)) {
$accessToken = [string]$tokenResponse[$propertyName]
if (-not [string]::IsNullOrWhiteSpace($accessToken)) {
if (-not [string]::IsNullOrWhiteSpace($accessToken)) {
return $accessToken
}
}
Expand All @@ -63,7 +63,7 @@ function Get-AccessToken {
$property = $tokenResponse.PSObject.Properties[$propertyName]
if ($null -ne $property) {
$accessToken = [string]$property.Value
if (-not [string]::IsNullOrWhiteSpace($accessToken)) {
if (-not [string]::IsNullOrWhiteSpace($accessToken)) {
return $accessToken
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ function Get-MerchantId {
}

if ($Merchant -is [hashtable]) {
foreach ($propertyName in 'merchantId', 'MerchantId', 'id', 'Id') {
foreach ($propertyName in 'merchant_Id', 'MerchantId', 'id', 'Id') {
if ($Merchant.ContainsKey($propertyName)) {
$merchantId = [string]$Merchant[$propertyName]
if (-not [string]::IsNullOrWhiteSpace($merchantId)) {
Expand All @@ -136,7 +136,7 @@ function Get-MerchantId {
}
}
else {
foreach ($propertyName in 'merchantId', 'MerchantId', 'id', 'Id') {
foreach ($propertyName in 'merchant_Id', 'MerchantId', 'id', 'Id') {
$property = $Merchant.PSObject.Properties[$propertyName]
if ($null -ne $property) {
$merchantId = [string]$property.Value
Expand Down Expand Up @@ -175,20 +175,17 @@ function Invoke-DailySettlementProcessing {
}

$normalizedBaseUrl = $BaseUrl.TrimEnd('/')
$merchantsEndpoint = '{0}/api/v2/estates/{1}/merchants' -f $normalizedBaseUrl, $EstateId
Write-Verbose "Requesting merchants from [$merchantsEndpoint]"

$merchantsEndpoint = '{0}/api/estates/{1}/merchants' -f $normalizedBaseUrl, $EstateId

$merchantResponse = Invoke-RestMethod -Method Get -Uri $merchantsEndpoint -Headers $headers
$merchantIds = @(Get-MerchantItems -MerchantResponse $merchantResponse | ForEach-Object { Get-MerchantId -Merchant $_ })

if ($merchantIds.Count -eq 0) {
Write-Verbose "No merchants were returned for estate [$EstateId]"
return
}

foreach ($merchantId in $merchantIds) {
$settlementEndpoint = '{0}/api/estates/{1}/settlements/{2}/merchants/{3}' -f $normalizedBaseUrl, $EstateId, $settlementDate, $merchantId
Write-Verbose "Submitting settlement for merchant [$merchantId] using [$settlementEndpoint]"
Invoke-RestMethod -Method Post -Uri $settlementEndpoint -Headers $headers
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Describe 'Invoke-DailySettlementProcessing.ps1' {
}
} -ParameterFilter {
$Method -eq 'Get' -and
$Uri -eq 'https://api.example/api/v2/estates/estate-123/merchants' -and
$Uri -eq 'https://api.example/api/estates/estate-123/merchants' -and
$Headers.Authorization -eq 'Bearer access-token'
}

Expand All @@ -50,7 +50,7 @@ Describe 'Invoke-DailySettlementProcessing.ps1' {
}

Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter {
$Method -eq 'Get' -and $Uri -eq 'https://api.example/api/v2/estates/estate-123/merchants'
$Method -eq 'Get' -and $Uri -eq 'https://api.example/api/estates/estate-123/merchants'
}

$postedUris | Should -Be @(
Expand Down
52 changes: 0 additions & 52 deletions Scripts/DailySettlementProcessingTask.xml

This file was deleted.

Loading