Skip to content

Email

domain.fetcher.ports.email

Summary

Email fetcher: pull statement messages from Gmail and convert them to omniread content.

Classes

EmailFetcher

1
2
3
4
5
EmailFetcher(
    credentials_path: str,
    token_path: str,
    scopes: List[str],
)

Fetch emails through Gmail and convert each message to :class:Content.

Notes

Lifecycle: Construction performs OAuth credential resolution once; a missing or expired token is refreshed automatically by the credential store.

Initialize the Gmail-backed email reader.

Parameters:

Name Type Description Default
credentials_path str

Path to the OAuth client credentials JSON.

required
token_path str

Path to the persisted OAuth token pickle.

required
scopes List[str]

OAuth scopes to request.

required
Functions
fetch
fetch(query: str) -> List[Content]

Return every message matching the Gmail query as content.

Parameters:

Name Type Description Default
query str

Gmail search query, e.g. from:x label:statements.

required

Returns:

Type Description
List[Content]

List[Content]: HTML content per matching message.