Public/Add-WebexMessage.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
<#
.SYNOPSIS
    Add-WebexMessage
.DESCRIPTION
    This will send a Webex message to a user or room
.EXAMPLE Add-WebexMessage
    PS :> Add-WebexMessage -token 'bottoken' -rooturl 'https://webexapis.com/v1/' -recipient_type 'Room' -recipient_value 'IdOfTheRoom' -message_type 'Text' - message_value 'Hello World'
.PARAMETER token
    Add the api token to authenticate with the api
.PARAMETER rooturl
    Add the root url of the api. https://webexapis.com/v1/
.PARAMETER recipient_type
    Add the recipient_type. "Room", "ParentMessage", "PersonId", "PersonEmail" are possible
.PARAMETER recipient_value
    Add the id of recipient_type
.PARAMETER message_type
    Add the message_type. "Text", "Markdown" are possible
.PARAMETER message_value
    Add the text of the message.
.NOTES
    Name: Add-WebexMessage
    Author: Clemens Richter
    DateCreated: 06.02.2021
.FUNCTIONALITY
    This will send a Webex message to a user or room
#>

function Add-WebexMessage {
    param (
        [parameter(position = 0, mandatory = $true)]
        [ValidateNotNullOrEmpty()] 
        [string]$token, 
        [parameter(position = 1, mandatory = $true)]
        [ValidateNotNullOrEmpty()] 
        [string]$rooturl,
        [parameter(position = 2, mandatory = $true)]
        [ValidateSet( "Room", "ParentMessage", "PersonId", "PersonEmail")]
        [string]$recipient_type,
        [parameter(position = 3, mandatory = $true)]
        [ValidateNotNullOrEmpty()] 
        [string]$recipient_value,
        [parameter(position = 4, mandatory = $true)]
        [ValidateSet( "Text", "Markdown")]
        [string]$message_type,
        [parameter(position = 5, mandatory = $true)]
        [ValidateNotNullOrEmpty()] 
        [string]$message_value
    )
    [WebexApiHelperClass] $webexapicaller = [WebexApiHelperClass]::new($token, $rooturl)
    $output = $webexapicaller.CreateMessage([string]$recipient_type, [string]$recipient_value, [string]$message_type, [string]$message_value)
    return $output
}