From c6f63d39ef08184458cd883a5b04679866519001 Mon Sep 17 00:00:00 2001 From: Gary Steers Date: Thu, 5 Mar 2020 08:17:45 +0000 Subject: [PATCH] Example for module usage --- examples/button.py | 32 ++++++++++++++++++++++++++++++++ examples/dateinput.py | 33 +++++++++++++++++++++++++++++++++ examples/input.py | 33 +++++++++++++++++++++++++++++++++ examples/message.py | 30 ++++++++++++++++++++++++++++++ examples/multipleoptions.py | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 examples/button.py create mode 100644 examples/dateinput.py create mode 100644 examples/input.py create mode 100644 examples/message.py create mode 100644 examples/multipleoptions.py diff --git a/examples/button.py b/examples/button.py new file mode 100644 index 0000000..09867c5 --- /dev/null +++ b/examples/button.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import sys,os +sys.path.append('../') +import teamswebhook as twh + +myhook = twh.MessageCard() + +myhook.channel_uri = 'https://outlook.office.com/webhook/CHANNELUUID/IncomingWebhook/WEBHOOKUUID' + +data = [ + {'Router': 'crN-lllN'}, + {'SomeText': 'Some other text'}, + {'Preformatted': '
\nsome output\n\twith an indent\n
'} +] + +myhook.title = 'Some title of a message' +myhook.subtitle = 'Some example subtitle' + +# Select an icon from icons.json array or put a URL/Base64 string +#myhook.icon = twh.stock_icons['cute']['firewall'] +#myhook.icon = twh.stock_icons['gradient']['system_task'] + +myhook.AddFacts(data) + +myhook.AddButton({'action_name': 'This is a button', 'button_label': 'Press Me', 'post_uri': 'https://example.com/postme'}) + +# Sends to Office365 +myhook.SendCard() + +# Prints out the JSON Card information +#myhook.PrintJSON() \ No newline at end of file diff --git a/examples/dateinput.py b/examples/dateinput.py new file mode 100644 index 0000000..46e1d17 --- /dev/null +++ b/examples/dateinput.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import sys,os +sys.path.append('../') +import teamswebhook as twh + +myhook = twh.MessageCard() + +myhook.channel_uri = 'https://outlook.office.com/webhook/CHANNELUUID/IncomingWebhook/WEBHOOKUUID' + +data = [ + {'Router': 'crN-lllN'}, + {'SomeText': 'Some other text'}, + {'Preformatted': '
\nsome output\n\twith an indent\n
'} +] + +myhook.title = 'Some title of a message' +myhook.subtitle = 'Some example subtitle' + +# Select an icon from icons.json array or put a URL/Base64 string +#myhook.icon = twh.stock_icons['cute']['firewall'] +#myhook.icon = twh.stock_icons['gradient']['system_task'] + +myhook.AddFacts(data) + +myhook.AddDateInput({'action_id': 'dateaction', 'action_name': 'This is a DateInput', 'button_label': 'Submit Date', 'input_hint': 'This is text that shows above the input', 'post_uri': 'https://example.com/postme', 'includetime': False}) +myhook.AddDateInput({'action_id': 'timeaction', 'action_name': 'This is a DateInput with Time', 'button_label': 'Submit Date/Time', 'input_hint': 'This is text that shows above the input', 'post_uri': 'https://example.com/postme', 'includetime': True}) + +# Sends to Office365 +myhook.SendCard() + +# Prints out the JSON Card information +#myhook.PrintJSON() \ No newline at end of file diff --git a/examples/input.py b/examples/input.py new file mode 100644 index 0000000..9f7e59d --- /dev/null +++ b/examples/input.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import sys,os +sys.path.append('../') +import teamswebhook as twh + +myhook = twh.MessageCard() + +myhook.channel_uri = 'https://outlook.office.com/webhook/CHANNELUUID/IncomingWebhook/WEBHOOKUUID' + +data = [ + {'Router': 'crN-lllN'}, + {'SomeText': 'Some other text'}, + {'Preformatted': '
\nsome output\n\twith an indent\n
'} +] + +myhook.title = 'Some title of a message' +myhook.subtitle = 'Some example subtitle' + +# Select an icon from icons.json array or put a URL/Base64 string +#myhook.icon = twh.stock_icons['cute']['firewall'] +#myhook.icon = twh.stock_icons['gradient']['system_task'] + +myhook.AddFacts(data) + +myhook.AddTextInput({'action_id': 'singleline', 'action_name': 'This is a TextInput Singleline', 'button_label': 'Single Text Input', 'input_hint': 'This is text that shows in the background of the input', 'post_uri': 'https://example.com/postme', 'multiline': False}) +myhook.AddTextInput({'action_id': 'multiline', 'action_name': 'This is a TextInput MultiLine', 'button_label': 'Multi Text Input', 'input_hint': 'This is text that shows in the background of the input', 'post_uri': 'https://example.com/postme', 'multiline': True}) + +# Sends to Office365 +myhook.SendCard() + +# Prints out the JSON Card information +#myhook.PrintJSON() \ No newline at end of file diff --git a/examples/message.py b/examples/message.py new file mode 100644 index 0000000..72d41fd --- /dev/null +++ b/examples/message.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import sys,os +sys.path.append('../') +import teamswebhook as twh + +myhook = twh.MessageCard() + +myhook.channel_uri = 'https://outlook.office.com/webhook/CHANNELUUID/IncomingWebhook/WEBHOOKUUID' + +data = [ + {'Router': 'crN-lllN'}, + {'SomeText': 'Some other text'}, + {'Preformatted': '
\nsome output\n\twith an indent\n
'} +] + +myhook.title = 'Some title of a message' +myhook.subtitle = 'Some example subtitle' + +# Select an icon from icons.json array or put a URL/Base64 string, can also be sent wihtout +#myhook.icon = twh.stock_icons['cute']['firewall'] +#myhook.icon = twh.stock_icons['gradient']['system_task'] + +myhook.AddFacts(data) + +# Sends to Office365 +myhook.SendCard() + +# Prints out the JSON Card information +#myhook.PrintJSON() \ No newline at end of file diff --git a/examples/multipleoptions.py b/examples/multipleoptions.py new file mode 100644 index 0000000..53e2fef --- /dev/null +++ b/examples/multipleoptions.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import sys,os +sys.path.append('../') +import teamswebhook as twh + +myhook = twh.MessageCard() + +myhook.channel_uri = 'https://outlook.office.com/webhook/CHANNELUUID/IncomingWebhook/WEBHOOKUUID' + +data = [ + {'Router': 'crN-lllN'}, + {'SomeText': 'Some other text'}, + {'Preformatted': '
\nsome output\n\twith an indent\n
'} +] + +myhook.title = 'Some title of a message' +myhook.subtitle = 'Some example subtitle' + +# Select an icon from icons.json array or put a URL/Base64 string +#myhook.icon = twh.stock_icons['cute']['firewall'] +#myhook.icon = twh.stock_icons['gradient']['system_task'] + +myhook.AddFacts(data) + +myhook.AddMultichoice({'action_id': 'multichoice', 'action_name': 'This is a MultiChoice Multiselect', 'button_label': 'Submit Choices', 'input_hint': 'Select all that apply', 'choices': [{'display': 'One', 'value': 1},{'display': 'Two', 'value': 2},{'display': 'Three', 'value': 13}], 'post_uri': 'https://example.com/postme', 'multiselect': True}) +myhook.AddMultichoice({'action_id': 'multichoice', 'action_name': 'This is a MultiChoice Singleselect', 'button_label': 'Submit Choice', 'input_hint': 'Select One', 'choices': [{'display': 'One', 'value': 1},{'display': 'Two', 'value': 2},{'display': 'Three', 'value': 13}], 'post_uri': 'https://example.com/postme'}) + +# Sends to Office365 +myhook.SendCard() + +# Prints out the JSON Card information +#myhook.PrintJSON() \ No newline at end of file