Public/New-ObservationScalars.ps1

<#
    .SYNOPSIS
    Creates an object that contains the observation and all the scalars

    .DESCRIPTION
    Creates the message body in hashtable form to send to the eCC Salesforce API to accept measurements

    .INPUTS
    None. You cannot pipe objects to New-ObservationScalars.

    .OUTPUTS
    The new PSCustomObject containing scalars

    .PARAMETER Observation
    The observation hashtable from New-Observation

    .PARAMETER Scalars
    An array of scalars from New-Scalar

    .LINK
    New-Observation
    New-Scalar
#>

function New-ObservationScalars {

    [CmdletBinding()]
    [OutputType([PSCustomObject])]
    param(
        [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline)]
        [ValidateNotNull()]
        [PSCustomObject]
        $Observation,

        [Parameter(Mandatory = $true, Position = 1)]
        [ValidateNotNull()]
        [PSCustomObject[]]
        $Scalars
    )
    begin {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
    }

    end {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
    }

    process {
        Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

        $post = @{}
        $post.body = @{ "observation" = $Observation }
        $i = 1
        $Scalars | ForEach-Object { $post.body."scalar-$($i)" = $_; $i++ } | Out-Null
        Write-Output $post
    }
}