Pax8API/Public/Partner/New-Pax8Company.ps1

<#
.SYNOPSIS
Create Company
.DESCRIPTION
Creates a new company. You can optionally include contacts in the request body to create the company with contacts in a single request. If no contacts are provided, the company will be placed in an "inactive" status until the [company has primary contacts added](#tag/Contacts). Once contacts are added, the company will move to "Active".
OpenAPI: POST /companies
Scope: Partner. Audience: https://api.pax8.com.
.PARAMETER Name
The company name
.PARAMETER Address
body parameter 'address'.
.PARAMETER Phone
The primary phone number of the company
.PARAMETER Website
The full URL of the company website
.PARAMETER ExternalId
An external ID that can be assigned to the company for reference
.PARAMETER BillOnBehalfOfEnabled
Value is ```true``` if Pax8 handles billing transactions, value is ```false``` if partner handles billing transactions
.PARAMETER SelfServiceAllowed
Value is ```true``` if self-service privileges are available to the company, otherwise value is ```false```
.PARAMETER OrderApprovalRequired
Value is ```true``` if the company's self-service orders require approval, otherwise value is ```false```
.PARAMETER Contacts
Optional array of contacts to create with the company. Including contacts during company creation will set the company status to "Active" immediately.
.PARAMETER Body
Raw request body. This can be a hashtable, PSCustomObject, or pre-built JSON string.
.EXAMPLE
New-Pax8Company
.LINK
https://devx.pax8.com/openapi/partner-endpoints.json
#>

function New-Pax8Company {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$Name,

        [Parameter(Mandatory = $true)]
        [object]$Address,

        [Parameter(Mandatory = $true)]
        [string]$Phone,

        [Parameter(Mandatory = $true)]
        [string]$Website,

        [string]$ExternalId,

        [Parameter(Mandatory = $true)]
        [bool]$BillOnBehalfOfEnabled,

        [Parameter(Mandatory = $true)]
        [bool]$SelfServiceAllowed,

        [Parameter(Mandatory = $true)]
        [bool]$OrderApprovalRequired,

        [object[]]$Contacts,

        [Parameter(ValueFromPipeline = $true)]
        [object]$Body,

        [switch]$Raw
    )

    process {
        $boundParameters = @{}
        foreach ($entry in $PSBoundParameters.GetEnumerator()) {
            $boundParameters[$entry.Key] = $entry.Value
        }

        Invoke-Pax8ApiOperation -CommandName $MyInvocation.MyCommand.Name -Parameters $boundParameters
    }
}