Model/ErrorRepresentation.ps1

#
# Torizon OTA
# No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
# Version: 2.0-Beta
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Code
No description available.
.PARAMETER Description
No description available.
.PARAMETER Cause
No description available.
.PARAMETER ErrorId
No description available.
.OUTPUTS

ErrorRepresentation<PSCustomObject>
#>


function Initialize-TorizonPlatformAPIErrorRepresentation {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Code},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Cause},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ErrorId}
    )

    Process {
        'Creating PSCustomObject: TorizonPlatformAPI => TorizonPlatformAPIErrorRepresentation' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        if ($null -eq $Code) {
            throw "invalid value for 'Code', 'Code' cannot be null."
        }

        if ($null -eq $Description) {
            throw "invalid value for 'Description', 'Description' cannot be null."
        }


        $PSO = [PSCustomObject]@{
            "code" = ${Code}
            "description" = ${Description}
            "cause" = ${Cause}
            "errorId" = ${ErrorId}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to ErrorRepresentation<PSCustomObject>

.DESCRIPTION

Convert from JSON to ErrorRepresentation<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

ErrorRepresentation<PSCustomObject>
#>

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

    Process {
        'Converting JSON to PSCustomObject: TorizonPlatformAPI => TorizonPlatformAPIErrorRepresentation' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in TorizonPlatformAPIErrorRepresentation
        $AllProperties = ("code", "description", "cause", "errorId")
        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 'code' missing."
        }

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

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

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

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

        $PSO = [PSCustomObject]@{
            "code" = ${Code}
            "description" = ${Description}
            "cause" = ${Cause}
            "errorId" = ${ErrorId}
        }

        return $PSO
    }

}