Public/Build-ConnectorObject.ps1

<#
.SYNOPSIS
    Builds a connector object to be used with the Connector Data API.

.DESCRIPTION
    Creates a hashtable representing a connector object with a unique external identifier,
    an object type, and a data payload. The resulting object can be passed to
    Add-ConnectorSyncSessionObject or Build-ConnectorOperation.

.PARAMETER ExternalId
    A unique identifier for the object in the source system.

.PARAMETER ObjectType
    The type/category of the object (e.g., "User", "Group").

.PARAMETER Data
    A hashtable containing the object's attribute data.

.OUTPUTS
    System.Collections.Hashtable

.EXAMPLE
    $obj = Build-ConnectorObject -ExternalId "user-123" -ObjectType "User" -Data @{ DisplayName = "Jane Doe"; Email = "jane@example.com" }
#>

function Build-ConnectorObject {
    [CmdletBinding()]
    [OutputType([System.Collections.Hashtable])]
    param (
        [Parameter(Mandatory = $true)]
        [string] $ExternalId,
        
        [Parameter(Mandatory = $true)]
        [string] $ObjectType,

        [Parameter(Mandatory = $true)]
        [System.Collections.Hashtable] $Data
    ) 
    
    process {
        if([string]::IsNullOrEmpty($ObjectType)) {
            throw "ObjectType cannot be null"
        }

        if([string]::IsNullOrEmpty($ExternalId)) {
            throw "ExternalId cannot be null"
        }

        @{
            ExternalId = $ExternalId
            Data       = $Data
            ObjectType = $ObjectType
        }
    }
}