Skip to content
Open
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 @@ -53,6 +53,7 @@
if ($tokenResponse.ContainsKey($propertyName)) {
$accessToken = [string]$tokenResponse[$propertyName]
if (-not [string]::IsNullOrWhiteSpace($accessToken)) {
Write-Host "Got an access token 1"

Check warning on line 56 in ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1#L56

File 'Invoke-DailySettlementProcessing.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
return $accessToken
}
}
Expand All @@ -64,6 +65,7 @@
if ($null -ne $property) {
$accessToken = [string]$property.Value
if (-not [string]::IsNullOrWhiteSpace($accessToken)) {
Write-Host "Got an access token 2"

Check warning on line 68 in ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1#L68

File 'Invoke-DailySettlementProcessing.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
return $accessToken
}
}
Expand Down Expand Up @@ -126,7 +128,7 @@
}

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 +138,7 @@
}
}
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 +177,20 @@
}

$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
Write-Host "Requesting merchants from [$merchantsEndpoint]"

Check warning on line 181 in ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1#L181

File 'Invoke-DailySettlementProcessing.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.

$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]"
Write-Host "No merchants were returned for estate [$EstateId]"

Check warning on line 187 in ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1#L187

File 'Invoke-DailySettlementProcessing.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
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]"
Write-Host "Submitting settlement for merchant [$merchantId] using [$settlementEndpoint]"

Check warning on line 193 in ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

ScheduledTasks/SettlementProcessing/Invoke-DailySettlementProcessing.ps1#L193

File 'Invoke-DailySettlementProcessing.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
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 Down
52 changes: 0 additions & 52 deletions Scripts/DailySettlementProcessingTask.xml

This file was deleted.

Loading