Skip to content

Using a template to create Remove CWMContact

Chris Taylor edited this page Apr 16, 2021 · 4 revisions

We will start by pulling up the Remove-CWMTemplate and, opening up the API documentation for the endpoint we are working with.

We create a new file Remove-CWMContact.ps1 in the appropriate directory and, update the function name to match. We then want to update the <Endpoint> to match the endpoint we are using.

function Remove-CWMContact {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Used by sub-function')]
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact='Medium')]
    param(
        [Parameter(Mandatory=$true)]
        [Alias('contactId')]
        [int]$id
    )

    $Endpoint = "/company/contacts/$($id)"
    return Invoke-CWMDeleteMaster -Endpoint $Endpoint
}

Remove endpoints are easy as the is nothing else that needs to be changed. This endpoint should be working now. Now we just need to make documentation