Model/SharingExpireSettingModel.ps1

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

<#
SharingExpireSettingModel<PSCustomObject>
#>


function New-SharingExpireSettingModel {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ExpireType} = "SameAsOrganization",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${ExpirationInDays} = 0
    )

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

        
        $PSO = [PSCustomObject]@{
            "ExpireType" = ${ExpireType}
            "ExpirationInDays" = ${ExpirationInDays}
        }

        return $PSO
    }
}

<#
SharingExpireSettingModel<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

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

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

        $PSO = [PSCustomObject]@{
            "ExpireType" = ${ExpireType}
            "ExpirationInDays" = ${ExpirationInDays}
        }

        return $PSO
    }

}