Public/Add-SignRequestRecipient.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<#
    .SYNOPSIS
    Adds recipient to signing request
 
    .DESCRIPTION
    Adds Directory user, Contact , New invitation or Contact Group to signing request
 
    .EXAMPLE
    Add recipient from email or contact list with email
    Add-SignRequestRecipient -id '130000000000001d' -recipient someone@somedomain.com
 
    .EXAMPLE
    Add new invite with email
    Add-SignRequestRecipient -id '130000000000001d' -recipient someonenew@somedomain.com -firstName New -lastName Invite -title 'Boss' -organizationName "New company" -phoneNumber '+3582345654345'
 
    #>


function Add-SignRequestRecipient {
    [CmdletBinding()]
    param (
        # Id of request
        [Parameter(Mandatory=$true)]
        [String]
        $id,

        # Phase number
        [Parameter(Mandatory=$false)]
        [int]
        $phaseNumber=0,

        # Recipient's identifier. This value can be anything of the following
        # - Directory users: user object ID, user ID (uid) or email address
        # - User's contact: contact object ID or email address
        # - New invitation: email address
        # - User's contact group: contact group object ID
        [Parameter(Mandatory=$true)]
        [string]
        $recipient,

        # Readonly user
        [Parameter(Mandatory=$false)]
        [bool]
        $readonly=$false,

        # First name
        [Parameter(Mandatory=$false)]
        [String]
        $firstName,

        # last name
        [Parameter(Mandatory=$false)]
        [String]
        $lastName,

        #Title
        [Parameter(Mandatory=$false)]
        [string]
        $title,

        #Organization name
        [Parameter(Mandatory=$false)]
        [string]
        $organizationName,

        #Preferred language code ISO 639-2
        [Parameter(Mandatory=$false)]
        [string]
        $languageCode='fin',

        #Phone number
        [Parameter(Mandatory=$false)]
        [string]
        $phoneNumber

    )

    begin {


        $api = "/request/"+$id+"/add"
        $body  = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters -DefaultExcludeParameter 'id','debug','verbose','firstName','lastName','title','organizationName','languageCode','phoneNumber'

        if($null -eq $body['readonly']) {
            $body['readonly'] = $false
        }

        $body['phaseNumber'] = $phaseNumber

        $fields = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters -DefaultExcludeParameter 'id','phaseNumber','readonly','recipient','debug','verbose'

        if ($fields.Count -gt 1) {
            $body['fields'] = $fields
        }

    }

    process {
        Invoke-SignApi -api $api -body $body -method 'PATCH'
    }

    end {

    }
}