Skip to content

Commit 5302239

Browse files
committed
Added all classes to autodoc
1 parent 432169a commit 5302239

File tree

5 files changed

+164
-1
lines changed

5 files changed

+164
-1
lines changed

docs/images/cards_sample.png

42.9 KB
Loading

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The User Guide
3333
user/intro
3434
user/quickstart
3535
user/api
36+
user/cards
3637

3738

3839
The Development Community

docs/user/api.rst

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,5 +277,93 @@ Warnings
277277
:show-inheritance:
278278
:members:
279279

280+
.. _CardsAPI:
281+
282+
Cards and Buttons
283+
=================
284+
285+
.. autoclass:: webexteamssdk.cards.card.AdaptiveCard()
286+
287+
Components
288+
----------
289+
290+
.. autoclass:: webexteamssdk.cards.components.Image()
291+
:members:
292+
293+
.. automethod:: __init__
294+
295+
.. autoclass:: webexteamssdk.cards.components.TextBlock()
296+
:members:
297+
298+
.. automethod:: __init__
299+
300+
.. autoclass:: webexteamssdk.cards.components.Column()
301+
302+
.. autoclass:: webexteamssdk.cards.components.Fact()
303+
304+
.. autoclass:: webexteamssdk.cards.components.Choice()
305+
306+
Options
307+
-------
308+
309+
.. autoclass:: webexteamssdk.cards.options.VerticalContentAlignment()
310+
311+
.. autoclass:: webexteamssdk.cards.options.Colors()
312+
313+
.. autoclass:: webexteamssdk.cards.options.HorizontalAlignment()
314+
315+
.. autoclass:: webexteamssdk.cards.options.FontSize()
316+
317+
.. autoclass:: webexteamssdk.cards.options.FontWeight()
318+
319+
.. autoclass:: webexteamssdk.cards.options.BlockElementHeight()
320+
321+
.. autoclass:: webexteamssdk.cards.options.Spacing()
322+
323+
.. autoclass:: webexteamssdk.cards.options.ImageSize()
324+
325+
.. autoclass:: webexteamssdk.cards.options.ImageStyle()
326+
327+
.. autoclass:: webexteamssdk.cards.options.ContainerStyle()
328+
329+
.. autoclass:: webexteamssdk.cards.options.TextInputStyle()
330+
331+
.. autoclass:: webexteamssdk.cards.options.ChoiceInputStyle()
332+
333+
334+
Container
335+
---------
336+
337+
.. autoclass:: webexteamssdk.cards.container.Container()
338+
339+
.. autoclass:: webexteamssdk.cards.container.ColumnSet()
340+
341+
.. autoclass:: webexteamssdk.cards.container.FactSet()
342+
343+
.. autoclass:: webexteamssdk.cards.container.ImageSet()
344+
345+
Inputs
346+
------
347+
348+
.. autoclass:: webexteamssdk.cards.inputs.Text()
349+
350+
.. autoclass:: webexteamssdk.cards.inputs.Number()
351+
352+
.. autoclass:: webexteamssdk.cards.inputs.Date()
353+
354+
.. autoclass:: webexteamssdk.cards.inputs.Time()
355+
356+
.. autoclass:: webexteamssdk.cards.inputs.Toggle()
357+
358+
.. autoclass:: webexteamssdk.cards.inputs.Choices()
359+
360+
Actions
361+
-------
362+
363+
.. autoclass:: webexteamssdk.cards.actions.OpenUrl
364+
365+
.. autoclass:: webexteamssdk.cards.actions.Submit
366+
367+
.. autoclass:: webexteamssdk.cards.actions.ShowCard
280368

281369
*Copyright (c) 2016-2019 Cisco and/or its affiliates.*

