Skip to content

Pthmint 108#54

Open
zulquer wants to merge 1 commit intomasterfrom
PTHMINT-108
Open

Pthmint 108#54
zulquer wants to merge 1 commit intomasterfrom
PTHMINT-108

Conversation

@zulquer
Copy link
Copy Markdown
Collaborator

@zulquer zulquer commented Apr 13, 2026

This pull request introduces several new Cloud POS and terminal management example scripts, improves environment variable configuration. It also adds new API managers to the public SDK interface. These changes collectively make it easier to work with Cloud POS flows, manage terminals and terminal groups, and configure the SDK for various environments.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.53%. Comparing base (463b422) to head (6194884).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
+ Coverage   90.94%   94.53%   +3.58%     
==========================================
  Files         147      178      +31     
  Lines        2607     3273     +666     
==========================================
+ Hits         2371     3094     +723     
+ Misses        236      179      -57     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the SDK to better support Cloud POS flows by introducing scoped credential resolution, adding an event streaming API (SSE) with an SDK convenience manager, and adding initial terminal management models/manager. It also adds/updates tests and new example scripts, plus .env.example entries, to demonstrate the new flows.

Changes:

  • Add CredentialResolver/ScopedCredentialResolver support and wire it into Client/Sdk, including auth-scope selection for terminal-group requests.
  • Add Events support (EventManager, EventStream) and normalize order event fields for backward compatibility.
  • Add Terminals support (TerminalManager, request/response models) plus new unit/integration tests and example scripts.

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
tests/multisafepay/unit/test_unit_sdk.py Adds SDK-level tests for resolver-only initialization and EventManager getter.
tests/multisafepay/unit/client/test_unit_credential_resolver.py New unit tests for scoped credential resolution behavior.
tests/multisafepay/unit/client/test_unit_client.py Updates client unit tests and adds resolver/transport test scaffolding.
tests/multisafepay/unit/api/path/terminals/response/test_unit_terminal_response.py New unit tests for the Terminal response model.
tests/multisafepay/unit/api/path/terminals/request/test_unit_create_terminal_request.py New unit tests for CreateTerminalRequest.
tests/multisafepay/unit/api/path/orders/response/test_unit_order_response.py New unit tests for plural/singular event-field normalization.
tests/multisafepay/unit/api/path/orders/manager/test_unit_order_manager.py New unit tests for terminal-group auth scoping in OrderManager.create.
tests/multisafepay/unit/api/path/events/test_unit_event_manager.py New unit tests for event subscription helpers.
tests/multisafepay/unit/api/path/events/stream/test_unit_event_stream.py New unit tests for SSE parsing and stream lifecycle handling.
tests/multisafepay/integration/api/path/orders/manager/test_integration_order_manager_create.py Updates order create assertion and adds scoped-auth integration-style test.
src/multisafepay/sdk.py Makes api_key optional when a resolver is provided; adds get_event_manager().
src/multisafepay/client/credential_resolver.py Introduces resolver protocol, auth-scope payload, and default scoped resolver implementation.
src/multisafepay/client/client.py Adds resolver wiring + auth_scope plumbing into request helpers and request creation.
src/multisafepay/api/paths/terminals/terminal_manager.py Adds TerminalManager with create/list endpoints for /json/terminals.
src/multisafepay/api/paths/terminals/response/terminal.py Adds Terminal response model.
src/multisafepay/api/paths/terminals/response/init.py Exports terminal response models.
src/multisafepay/api/paths/terminals/request/create_terminal_request.py Adds CreateTerminalRequest request model.
src/multisafepay/api/paths/terminals/request/init.py Exports terminal request models.
src/multisafepay/api/paths/terminals/init.py Exposes terminal API package entrypoint.
src/multisafepay/api/paths/orders/response/order_response.py Adds plural event fields and normalizes plural/singular compatibility in from_dict.
src/multisafepay/api/paths/orders/order_manager.py Adds terminal_group_id argument and passes terminal-group auth scope to client.
src/multisafepay/api/paths/events/stream/event_stream.py Adds SSE stream opener + parser (EventStream, Event).
src/multisafepay/api/paths/events/stream/init.py Exports event stream helpers.
src/multisafepay/api/paths/events/event_manager.py Adds EventManager subscription helpers (direct and from Order).
src/multisafepay/api/paths/events/init.py Exposes events API package entrypoint.
src/multisafepay/api/paths/init.py Adds EventManager to API paths exports.
examples/terminal_manager/get_terminals.py New example to list terminals (currently relies on missing SDK surface / exports).
examples/terminal_manager/create.py New example to create a terminal (currently relies on missing SDK surface / exports).
examples/terminal_group_manager/get_terminals_by_group.py New example for terminal-group listing (currently relies on missing manager / SDK surface).
examples/pos_manager/get_receipt.py New example for Cloud POS receipt flow (currently relies on missing POS manager / SDK surface).
examples/order_manager/cloud_pos_order.py New Cloud POS order creation example (currently relies on missing client exports).
examples/order_manager/cancel.py New Cloud POS cancel example (currently relies on missing client exports).
examples/event_manager/subscribe_events.py New example for subscribing to event streams (currently has a runtime NameError + missing exports).
.env.example Adds env var placeholders for partner + terminal-group API keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +43
# Get the 'TerminalGroup' manager from the SDK
terminal_group_manager = multisafepay_sdk.get_terminal_group_manager()

Comment thread examples/pos_manager/get_receipt.py
Comment thread examples/event_manager/subscribe_events.py
from dotenv import load_dotenv

from multisafepay import Sdk
from multisafepay.client import ScopedCredentialResolver
)

# Get the 'Terminal' manager from the SDK
terminal_manager = multisafepay_sdk.get_terminal_manager()
Comment thread examples/event_manager/subscribe_events.py
Comment on lines +67 to +71
def add_group_id(
self: "CreateTerminalRequest",
group_id: str,
) -> "CreateTerminalRequest":
"""
Comment thread src/multisafepay/sdk.py
Comment on lines +177 to +181
def get_event_manager(self: "Sdk") -> EventManager:
"""
Get the event manager.

Returns
from multisafepay.api.paths.terminals.request.create_terminal_request import (
CreateTerminalRequest,
)
from multisafepay.client import ScopedCredentialResolver
)

# Get the 'Terminal' manager from the SDK
terminal_manager = multisafepay_sdk.get_terminal_manager()
@zulquer zulquer force-pushed the PTHMINT-108 branch 2 times, most recently from c16a729 to f197d99 Compare April 17, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants