Public/Add-SignDocument.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
50
51
52
53
54
55
56
57
<#
.SYNOPSIS
Attach document to signing request
 
.DESCRIPTION
Uploads and attach document to signing request.
 
.EXAMPLE
Add-SignDocument -id '130000000000001d' -file some.pdf -data (New-SignDocumentMetadata)
 
Adds a document to signing request
 
.EXAMPLE
Add-SignDocument -id '130000000000001d' -file some.pdf -data (New-SignDocumentMetadata -signatureMode NotSigned)
 
Adds a document as attachment to signing request. Attachments are not signed.
 
 
 
#>


function Add-SignDocument {
    [CmdletBinding()]
    param (
        # Request id
        [Parameter(Mandatory=$false)]
        [string]
        $id,
        # Document to attach
        [Parameter(Mandatory=$true)]
        [ValidateScript({Test-Path $_ -PathType Leaf})]
        [string]
        $file,
        # Document metadata
        [Parameter(Mandatory=$true)]
        [System.Collections.IDictionary]
        $data
        )

    begin {
        $api = "/document/$id"
        $Body = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
        $Body['data']=  $Body['data'] | ConvertTo-Json -Depth 5

        if ($Body['file']) {$Body['file']= get-item $body['file']}

    }

    process {
        Invoke-SignApi -api $api -method 'POST' -body $Body
    }

    end {

    }
}