Public/New-SurveyResponses.ps1

<#
    .SYNOPSIS
    Creates an survey responses object.

    .DESCRIPTION
    Creates the survey portion of the JSON message in hashtable form to send to the eCC Salesforce API to accept measurements and surveys.

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

    .OUTPUTS
    A PSCustomObject that contains the survey response data

    .PARAMETER SurveyQuestionId
    An survey question identifier.

    .PARAMETER AnswerIds
    A string array of answer ids for the question id specified
#>

function New-SurveyResponses {

    [CmdletBinding()]
    [OutputType([PSCustomObject])]
    param(
        [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline)]
        [ValidateNotNullOrEmpty()]
        [String]
        $SurveyQuestionId,

        [Parameter(Mandatory = $true, Position = 1)]
        [ValidateNotNullOrEmpty()]
        [String[]]
        $AnswerIds
    )

    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)"
        $aids = $AnswerIds | ForEach-Object { @{"Survey_Answer__c" = $_ } }
        Write-Output @{
            "Survey_Question__c" = $SurveyQuestionId
            "Answers"            = $aids
        }
    }
}