Model/AppInfo.ps1

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

<#
AppInfo<PSCustomObject>
#>


function New-AppInfo {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${LicenseId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PlanId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PlanName}
    )

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

        
        $PSO = [PSCustomObject]@{
            "LicenseId" = ${LicenseId}
            "PlanId" = ${PlanId}
            "PlanName" = ${PlanName}
        }

        return $PSO
    }
}

<#
AppInfo<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

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

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

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

        $PSO = [PSCustomObject]@{
            "LicenseId" = ${LicenseId}
            "PlanId" = ${PlanId}
            "PlanName" = ${PlanName}
        }

        return $PSO
    }

}