Skip to main content

Python client for POS Media Data Core APIs with credential handling and convenience helpers.

Project description

POS Media Data Core Python Client

Lightweight helper package for authenticating against POS Media Data Core and calling its Campaigns API from Python. The library exposes two primary objects:

  • Credentials: exchanges a username/password for a short-lived Bearer token.
  • Client: wraps Data Core endpoints (e.g., list campaigns, fetch campaign installations) using an injected Credentials instance.

Installation

pip install surquest-utils-poscore-client

Quickstart

from surquest.utils.poscore.credentials import Credentials
from surquest.utils.poscore.client import Client
import uuid

# Create token provider
creds = Credentials(
    username="your_username",
    password="your_password",
    # Optional: base_url="https://pos-core.pos-media.eu/gate/api/v1"
)

# Wire the authenticated client
client = Client(credentials=creds)

# 1) List campaigns
campaigns = client.get_campaigns(
    size=50,
    orderby="created desc",
    fetch_all=False # Set to True to auto-paginate through all results
)
for campaign in campaigns:
    print(f"Campaign: {campaign.name} with id: `{campaign.id}`

# 2) Get campaign installations
installations = client.get_campaign_installations(
    campaign_id=12345,
    locations=[], # Optional filters
    cm_carriers=[],
    components=[],
    task_types=[]
)
print(installations)

# 3) Fetch a document
doc_id = uuid.UUID("dc85d712-dc49-4e07-bb6c-876a6aa97ec6")
blob = client.fetch_document(document_id=doc_id, thumbnail=False)
print(f"Downloaded {blob.file_name} ({blob.content_type})")

# 4) Export all photos
blob = client.export_photos(
    campaign_id=12345
)

Concepts

  • Token handling: Credentials handles authentication and attaches the Bearer token to each request. Refresh logic is encapsulated so callers do not manually manage tokens.
  • Thin HTTP wrapper: Client keeps endpoints small and explicit; it accepts request parameters and returns parsed JSON (or content for documents).

Common Usage Patterns

  • Pagination: get_campaigns supports fetch_all=True to automatically retrieve all pages. If fetch_all=False, use page and size to paginate manually.
  • Filtering: get_campaign_installations allows filtering by locations, carriers, components, and task types.
  • Document Retrieval: fetch_document retrieves the binary content of a document along with its filename and content type.

Error Handling

  • Authentication errors: raised when credentials are invalid or tokens expire unexpectedly.
  • HTTP errors: surfaced with status codes and response bodies to aid debugging; wrap calls in try/except as needed.

Development

Development of this package is realized via Dev Containers. This ensures a consistent environment for all developers.

Using Dev Containers (Recommended)

  1. Open the project in VS Code.
  2. When prompted, click Reopen in Container (or run the command Dev Containers: Reopen in Container).
  3. The environment will be automatically configured with all dependencies.
  4. Run tests using:
    pytest
    

Support

In case you have any questions or suggestions please contact us: info@surquest.com

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

surquest_utils_poscore_client-0.0.5.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

surquest_utils_poscore_client-0.0.5-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file surquest_utils_poscore_client-0.0.5.tar.gz.

File metadata

File hashes

Hashes for surquest_utils_poscore_client-0.0.5.tar.gz
Algorithm Hash digest
SHA256 0e9fc670312e3f0a7878a3a719758df8c27bb19da9843fa4b42e6cdf02963a73
MD5 c32924f1ee68f0702c2dc81070c1ce30
BLAKE2b-256 9047179fc005d07811abb636137c0616e692fb827cb0553c7df6fccfdf722d51

See more details on using hashes here.

File details

Details for the file surquest_utils_poscore_client-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for surquest_utils_poscore_client-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 97cfc3c69a6e3e12d13c773f5fd267c46188069c2c4c9011da8183064b5a8c7e
MD5 247c6502b2504beb43a48fa2876af860
BLAKE2b-256 df3e0d545bfb5c1c8fd78cbc5428b8a3f7f0bcbf9e383937f6abf1d37723e7ca

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