public/Update-FootballCompetitionTemplate.ps1
function Update-FootballCompetitionTemplate { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateSet('get-predictions','get-results')] [string]$Action, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Continent, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Object]$Header, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Path, [Parameter(Mandatory=$false)] [switch]$Refresh, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$SMToken, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Token ) process{ $ErrorActionPreference = 'Stop' if ($Action -eq 'get-predictions') { if ($Refresh) { Invoke-RemoveFootballCompetionData -Continent $Continent -Type predictions -Path $Path } # if $Predictions = Get-Content -Path "$Path\git-hub\sportsmonk-api\function-parameters\predictions-schedule.json" -ErrorAction Stop | ConvertFrom-Json | Where-Object {$_.Enabled -eq $true} Set-ActionState -Action get-predictions -Continent $Continent -Enabled true -DateRange $($Predictions.DateRange) -Path $Path | Format-Table Invoke-SportsmonkAutomation -Header $Header -Token $Token -SMToken $SMToken -Action get-predictions -Path $Path } # if if ($Action -eq 'get-results') { $Results = Get-Content -Path "$Path\git-hub\sportsmonk-api\function-parameters\results-schedule.json" -ErrorAction Stop | ConvertFrom-Json | Where-Object {$_.Enabled -eq $true} $ResultDateRange = $($Results.DateRange) Set-ActionState -Action get-results -Continent $Continent -Enabled true -DateRange $ResultDateRange -Path $Path | Format-Table Invoke-SportsmonkAutomation -Header $Header -Token $Token -SMToken $SMToken -Action get-results -Path $Path # Set the start date # 2025-05-17/2025-05-20 becomes 2025-05-17 $StartDate = $ResultDateRange.Split('/')[0] Invoke-PopulateFootballCompetitionTemplateAutomation -Header $Header -Token $Token -Continent $Continent -StartDate $StartDate -Type review -Path $Path } # if } # process } # function |