Skip to main content

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'}

Metadata

Release files for onem-py 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for onem-py 0.0.3
File Interpreter ABI Platform Actions
onem_py-0.0.3-py3-none-any.whl Python 3 none any Details for onem_py-0.0.3-py3-none-any.whl

Release files / onem_py-0.0.3-py3-none-any.whl

Download URL onem_py-0.0.3-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a72569e63e7560f5f0250d248892c6317f4c2db160c2b09be535e138d5058756
BLAKE2b-256 checksum
How to use checksums
ec4be977b1170740c8cf09b7ed740687d42fd8a0665868cbd74baec335e4d938
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for onem-py 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page