Model/DeviceInfoBasic.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 DeviceName
No description available.
.PARAMETER DeviceId
No description available.
.PARAMETER LastSeen
No description available.
.PARAMETER CreatedAt
No description available.
.PARAMETER ActivatedAt
No description available.
.PARAMETER DeviceStatus
No description available.
.PARAMETER Notes
No description available.
.OUTPUTS

DeviceInfoBasic<PSCustomObject>
#>


function Initialize-TorizonPlatformAPIDeviceInfoBasic {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DeviceName},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DeviceId},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${LastSeen},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [System.DateTime]
        ${CreatedAt},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${ActivatedAt},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("NotSeen", "Error", "UpToDate", "UpdatePending", "OutDated")]
        [PSCustomObject]
        ${DeviceStatus},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Notes}
    )

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

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

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

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

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


        $PSO = [PSCustomObject]@{
            "deviceName" = ${DeviceName}
            "deviceId" = ${DeviceId}
            "lastSeen" = ${LastSeen}
            "createdAt" = ${CreatedAt}
            "activatedAt" = ${ActivatedAt}
            "deviceStatus" = ${DeviceStatus}
            "notes" = ${Notes}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to DeviceInfoBasic<PSCustomObject>

.DESCRIPTION

Convert from JSON to DeviceInfoBasic<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

DeviceInfoBasic<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in TorizonPlatformAPIDeviceInfoBasic
        $AllProperties = ("deviceName", "deviceId", "lastSeen", "createdAt", "activatedAt", "deviceStatus", "notes")
        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 'deviceName' missing."
        }

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "deviceName" = ${DeviceName}
            "deviceId" = ${DeviceId}
            "lastSeen" = ${LastSeen}
            "createdAt" = ${CreatedAt}
            "activatedAt" = ${ActivatedAt}
            "deviceStatus" = ${DeviceStatus}
            "notes" = ${Notes}
        }

        return $PSO
    }

}