docs/user/cards.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.. _Cards:
2+
3+
=================
4+
Cards and Buttons
5+
=================
6+
7+
Webex Teams supports `AdaptiveCards <https://www.adaptivecards.io/>`_ to allow
8+
new levels of interactivity for bots and integrations. You can read more about
9+
how cards and buttons work `in the official guide <https://developer.webex.com/docs/api/guides/cards>`_.
10+
11+
In this guide I want to cover the abstraction build into the webexteamssdk that
12+
lets you author adaptive cards in pure python without having to touch the
13+
underlying json of a adaptive card.
14+
15+
Lets dive into a simple example that sends a card to a room
16+
17+
.. code-block:: python
18+
19+
from webexteamssdk import WebexTeamsAPI
20+
from webexteamssdk.cards.card import AdaptiveCard
21+
from webexteamssdk.cards.inputs import Text, Number
22+
from webexteamssdk.cards.components import TextBlock
23+
from webexteamssdk.cards.actions import Submit
24+
25+
greeting = TextBlock("Hey hello there! I am a adaptive card")
26+
first_name = Text('first_name', placeholder="First Name")
27+
age = Number('age', placeholder="Age")
28+
29+
submit = Submit(title="Send me!")
30+
31+
card = AdaptiveCard(body=[greeting, first_name, age], actions=[submit])
32+
33+
api = WebexTeamsAPI()
34+
api.messages.create(text="fallback", roomId="...", cards=card)
35+
36+
The message we send with this code then looks like this in our Webex Teams
37+
client:
38+
39+
.. image:: ../images/cards_sample.png

webexteamssdk/cards/components.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from .abstract_components import Serializable
2626
from .utils import check_type
2727
from .options import BlockElementHeight, Spacing
28+
from .actions import OpenUrl, ShowCard, Submit
2829

2930
class MediaSource(Serializable):
3031
"""Defines the source of a Media element."""
@@ -76,7 +77,7 @@ def __init__(self,
7677
check_type(separator, bool, False, True)
7778
check_type(spacing, Spacing, False, True)
7879
check_type(id, str, False, True)
79-
80+
8081
self.type = "Media"
8182
self.sources = sources #Needs to be a list of media sources
8283
self.poster = poster
@@ -92,6 +93,8 @@ def __init__(self,
9293
'separator', 'spacing', 'id'
9394
])
9495
class Image(Serializable):
96+
"""Displays a image object"""
97+
9598
def __init__(self,
9699
url,
97100
altText=None,
@@ -105,6 +108,38 @@ def __init__(self,
105108
seperator=None,
106109
spacing=None,
107110
id=None):
111+
"""Create a new image component
112+
113+
Args:
114+
url(str): The URL to the image
115+
altText(str): Alternative text describing the image
116+
backgroundColor(str): Background color for transparent images.
117+
height(str, BlockElementHeight): Height of the image either as a
118+
pixel value(i.e. '50px') or as an instance of BlockElementHeight
119+
horizontalAlignmnet(HorizontalAlignment): Controls how the component
120+
is positioned within its parent.
121+
selectAction(OpenUrl, Submit): Option that is caried out when the
122+
card is selected.
123+
size(ImageSize): Controls the approximate size of the image.
124+
style(ImageStyle): The display style of this image.
125+
width(str): Width of the image as a pixel value (i.e. '50px')
126+
separator(bool): Draw a separating line when set to true
127+
spacing(Spacing): Specify the spacing of this component
128+
id(str): The id of this component
129+
130+
"""
131+
check_type(url, str, False, False)
132+
check_type(altText, str, False, True)
133+
check_type(backgroundColor, str, False, True)
134+
check_type(height, (str, BlockElementHeight), False, True)
135+
check_type(horizontalAlignment, horizontalAlignment, False, True)
136+
check_type(selectAction, (OpenUrl, Submit), False, True)
137+
check_type(size, ImageSize, False, True)
138+
check_type(style, ImageStyle, False, True)
139+
check_style(width, str, False, True)
140+
check_style(separator, bool, False, True)
141+
check_style(spacing, Spacing, False, True)
142+
check_style(id, str, False, True)
108143

109144
self.type = "Image"
110145
self.url = url

0 commit comments

Comments
 (0)