-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSTriggerIfttt.psm1
56 lines (49 loc) · 1.46 KB
/
PSTriggerIfttt.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
Set-StrictMode -Version Latest
<#
.SYNOPSIS
Triggers an event on the IFTTT Maker Channel.
.DESCRIPTION
Send-IftttMakerEvent triggers an event on the IFTTT Maker Channel.
The particular event and 3 values can be specified when triggering.
.PARAMETER EventName
The name of the event to trigger on the IFTTT Maker Channel.
.PARAMETER SecretKey
The secret key you got from IFTTT for triggering events on the Maker Channel.
.PARAMETER Value1
First value of the triggered event (ingredient Value1).
.PARAMETER Value2
Second value of the triggered event (ingredient Value2).
.PARAMETER Value3
Third value of the triggered event (ingredient Value3).
#>
function Send-IftttMakerEvent {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]$EventName,
[Parameter(Mandatory=$true)]
[string]$SecretKey,
[string]$Value1,
[string]$Value2,
[string]$Value3
)
$uri = 'https://maker.ifttt.com/trigger/{0}/with/key/{1}' -f $EventName, $SecretKey
$body = @{}
if ($Value1) {
$body.value1 = $Value1
}
if ($Value2) {
$body.value2 = $Value2
}
if ($Value3) {
$body.value3 = $Value3
}
$bodyJson = ConvertTo-Json $body
$arguments = @{
Uri = $uri
Method = 'Post'
ContentType = 'application/json'
Body = $bodyJson
}
Invoke-RestMethod @arguments
}