Public/FieldValueChanges/Get-AffinityFieldValueChange.ps1

<#
.Synopsis
    Read field-value-changes for a field_id
.DESCRIPTION
    This function returns a PSObject containing all the field-value-changes related to a given field_id.
.PARAMETER FieldID
    The field_id from Affinity
.PARAMETER FieldValueChangeActionTypeID
    The action_type key from Affinity
.EXAMPLE
    $FieldValueChanges = Get-AffinityListEntry -FieldID $ID
.OUTPUTS
    System.Management.Automation.PSObject
.NOTES
    Need to implement FieldValueChangeActionType parameter
.LINK
    https://api-docs.affinity.co/#field-value-changes
.LINK
    https://api-docs.affinity.co/#the-field-value-change-resource
.LINK
    https://api-docs.affinity.co/#get-field-values-changes
#>


function Get-AffinityFieldValueChange
{
    [CmdletBinding(PositionalBinding = $true)]
    [OutputType([System.Management.Automation.PSObject])]
    Param
    (
        # Affinity Field ID
        [Parameter(Mandatory = $true,
                   Position = 0)]
        [ValidateNotNullOrEmpty()]
        [long]
        $FieldID,

        # Affinity Field Value Change Action Type ID
        [Parameter(Mandatory = $false,
                   Position = 1)]
        [Alias("ActionTypeID")]
        [ValidateRange(0,2)]
        [int]
        $FieldValueChangeActionTypeID
    )

    Process {
        $Content = @{ 'field_id' = $FieldID }
        if ($FieldValueChangeActionTypeID) { $Content.add('action_type', $FieldValueChangeActionTypeID) }

        Invoke-AffinityAPIRequest -Method Get -Fragment 'field-value-changes' -Content $Content
    }
}