Skip to main content

Ezeas Client API SDK (Python, async)

Project description

Ezeas Client SDK (Python)

Minimal async client for the Ezeas Client API using HS256 JWT.

This SDK is intended for backend integrations (Python 3.9+). It handles:

  • Generating and caching short-lived JWT access tokens using client_id and client_secret
  • Sending authenticated requests to the Ezeas Client API
  • Minimal error handling for business errors (4xx) vs internal errors (5xx)

Installation

From PyPI (production):

pip install ezeas-client

From TestPyPI (pre-release/testing):

pip install -i https://test.pypi.org/simple/ ezeas-client

Requires Python 3.9+.

Quick start

import asyncio
from ezeas_client import AsyncEzeasClient

async def main() -> None:
    client_id = "your-client-id"
    client_secret = "your-client-secret"

    async with AsyncEzeasClient(
        client_id=client_id,
        client_secret=client_secret,
        _base_url="https://www.ezeas.com",  # or "http://localhost:8000" for development
    ) as client:
        # Create contact
        contact_result = await client.create_contact(
            {
                "external_id": "EXT-123",
                "employee_number": "EMP-001",
                "first_name": "Jane",
                "last_name": "Doe",
                "mobile": "0400000000",
                "email": "jane.doe@example.com",
                "tenure_date": "2025-11-01",
            }
        )
        print("Contact result:", contact_result)

        # Create timesheet
        timesheet_result = await client.create_timesheet(
            {
                "job_code": "JOB-001",
                "timesheet_entries": [
                    {
                        "date": "2025-11-01",
                        "hours_ordinary": 8.0,
                        "hours_time_and_half": 2.0,
                        "hours_double_time": 0.0,
                    },
                    {
                        "date": "2025-11-02",
                        "hours_ordinary": 7.5,
                        "hours_time_and_half": 0.0,
                        "hours_double_time": 0.0,
                    },
                ],
            }
        )
        print("Timesheet result:", timesheet_result)

if __name__ == "__main__":
    asyncio.run(main())

Types

The SDK uses TypedDict internally. The logical shapes are:

from typing import TypedDict, List

class ContactInput(TypedDict):
    external_id: str
    employee_number: str
    first_name: str
    last_name: str
    mobile: str
    email: str
    tenure_date: str


class TimesheetEntry(TypedDict):
    date: str
    hours_ordinary: float
    hours_time_and_half: float
    hours_double_time: float


class TimesheetInput(TypedDict):
    job_code: str
    timesheet_entries: List[TimesheetEntry]

You can pass either these shapes or any plain dict with the same keys.

API

AsyncEzeasClient(client_id, client_secret, _base_url=None)

Creates a new async client instance.

  • client_id: string issued by Ezeas
  • client_secret: shared secret issued by Ezeas
  • _base_url: override base URL (defaults to https://www.ezeas.com)

The recommended usage is via async with:

async with AsyncEzeasClient(client_id, client_secret, _base_url="http://localhost:8000") as client:
    ...

await client.create_contact(data)

Creates a contact for the account associated with this client_id.

  • data: ContactInput (or a plain dict with the same shape)

Returns the parsed JSON response from the Ezeas API (or None if the response has no body).

await client.create_timesheet(data)

Creates a timesheet for the account associated with this client_id.

  • data: TimesheetInput (or a plain dict with the same shape)

Returns the parsed JSON response from the Ezeas API (or None if the response has no body).

Error handling

Internally, the SDK uses httpx.AsyncClient. The current behaviour is:

  • For 2xx responses:
    • Parses and returns JSON (or None if the body is empty).
  • For 4xx responses:
    • Raises Exception with the backend error payload as text.
  • For 5xx responses:
    • Raises Exception with a message in the form:
      • "Internal server error <status>: <body>"

You can wrap calls in your own try/except logic to map these to your application's error model.

Token format

The SDK generates short-lived JWT access tokens using HS256:

  • Header:
    • alg: "HS256"
    • typ: "JWT"
  • Payload:
    • sub: client_id
    • client_id: client_id
    • iat: issued-at (seconds since epoch)
    • exp: expiry (seconds since epoch, typically iat + 900)

The token is signed with client_secret.

The Ezeas API validates this token server-side and resolves the associated account from the client credentials.

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

ezeas_client-0.1.5.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ezeas_client-0.1.5-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file ezeas_client-0.1.5.tar.gz.

File metadata

  • Download URL: ezeas_client-0.1.5.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Windows/11

File hashes

Hashes for ezeas_client-0.1.5.tar.gz
Algorithm Hash digest
SHA256 f2ff7fb94855c2641af25b747ccd9d4f3ddde40713f3e69d6433a07eb6acd04f
MD5 7bf7b561c7a8e08fa61effd0d568c82e
BLAKE2b-256 6fc3c6565719cdf9aea6fde0342ec0ad13baac1ed403499f0118c0f67c7ff760

See more details on using hashes here.

File details

Details for the file ezeas_client-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: ezeas_client-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Windows/11

File hashes

Hashes for ezeas_client-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4a86774acd437cf41010298bd0599d68842abfae25497c81131196df5ef2f84d
MD5 dcd6a99367ac8dfbfbd00945e9be57f3
BLAKE2b-256 abdacdd3d8423fc01ae2bb92c7c35121eebadeb94ca625c412fcd01ebf3fd392

See more details on using hashes here.

Supported by

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