Model/DeliveryManagement.ps1

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

<#
DeliveryManagement<PSCustomObject>
#>


function New-DeliveryManagement {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${SpecifiedSenders},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${PredefinedSpecifiedSenders},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${SenderOptions} = "Inside",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ActivityId}
    )

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

        
        $PSO = [PSCustomObject]@{
            "SpecifiedSenders" = ${SpecifiedSenders}
            "PredefinedSpecifiedSenders" = ${PredefinedSpecifiedSenders}
            "SenderOptions" = ${SenderOptions}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }
}

<#
DeliveryManagement<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in DeliveryManagement
        $AllProperties = $("SpecifiedSenders", "PredefinedSpecifiedSenders", "SenderOptions", "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 "SpecifiedSenders"))) { #optional property not found
            $SpecifiedSenders = $null
        } else {
            $SpecifiedSenders = $JsonParameters.PSobject.Properties["SpecifiedSenders"].value
        }

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

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

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

        $PSO = [PSCustomObject]@{
            "SpecifiedSenders" = ${SpecifiedSenders}
            "PredefinedSpecifiedSenders" = ${PredefinedSpecifiedSenders}
            "SenderOptions" = ${SenderOptions}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }

}