Experimental Python class abstraction layer for `spond` package.
Project description
Spond-classes
About
Spond is a team/group-oriented events system.
The unofficial Python spond
library package gets
data from the Spond API and returns dict
objects.
This unofficial Python spond-classes
package parses those dict
objects to create
class instances, i.e. provides an object abstraction layer.
Experimental, very partial, read-only implementation.
Install
Install from PyPI, e.g:
pip install spond-classes
Or if you're using Poetry:
poetry add spond-classes
Example code
Adapting the example code in Spond
README:
import asyncio
from spond import spond
import spond_classes
# fake credentials and ids
username = 'my@mail.invalid'
password = 'Pa55worD'
group_id = 'G1'
subgroup_id = 'SG1'
async def main():
s = spond.Spond(username=username, password=password)
group_data = await s.get_group(group_id)
await s.clientsession.close()
# Now we can create a class instance ...
group = spond_classes.Group(**group_data)
# ... use class properties instead of dict keys ...
print(group.name)
# ... access nested instances and their properties ...
for member in group.members:
print(f"{member.full_name} is in the {group.name} group")
# ... and use some helper methods
subgroup = group.subgroup_by_id(subgroup_id)
for member in group.members_by_subgroup(subgroup)
print(f"{member.full_name} is in the {subgroup.name} subgroup")
asyncio.run(main())
Key features
- Create
Group
instance from the dict returned from the API by the correspondingSpond
method:
spond_classes.Group(**dict)
- Then access class instance attributes and methods:
Group.uid: str
Group.members: list[Member]
Group.name: str
Group.roles: list[Role]
Group.subgroups: list[Subgroup]
Group.member_by_id() -> Member
Group.role_by_id() -> Role
Group.subgroup_by_id() -> Subgroup
Group.members_by_subgroup(subgroup: Subgroup) -> list[Member]
Group.members_by_role(role: Role) -> list[Member]
- Also provides access to nested
Member
,Role
,Subgroup
instances:
Member.uid: str
Member.created_time: datetime
Member.email: str
Member.first_name: str
Member.full_name: str
Member.last_name: str
Member.phone_number: str
Member.Profile.uid: str
Member.role_uids: list[str]
Member.subgroup_uids: list[str]
Role.uid: str
Role.name: str
Subgroup.uid: str
Subgroup.name: str
- Create
Event
instance from the dict returned from the API by the correspondingSpond
method:
spond_classes.Event(**dict)
- Then access attributes:
Event.uid: str
Event.heading: str
Event.start_time: datetime
Event.Responses.accepted_uids: list[str]
Event.Responses.declined_uids: list[str]
Event.Responses.unanswered_uids: list[str]
Event.Responses.waiting_list_uids: list[str]
Event.Responses.unconfirmed_uids: list[str]
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
spond_classes-0.10.0.post2.tar.gz
(18.9 kB
view hashes)
Built Distribution
Close
Hashes for spond_classes-0.10.0.post2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e2eb66fbb863c224fada28fab63d9f0cb653b34ff30f7237b392f2a5e7fca2d |
|
MD5 | e0ee117e4e3a4862f9ecfb2abc2d1e40 |
|
BLAKE2b-256 | 5f6365dc95c9d46a15c27e83344135e9b0ac1bf6dd5fda1e2a72397303935ca5 |
Close
Hashes for spond_classes-0.10.0.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c599d9a3cacf57c91304434a40cec29d7ede23cf57176e8875c032df754cc641 |
|
MD5 | 1bb4d9f8f894c3ad71f93da9842b33cc |
|
BLAKE2b-256 | 2670d6b9a9fcbad0ba279dfd5b48ab225edfa1e6de9e6ae1770ddf2b8a9cb6b4 |