public/Get-FootballFixturePreMatchPublication.ps1
function Get-FootballFixturePreMatchPublication { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Competition, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Date, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Object]$Header, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Path, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Token ) process{ $ErrorActionPreference = 'Stop' $PathToUse = "$Path\$Competition\$Date\$Competition-240-$Date.csv" $PathExists = Test-Path -Path $PathToUse if ($PathExists) { $AllFixtures = Import-Csv -Path $PathToUse $Response = Invoke-RestMethod -Uri "https://api.sportmonks.com/v3/football/news/pre-match/upcoming?api_token=$Token&include=lines" -Method 'GET' -Headers $Header foreach ($Fixture in $AllFixtures) { $FixtureNews = $($Response.data) | Where-Object {$_.fixture_id -eq $($Fixture.FixtureId)} $NewsIntroduction = $($FixtureNews.lines) | Where-Object {$_.type -eq 'Introduction'} $NewsHome = $($FixtureNews.lines) | Where-Object {$_.type -eq 'home'} $NewsAway = $($FixtureNews.lines) | Where-Object {$_.type -eq 'away'} Write-Host Write-Host $FixtureNews | Select-Object -ExcludeProperty lines Write-Host "Fixture: $($Fixture.FixtureName)" Write-Host "Kick Off: $($Fixture.StartingAt)" Write-Host Write-Host '-- News Title' Write-Host $($FixtureNews.title) Write-Host Write-Host '-- News introduction' Write-Host $($NewsIntroduction.text) Write-Host Write-Host '-- News home' Write-Host $($NewsHome.text) Write-Host Write-Host '-- News away' Write-Host $($NewsAway.text) } # foreach } # if } # process } # function |