Functions/Public/Test-BricksetAPIKey.psm1

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
41
42
43
44
45
46
47
48
49
50
function Test-BricksetAPIKey {
<#
    .SYNOPSIS
    Test the Brickset API Key
    
    .DESCRIPTION
    Test the Brickset API Key
    
    .PARAMETER APIKey
    API Key

    .INPUTS
    System.String.

    .OUTPUTS
    System.Boolean

    .EXAMPLE
    Test-BricksetAPIKey -APIKey 'Tk5C-KTA2-Gw2Q'
#>

[CmdletBinding()][OutputType('System.Boolean')]

    Param
    (

    [parameter(Mandatory=$true)]
    [ValidateNotNullOrEmpty()]
    [String]$APIKey
    )    

    try {

        # --- Make the Webservice Call
        $TestWebservice = New-WebServiceProxy -Uri 'http://brickset.com/api/v2.asmx?WSDL' -Namespace 'Brickset' -Class 'Sets'
        $CheckKey = $TestWebservice.checkKey($APIKey)

        if ($CheckKey -eq 'OK'){

            Write-Output $true
        }
        else {

            Write-Output $false
        }
    }
    catch [Exception]{
            
        throw
    }
}