Defines the JSON structure accepted by ONEm platform.
Project description
ONEm python client
Client which defines the JSON structure accepted by ONEm platform.
Quickstart
ONEm client works only with Python 3. You can use virtualenvwrapper to create a virtual environment.
On a linux box:
mkvirtualenv --python=`which python3` onem-py
Then install the ONEm client
pip install onem-py
Menu
In [1]: from onem import menus
In [2]: menu_item1 = menus.MenuItem('First menu item', '/callback-path-m1')
In [3]: menu_item2 = menus.MenuItem('Second menu item which is just content', is_option=False)
In [4]: menu = menus.Menu([menu_item1, menu_item2],
header='Menu header',
footer='Displayed at the bottom')
In [5]: menu.as_data()
Out[5]:
{'type': 'menu',
'header': 'Menu header',
'footer': 'Displayed at the bottom',
'body': [{'description': 'First menu item',
'method': 'GET',
'path': '/callback-path-m1',
'type': 'option'},
{'description': 'Second menu item which is just content',
'method': None,
'path': None,
'type': 'content'}],
'meta': None}
Form
In [1]: from onem import forms
In [2]: form_item1 = forms.FormItem('age', forms.FormItemType.INT, 'How old are you?')
In [3]: form_item2 = forms.FormItemMenu('is_number', [
...: forms.FormItemMenuItem('Age is just a number, right?', is_option=False),
...: forms.FormItemMenuItem('Yes!', value=True),
...: forms.FormItemMenuItem('Not really ...', value=False),
...: ])
In [4]: form = forms.Form([form_item1, form_item2],
...: '/form-callback-path-with-user-choices',
...: method='POST',
...: header='Form header',
...: footer='Form footer',
...: meta=forms.FormMeta(confirm=False))
In [5]: form.as_data()
Out[5]:
{'type': 'form',
'header': 'Form header',
'footer': 'Form footer',
'body': [{'description': 'How old are you?',
'footer': None,
'header': None,
'method': None,
'name': 'age',
'path': None,
'type': 'int'},
{'type': 'form-menu',
'header': None,
'footer': None,
'body': [{'description': 'Age is just a number, right?',
'type': 'content',
'value': None},
{'description': 'Yes!', 'type': 'option', 'value': True},
{'description': 'Not really ...', 'type': 'option', 'value': False}],
'meta': None,
'name': 'is_number'}],
'meta': {'completion_status_show': True,
'completion_status_in_header': True,
'confirmation_needed': False},
'path': '/form-callback-path-with-user-choices',
'method': 'POST'}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file onem_py-0.0.3-py3-none-any.whl.
File metadata
- Download URL: onem_py-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a72569e63e7560f5f0250d248892c6317f4c2db160c2b09be535e138d5058756
|
|
| MD5 |
52243ac0e672c77e8ea8ca7b6a53f483
|
|
| BLAKE2b-256 |
ec4be977b1170740c8cf09b7ed740687d42fd8a0665868cbd74baec335e4d938
|