https://github.com/pythonindia/junction-client
Python API client for junction
https://github.com/pythonindia/junction-client
Last synced: 7 months ago
JSON representation
Python API client for junction
- Host: GitHub
- URL: https://github.com/pythonindia/junction-client
- Owner: pythonindia
- License: mit
- Created: 2016-07-09T13:28:33.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-10T11:51:44.000Z (almost 10 years ago)
- Last Synced: 2024-12-28T17:34:16.385Z (over 1 year ago)
- Language: Python
- Size: 17.6 KB
- Stars: 3
- Watchers: 11
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Junction API client.
#### Installation
`pip install git+git://github.com/pythonindia/junction-client.git`
#### API
``` python
In [4]: from junction import JunctionClient
In [5]: client = JunctionClient('https://in.pycon.org/cfp/')
In [6]: client.conferences
Out[6]:
[,
,
,
,
]
In [7]: conf_2016 = client.conferences[0]
In [8]: conf_2016.venue
Out[8]:
In [9]: conf_2016.venue.rooms
Out[9]: [Room(id=5, name='Conference Hall', venue='http://in.pycon.org/cfp/api/v1/venues/2/', note='Conference Hall')]
In [10]: conf_2015 = client.conferences[-2]
In [11]: schdeule = conf_2015.schedule
In [12]: schedule = conf_2015.schedule
In [13]: schedule.
schedule.clear schedule.copy schedule.fromkeys schedule.get schedule.items schedule.keys schedule.pop schedule.popitem schedule.setdefault schedule.update schedule.values
In [14]: schedule.keys()
Out[14]: dict_keys(['2015-10-02', '2015-10-03', '2015-10-04'])
In [15]: schedule['2015-10-02']
Out[15]:
{'09:30:00 - 12:00:00': [,
,
],
'12:30:00 - 13:00:00': [],
'13:00:00 - 15:30:00': [,
,
],
'16:00:00 - 18:30:00': [,
,
]}
In [16]: schedule['2015-10-02']['16:00:00 - 18:30:00']
Out[16]:
[,
,
]
In [17]: item = schedule['2015-10-02']['16:00:00 - 18:30:00'][0]
In [18]: item.session
Out[18]:
In [19]: item.id
Out[19]: 8
In [20]: item.start_time
Out[20]: datetime.datetime(1900, 1, 1, 16, 0)
In [21]: item.type
Out[21]: 'Workshop'
In [22]: item.session.title
Out[22]: 'Building NextGen IoT solutions using Python and Cloud'
In [23]: item.session.to_native()
Out[23]:
{'author': 'Saurabh Kirtani',
'content_urls': '...',
'description': "...",
'id': 83,
'prerequisites': '...',
'section': 'Embedded Python',
'speaker_info': '..',
'speaker_links': '...',
'target_audience': 1,
'title': 'Building NextGen IoT solutions using Python and Cloud'}
In [24]: questions = conf_2015.feedback_questions
In [25]: questions
Out[25]:
{'Talk': ,
'Workshop': }
In [26]: questions['Talk']
Out[26]:
In [27]: questions['Talk'].text
Out[27]: []
In [28]: questions['Talk'].text[0].to_primitive()
Out[28]:
{'id': 1,
'is_required': False,
'schedule_item_type': 'Talk',
'title': 'Any other feedback for the talk ?',
'type': 'text'}
In [29]: questions['Talk'].choice[0].to_primitive()
Out[29]:
{'allowed_choices': [{'id': 18, 'title': 'Good', 'value': 2},
{'id': 17, 'title': 'Ok', 'value': 1},
{'id': 16, 'title': 'Bad', 'value': 0}],
'id': 6,
'is_required': True,
'schedule_item_type': 'Talk',
'title': 'Does the speaker have experience on the subject?',
'type': 'choice'}
In [30]: questions['Talk'].choice[1].allowed_choices
Out[30]:
[,
,
]
In [31]: questions['Talk'].choice[1].allowed_choices[0].id
Out[31]: 12
In [32]: questions['Talk'].choice[1].is_required
Out[32]: True
In [33]: conf_2016.get_token()
Out[33]: '6a6f531c-4692-11e6-8714-ac87a3379142'
In [34]: conf_2016.get_token()
Out[34]: '6a6f531c-4692-11e6-8714-ac87a3379142'
In [35]: conf_2016.get_token(force_fetch=True)
Out[35]: '77345ad4-4692-11e6-8ad3-ac87a3379142'
```
To submit a feedback, call `conf.submit_feedback(data)`. Before calling `submit_feedback`, call `conf.get_token()`.
The client is still in development mode. HTTP Docs is available in [Junction Repo](https://github.com/pythonindia/junction/blob/master/docs/api.md).