Python package integrating with Litmos User and Teams API
Project description
Litmos REST API client for python 3.5>
Free software: BSD license
Installation
pip install litmos-api
Getting started
from litmos import Litmos
litmos = Litmos({apikey}, {source})
# --- User ---
# retrieve users
all_users = litmos.User.all()
# retrieve all users (with all information populated - default /users/all API endpoint only returns a subset of user fields)
# much longer than .all() as individual requests to /find/{user-id} for every user are made
all_users_with_full_details = litmos.User.all(True)
#find user by Id
user = litmos.User.find('rnjx2WaQOa11')
# search for user by username
user = litmos.User.search('beelzebub@pieshop.net')
# update JobTitle & City fields
user.JobTitle = 'Pie eater'
user.City = 'Pieland'
# save user
user.save()
# deactivate user
user.deactivate()
# create user
user = litmos.User.create({
'UserName': 'jobaba72@pieshop.net',
'FirstName': 'Jo',
'LastName': 'Baba72',
'Email': 'jobaba72@pieshop.net'
})
# remove all teams from user
user.remove_teams()
# delete user
# with Id
litmos.User.delete('YmrD112qlm41')
# instance
user.destroy()
# --- Team ---
# get all teams
all_teams = litmos.Team.all()
# find team by Id
team = litmos.Team.find('rnjx2WaQOa11')
# get team members
users = team.users()
# get team leaders
leaders = team.leaders()
# create team (at root level)
team = litmos.Team.create({'Name': 'A-Team','Description': 'I pity the fool!'})
# add sub-team
sub_team = litmos.Team()
sub_team.Name = 'B-Team'
sub_team.Description = 'Woohoo'
sub_team_id = team.add_sub_team(sub_team)
# assign courses to team
course1 = litmos.Course.find('d2cJSDvIU0c1')
course2 = litmos.Course.find('d2cJSDvIU0c2')
team.assign_courses([course1, course2])
# unassign courses to team
course1 = litmos.Course.find('d2cJSDvIU0c1')
course2 = litmos.Course.find('d2cJSDvIU0c2')
team.unassign_courses([course1, course2])
# --- Team members ---
# add users to team
user1 = litmos.User.find('rnjx2WaQOa11')
user2 = litmos.User.find('rnjx2WaQOa12')
team.add_users([user1, user2])
# remove users from team
team.remove_user(user2)
# --- Team leaders ---
# promote user
team.promote_team_leader(user1)
# demote user
team.demote_team_leader(user1)
Documentation
Development
To run the all tests run:
nosetests
Changelog
0.1.1 (2019-08-19)
Add assign and unassign courses methods to Team class.
0.1.0 (2016-12-07)
First release on PyPI.
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 Distribution
litmos-api-0.6.0.tar.gz
(27.2 kB
view hashes)
Built Distribution
Close
Hashes for litmos_api-0.6.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba28336536a294ee87977e9e94e72ffb5134be6fdba267a223465fe24b2bb6c2 |
|
MD5 | 83f9fde6b7287c9dfdf1e60700f31053 |
|
BLAKE2b-256 | 8ad24cac71a67d5074e96fe265083096c5ff09dad8c8600e7dac8053695af3c8 |