notifications/src/PSSailpoint.Notifications/Model/CcBccPreferenceEntry.ps1

#
# Identity Security Cloud API - Notifications
# Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.
# Version: v1
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

One CC or BCC routing entry. Dynamic recipient types are resolved at notification send time. Field applicability depends on type: IDENTITY and GOVERNANCE_GROUP require `id`; STATIC_EMAIL requires `email`; MANAGER_OF may optionally include `id` (manager of that identity, otherwise manager of the notification recipient); ORG_ADMINS does not use `id` or `email`.

.PARAMETER Type
No description available.
.PARAMETER Id
Identity or governance group id when required by the recipient type. For MANAGER_OF, when provided this is the identity whose manager should receive the email.
.PARAMETER Email
Static email address when type is STATIC_EMAIL.
.OUTPUTS

CcBccPreferenceEntry<PSCustomObject>
#>


function Initialize-CcBccPreferenceEntry {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("IDENTITY", "MANAGER_OF", "GOVERNANCE_GROUP", "ORG_ADMINS", "STATIC_EMAIL")]
        [PSCustomObject]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Email}
    )

    Process {
        'Creating PSCustomObject: PSSailpoint.Notifications => CcBccPreferenceEntry' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        if (!$Type) {
            throw "invalid value for 'Type', 'Type' cannot be null."
        }


        $PSO = [PSCustomObject]@{
            "type" = ${Type}
            "id" = ${Id}
            "email" = ${Email}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to CcBccPreferenceEntry<PSCustomObject>

.DESCRIPTION

Convert from JSON to CcBccPreferenceEntry<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

CcBccPreferenceEntry<PSCustomObject>
#>

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

    Process {
        'Converting JSON to PSCustomObject: PSSailpoint.Notifications => CcBccPreferenceEntry' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in CcBccPreferenceEntry
        $AllProperties = ("type", "id", "email")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        If ([string]::IsNullOrEmpty($Json) -or $Json -eq "{}") { # empty json
            throw "Error! Empty JSON cannot be serialized due to the required property 'type' missing."
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "type"))) {
            throw "Error! JSON cannot be serialized due to the required property 'type' missing."
        } else {
            $Type = $JsonParameters.PSobject.Properties["type"].value
        }

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

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

        $PSO = [PSCustomObject]@{
            "type" = ${Type}
            "id" = ${Id}
            "email" = ${Email}
        }

        return $PSO
    }

}