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 injectedCredentialsinstance.
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:
Credentialshandles authentication and attaches the Bearer token to each request. Refresh logic is encapsulated so callers do not manually manage tokens. - Thin HTTP wrapper:
Clientkeeps endpoints small and explicit; it accepts request parameters and returns parsed JSON (or content for documents).
Common Usage Patterns
- Pagination:
get_campaignssupportsfetch_all=Trueto automatically retrieve all pages. Iffetch_all=False, usepageandsizeto paginate manually. - Filtering:
get_campaign_installationsallows filtering by locations, carriers, components, and task types. - Document Retrieval:
fetch_documentretrieves 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/exceptas needed.
Development
Development of this package is realized via Dev Containers. This ensures a consistent environment for all developers.
Using Dev Containers (Recommended)
- Open the project in VS Code.
- When prompted, click Reopen in Container (or run the command
Dev Containers: Reopen in Container). - The environment will be automatically configured with all dependencies.
- Run tests using:
pytest
Support
In case you have any questions or suggestions please contact us: info@surquest.com
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file surquest_utils_poscore_client-0.0.5.tar.gz.
File metadata
- Download URL: surquest_utils_poscore_client-0.0.5.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e9fc670312e3f0a7878a3a719758df8c27bb19da9843fa4b42e6cdf02963a73
|
|
| MD5 |
c32924f1ee68f0702c2dc81070c1ce30
|
|
| BLAKE2b-256 |
9047179fc005d07811abb636137c0616e692fb827cb0553c7df6fccfdf722d51
|
File details
Details for the file surquest_utils_poscore_client-0.0.5-py3-none-any.whl.
File metadata
- Download URL: surquest_utils_poscore_client-0.0.5-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97cfc3c69a6e3e12d13c773f5fd267c46188069c2c4c9011da8183064b5a8c7e
|
|
| MD5 |
247c6502b2504beb43a48fa2876af860
|
|
| BLAKE2b-256 |
df3e0d545bfb5c1c8fd78cbc5428b8a3f7f0bcbf9e383937f6abf1d37723e7ca
|