public/New-FootballCompetitionStageStatisticObject.ps1
function New-FootballCompetitionStageStatisticObject { <# .SYNOPSIS Get-FootballCompetitionStageStatistic -Header $Headers -Token $Token -StageId 77471288 .LINK https://docs.sportmonks.com/football/definitions/types/statistics #> [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Object]$StageObject, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Object]$StatisticObject ) process{ $ErrorActionPreference try { foreach ($StageStat in $StatisticObject) { $StageStatType = ($StageStat.Type) if ($($StageStatType.Count) -lt 1) { continue } # if $Object1 = $($StageStat.value) $Object2 = $($StageStat.type) $PSObject = [PSCustomObject]@{} $PSObject | Add-Member -MemberType NoteProperty -Name type_id -Value $($StageStat.type_id) $PSObject | Add-Member -MemberType NoteProperty -Name model_id -Value $($StageStat.model_id) $Object1.PSObject.Properties | ForEach-Object -Process { Write-Warning -Message "Proccesing: $($_.Name), $($_.Value)" $PSObject | Add-Member -MemberType NoteProperty -Name "v_$($_.Name)" -Value $($_.Value) } $Object2.PSObject.Properties | ForEach-Object -Process { Write-Warning -Message "Proccesing: $($_.Name), $($_.Value)" $PSObject | Add-Member -MemberType NoteProperty -Name "t_$($_.Name)" -Value $($_.Value) } $StageObject.PSObject.Properties | ForEach-Object -Process { Write-Warning -Message "Proccesing: $($_.Name), $($_.Value)" $PSObject | Add-Member -MemberType NoteProperty -Name "s_$($_.Name)" -Value $($_.Value) } $PSObject } # if } catch { "$($MyInvocation.MyCommand.Name): $_.Exception.Message" } # try catch } # process } # function |