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
Key features
- Create
Group
class instance from the dict returned by the correspondingspond
method:
spond_classes.Group.from_dict()
- Then access class instance attributes and methods:
Group.uid: str
Group.name: str
Group.members: List[Member]
Group.member_by_id() -> Member
Group.roles: List[SpondRoles]
Group.role_by_id() -> Role
Group.subgroups: List[Subgroup]
Group.subgroup_by_id() -> Subgroup
- Also provides access to child
Member
,Role
,Subgroup
instances:
Member.uid: str
Member.created_time: datetime
Member.first_name: str
Member.last_name: str
Member.full_name: str
Member.phone_number: str
Member.profile_uid: str
Member.roles: List[Role]
Member.subgroups: List[Subgroup]
Role.uid: str
Role.members: List[Member]
Role.name: str
Subgroup.uid: str
Subgroup.members: List[Member]
Subgroup.name: str
- Create
Event
class instance from the dict returned by the correspondingSpond
method:
spond_classes.Event.from_dict()
- Then access attributes:
Event.uid: str
Event.heading: str
Event.start_time: datetime
Event.accepted_uids: list
Event.declined_uids: list
Event.unanswered_uids: list
Event.waiting_list_uids: list
Event.unconfirmed_uids: list
It's also possible to create Member.from_dict()
, Role.from_dict()
,
Subgroup.from_dict()
.
Example code
Adapting the example code in Spond
README:
import asyncio
from spond import spond
import spond_classes
username = 'my@mail.invalid'
password = 'Pa55worD'
group_id = 'C9DC791FFE63D7914D6952BE10D97B46' # fake
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.from_dict(group_data)
# ... use class properties instead of dict keys ...
print(group.name)
# ... and access child instances and their properties
for member in group.members:
print(member.full_name)
asyncio.run(main())
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
Built Distribution
Hashes for spond_classes-0.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d343c197428f636b82ea736ff1aaa811005cfa100ac7222de3df0c1723ffb9ce |
|
MD5 | 414542f92326766d31d1b61b86c33be8 |
|
BLAKE2b-256 | 018f69c3a4c1df62bb912200254713fb5fd0912fbd9ad7695c901f35a4ad4331 |