-
Notifications
You must be signed in to change notification settings - Fork 7
/
New-ICWorkgroup.ps1
83 lines (74 loc) · 2.38 KB
/
New-ICWorkgroup.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
<#
# AUTHOR : Pierrick Lozach
#>
function New-ICWorkgroup() # {{{2
{
# Documentation {{{3
<#
.SYNOPSIS
Creates a new CIC workgroup
.DESCRIPTION
Creates a new CIC workgroup
.PARAMETER ICSession
The Interaction Center Session
.PARAMETER ICWorkgroup
The Interaction Center Workgroup Identifier
.PARAMETER Extension
The Interaction Center Workgroup Extension
.PARAMETER Members
The Interaction Center Workgroup Members
#> # }}}3
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)] [Alias("Session", "Id")] [ININ.ICSession] $ICSession,
[Parameter(Mandatory=$true)] [Alias("Workgroup")] [string] $ICWorkgroup,
[Parameter(Mandatory=$false)] [string] $Extension,
[Parameter(Mandatory=$false)] [string[]] $Members,
[Parameter(Mandatory=$false)] [boolean] $HasQueue,
[Parameter(Mandatory=$false)] [string] $QueueType,
[Parameter(Mandatory=$false)] [boolean] $IsActive
)
$workgroupExists = Get-ICWorkgroup $ICSession -ICWorkgroup $ICWorkgroup
if (-not ([string]::IsNullOrEmpty($workgroupExists))) {
return
}
# Parameter validation
if (!$PSBoundParameters.ContainsKey('IsActive'))
{
$IsActive = $True
}
if (!$PSBoundParameters.ContainsKey('HasQueue'))
{
$HasQueue = $True
}
# Queue Type
$QueueTypeInt = 5 # Default is ACD
switch($QueueType.ToLower())
{
"none" { $QueueTypeInt = 0 }
"custom" { $QueueTypeInt = 1 }
"groupring" { $QueueTypeInt = 2 }
"sequential" { $QueueTypeInt = 3 }
"roundrobin" { $QueueTypeInt = 4 }
"acd" { $QueueTypeInt = 5 } # No need to add this but oh well...
}
if (!$PSBoundParameters.ContainsKey('QueueType'))
{
$QueueType = "ACD"
}
$headers = @{
"Accept-Language" = $ICSession.language;
"ININ-ICWS-CSRF-Token" = $ICSession.token;
}
$body = ConvertTo-Json(@{
"configurationId" = New-IcConfigurationId $ICWorkgroup
"extension" = $Extension
"hasQueue" = $HasQueue
"queueType" = 5
"isActive" = $IsActive
"members" = if ([string]::IsNullOrEmpty($Members)) { $null } else {@( $Members | foreach { New-ICConfigurationId $_ } )}
})
$response = Invoke-RestMethod -Uri "$($ICsession.baseURL)/$($ICSession.id)/configuration/workgroups" -Body $body -Method Post -Headers $headers -WebSession $ICSession.webSession -ErrorAction Stop
Write-Output $response | Format-Table
[PSCustomObject] $response
} # }}}2