Public/Get-SignRequest.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
41
42
43
44
45
46
47
48
49
<#
.SYNOPSIS
Get signing request
#>

function Get-SignRequest {
    [CmdletBinding()]
    param (
        # Request id
        [Parameter(Mandatory=$false)]
        [string]
        $id,

        #0 = All requests , 1 = Received by the current user, 2 = Sent by the current user
        [Parameter(Mandatory=$false)]
        [int]
        $mode=0,
        #0 = Draft,1 = Waiting for the current user,2 = Waiting for other users,3 = Completed requests, 4 = Aborted requests
        [Parameter(Mandatory=$false)]
        [int]
        $status,
        #Indicates whether requests from all users should be shown
        [Parameter(Mandatory=$false)]

        [switch]
        $showAll
    )

    begin {
        $api = "/request"
        if ($id) { $api = $api +"/$id"}
        $body = @{ 'mode' = $mode }
        if ($showAll) { $body.showAll = $true}
        if ($status -ne $null) { $body.status = $status}
    }

    process {
        $result = Invoke-SignApi -api $api -Body $body  -method get
        if ($result.requests) {
            $result.requests
        } elseif ($result.request) {
            $result.request
        }
    }

    end {

    }
}