-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTervisTwilio.psm1
102 lines (86 loc) · 3.7 KB
/
TervisTwilio.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
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
$ModulePath = (Get-Module -ListAvailable TervisTwilio).ModuleBase
. $ModulePath\Definition.ps1
Set-GetTwilioCredentialScriptBlock -ScriptBlock {
Get-PasswordstatePassword -AsCredential -ID 5313
}
function Get-EmergencyAddress {
param (
$Name
)
$EmergencyResponseAddresses |
Where-Object Name -EQ $Name
}
function Get-VoiceURL {
param (
$Name
)
$voiceurls | Where-Object Name -EQ $Name
}
function Get-WhoHasHelpDeskPhone {
$HelpDeskNumberUrl = Get-TwilioIncomingPhoneNumbers Get-TwilioIncomingPhoneNumbers | select -ExpandProperty incoming_phone_numbers | where friendly_name -EQ "(941) 441-4563" | select -ExpandProperty voice_url
$PhoneKeeper = $VoiceURLs | where url -EQ $HelpDeskNumberUrl | select -ExpandProperty Name
Write-Host " $PhoneKeeper has the HelpDesk Phone"
}
function Get-EmergencyResponseLocationAddresses {
foreach ($EmergencyLocation in $EmergencyLocations) {
$EmergencyAddress = Get-EmergencyAddress -Name $EmergencyLocation.AddressName
$EmergencyAddress |
Add-Member -MemberType NoteProperty -Name Address2 -Value $EmergencyLocation.Name -Force -PassThru |
Add-Member -MemberType NoteProperty -Name DirectNumber -Value $EmergencyLocation.DirectNumber -Force -PassThru |
Add-Member -MemberType NoteProperty -Name FriendlyName -Value $EmergencyLocation.FriendlyName -Force -PassThru
}
}
function Add-TervisTwilioAddress {
param (
[Parameter(Mandatory,ValueFromPipeLinebyPropertyName)][String]$FriendlyName,
[Parameter(Mandatory,ValueFromPipeLinebyPropertyName)][String]$CustomerName,
[Parameter(Mandatory,ValueFromPipeLinebyPropertyName)][String]$Street,
[Parameter(Mandatory,ValueFromPipeLinebyPropertyName)][String]$City,
[Parameter(Mandatory,ValueFromPipeLinebyPropertyName)][String]$Region,
[Parameter(Mandatory,ValueFromPipeLinebyPropertyName)][String]$PostalCode,
[Parameter(Mandatory,ValueFromPipeLinebyPropertyName)][String]$IsoCountry
)
process {
$ExistingFriendlyName = Get-TwilioAddresses | select -ExpandProperty addresses | select -ExpandProperty friendly_name
if ($ExistingFriendlyName -eq $FriendlyName) {
(Write-Host "The address with the same Friendly_Name already existed")
} else {
Add-TwilioAddresses -FriendlyName $FriendlyName -CustomerName $CustomerName -Street $Street -City $City -Region $Region -PostalCode $PostalCode -IsoCountry $IsoCountry
}
}
}
function Set-TervisSipTrunkOnPhoneNumber {
param (
[Parameter(Mandatory,ValueFromPipeLine)][string]$FriendlyName,
$TrunkSid,
$ApiVersion,
$VoiceUrl,
$VoiceMethod,
$VoiceFallbackUrl,
$VoiceFallbackMethod,
$StatusCallback,
$StatusCallbackMethod,
$VoiceCallerIdLookup,
$VoiceApplicationSid,
$SmsUrl,
$SmsMethod,
$SmsFallbackUrl,
$SmsFallbackMethod,
$SmsApplicationSid,
$AccountSid,
$AddressSid
)
process {
Set-TwilioIncomingPhoneNumber -FriendlyName $FriendlyName -TrunkSid "TK59ae204b72e3b329cd361c0060c4e17c"
}
}
function Set-HelpDeskForwardedNumber {
param (
[Parameter(Mandatory)]
[ValidateSet('Arthur', 'Chris', 'Don', 'Hamilton', 'Hossein', 'Mark')]
$Name
)
$FriendlyName = Get-TwilioIncomingPhoneNumbers | Select-Object -ExpandProperty incoming_phone_numbers | Where-Object sid -EQ PNb766129700d9fb5bd08185748a598b07 | Select-Object -ExpandProperty friendly_name
$VoiceUrl = Get-VoiceURL -Name $Name | Select-Object -ExpandProperty URL
Set-TwilioIncomingPhoneNumber -FriendlyName $FriendlyName -VoiceUrl $VoiceUrl
}