-
-
Save irwins/facde4d1518d6eb0bd1e26088153efea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region MessageCard function helpers | |
function MessageCard { | |
param([scriptblock]$ScriptBlock) | |
$newScript = "@{$($ScriptBlock.ToString())}" | |
$newScriptBlock = [scriptblock]::Create($newScript) | |
& $newScriptBlock | |
} | |
function section { | |
param([scriptblock]$ScriptBlock) | |
$newScript = "[Ordered]@{$($ScriptBlock.ToString())}" | |
$newScriptBlock = [scriptblock]::Create($newScript) | |
& $newScriptBlock | |
} | |
function fact { | |
param([scriptblock]$ScriptBlock) | |
$Invoked = $ScriptBlock.Invoke() | |
$Invoked.Keys | | |
ForEach-Object { | |
@{ | |
Name = $_ | |
Value = $Invoked.$_ | |
} | |
} | |
} | |
#endregion | |
#region Main | |
$NewMessage = MessageCard { | |
summary = 'This is the summary property' | |
title = "This is the card's title property" | |
text = 'This is the cards text property.' | |
sections = @( | |
section { | |
activityTitle = 'Activity Title' | |
activitySubtitle = 'Activity **Sub**Title' | |
images = @( | |
@{ | |
image = "http://connectorsdemo.azurewebsites.net/images/WIN12_Scene_01.jpg" | |
title = "This is the image alternate text Pic 01" | |
} | |
@{ | |
image = "http://connectorsdemo.azurewebsites.net/images/WIN12_Anthony_02.jpg" | |
title = "This is the image alternate text Pic 02" | |
} | |
) | |
PotentialAction = @( | |
@{ | |
'@type' = 'Actioncard' | |
Name = 'Comment' | |
Inputs = @( | |
@{ | |
'@type' = 'TextInput' | |
Id = 'Comment' | |
isMultiLine = $true | |
Title = 'Input title property' | |
} | |
) | |
Actions = @( | |
@{ | |
'@type' = 'HttpPOST' | |
Name = 'Save' | |
Target = 'http://...' | |
} | |
) | |
} | |
@{ | |
'@type' = 'Actioncard' | |
Name = 'Due Date' | |
Inputs = @( | |
@{ | |
'@type' = 'DateInput' | |
Id = 'dueDate' | |
Title = 'Input due date' | |
} | |
) | |
Actions = @( | |
@{ | |
'@type' = 'HttpPOST' | |
Name = 'Save' | |
Target = 'http://...' | |
} | |
) | |
} | |
) | |
} | |
section { | |
title = 'Details:' | |
facts = fact { | |
@{ | |
GivenName = 'Irwin' | |
SurName = 'Strachan' | |
} | |
} | |
} | |
section { | |
activityTitle = 'Default MD Support' | |
activitySubtitle = 'Activity **Subtitle**' | |
facts = fact { | |
@{ | |
Email = 'Irwin@DosSantos.ca' | |
WebSite = '[pshirwins](https://pshirwin.wordpress.com)' | |
} | |
} | |
} | |
) | |
} | |
$restparams = @{ | |
Uri = "Your WebHook Uri" | |
Method = 'POST' | |
Body = $($NewMessage | ConvertTo-Json -Depth 6) | |
ContentType = 'application/JSON' | |
} | |
Invoke-RestMethod @restparams | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment