Model/EmailAddress.ps1

#
# Cloud Governance Api
# Contact: support@avepoint.com
#

<#
EmailAddress<PSCustomObject>
#>


function New-EmailAddress {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Prefix},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${GroupEmailAddress},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Suffix},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Domain},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ActivityId}
    )

    Process {
        'Creating PSCustomObject: Cloud.Governance.Client => EmailAddress' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        
        $PSO = [PSCustomObject]@{
            "Prefix" = ${Prefix}
            "GroupEmailAddress" = ${GroupEmailAddress}
            "Suffix" = ${Suffix}
            "Domain" = ${Domain}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }
}

<#
EmailAddress<PSCustomObject>
#>

function ConvertFrom-JsonToEmailAddress {
    Param(
        [AllowEmptyString()]
        [string]$Json
    )

    Process {
        'Converting JSON to PSCustomObject: Cloud.Governance.Client => EmailAddress' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in EmailAddress
        $AllProperties = $("Prefix", "GroupEmailAddress", "Suffix", "Domain", "ActivityId")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "Prefix"))) { #optional property not found
            $Prefix = $null
        } else {
            $Prefix = $JsonParameters.PSobject.Properties["Prefix"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "GroupEmailAddress"))) { #optional property not found
            $GroupEmailAddress = $null
        } else {
            $GroupEmailAddress = $JsonParameters.PSobject.Properties["GroupEmailAddress"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "Suffix"))) { #optional property not found
            $Suffix = $null
        } else {
            $Suffix = $JsonParameters.PSobject.Properties["Suffix"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "Domain"))) { #optional property not found
            $Domain = $null
        } else {
            $Domain = $JsonParameters.PSobject.Properties["Domain"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "ActivityId"))) { #optional property not found
            $ActivityId = $null
        } else {
            $ActivityId = $JsonParameters.PSobject.Properties["ActivityId"].value
        }

        $PSO = [PSCustomObject]@{
            "Prefix" = ${Prefix}
            "GroupEmailAddress" = ${GroupEmailAddress}
            "Suffix" = ${Suffix}
            "Domain" = ${Domain}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }

}