Skip to main content

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 library package parses those dict objects to create Pydantic class instances, i.e. provides an object abstraction layer.

Experimental, partial, read-only implementation.

Install

Install from PyPI, e.g:

pip install spond-classes

Or if you're using Poetry:

poetry add spond-classes

Note that spond is required for practical use, but not a technical dependency, so needs to be installed separately.

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.model_validate(group_data)
    # or `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 corresponding Spond method:
spond_classes.Group.model_validate(dict)
# or `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 corresponding Spond method:
spond_classes.Event.model_validate(dict)
# or 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


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.11.2.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

spond_classes-0.11.2-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file spond_classes-0.11.2.tar.gz.

File metadata

  • Download URL: spond_classes-0.11.2.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Windows/11

File hashes

Hashes for spond_classes-0.11.2.tar.gz
Algorithm Hash digest
SHA256 42e1c636b51671768c1dd6ed8126da2c5ddf122328feac2fe5c22575bf646761
MD5 5ba2379181af43bda8782210ce458c66
BLAKE2b-256 7c23f6b56585e49b2fbf6ed1d3768205b1718811892998c5e9431744b74bee71

See more details on using hashes here.

File details

Details for the file spond_classes-0.11.2-py3-none-any.whl.

File metadata

  • Download URL: spond_classes-0.11.2-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Windows/11

File hashes

Hashes for spond_classes-0.11.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1cbb38b93633e91526d7debc72ab99d8a2c5dc954ed0b4ac2d7a1e35290bcb97
MD5 67b441b6fc00622f007cc0b033e4dd01
BLAKE2b-256 b6baa7fc7625b88709ca6fa7c11bfcd66b9b4967074de5ceac4d70d6389cbe5e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page