Private/Session/_Classes.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40


class CredentialDetails {
    [string] $Tenant
    [string] $ApiKey
    CredentialDetails($Tenant,$ApiKey){
        $this.ApiKey = $ApiKey
        $this.Tenant = $Tenant
        
    }
    [string]EncodedCredential(){
        Return [convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($this.Tenant + ":" + $this.ApiKey))
    }
    
}

class Session 
{
    [string] $Uri 
    [CredentialDetails] $User
    [bool]$isValid
    [string]$InvalidReason
    Session(){
        $this.isValid = $false
        $this.InvalidReason = "No user information provided"
    }
    Session([string]$Tenant,[string]$ApiKey) {
        $this.User = [CredentialDetails]::New($Tenant,$ApiKey) 
        $this.isValid = $true
        $this.Uri = "https://odata.bluedolphin.valueblue.nl"
    }
    Session([string] $Tenant,[string] $ApiKey,[string] $Uri) {
        $this.User = [CredentialDetails]::New($Tenant,$ApiKey) 
        $this.isValid  = $true
        $this.Uri = $Uri
    }
    
}