Public/New-JoinableCollection.ps1
|
<# .SYNOPSIS Creates a new joinable collection in the Fortytwo Collections API. .DESCRIPTION This function creates a new joinable collection in the Fortytwo Collections API. #> function New-JoinableCollection { [CmdletBinding(SupportsShouldProcess = $true)] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [System.Collections.Hashtable]$Collection ) process { # TODO: Add validation for the collection object to ensure it meets the required structure and properties. $URI = $Script:APIRoot -f "collections-joinable", "" $Body = $Collection | ConvertTo-Json -Depth 10 Write-Verbose "Creating Joinable Collection with at URI: $URI" $Result = Invoke-RestMethod -Method Post -Uri $URI -Headers (Get-CollectionHeader) -Body $Body -ContentType "application/json" if ($Result.IsSuccess) { Write-Verbose "Successfully created Joinable Collection with Id: $($Result.Data.Id)" } else { throw "Failed to create Joinable Collection: $($Result.Errors -join '; ')" } } } |