Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #54 +/- ##
==========================================
+ Coverage 90.94% 94.43% +3.49%
==========================================
Files 147 173 +26
Lines 2607 3182 +575
==========================================
+ Hits 2371 3005 +634
+ Misses 236 177 -59 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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/ScopedCredentialResolversupport and wire it intoClient/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.
| # Get the 'TerminalGroup' manager from the SDK | ||
| terminal_group_manager = multisafepay_sdk.get_terminal_group_manager() | ||
|
|
| 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() |
| def add_group_id( | ||
| self: "CreateTerminalRequest", | ||
| group_id: str, | ||
| ) -> "CreateTerminalRequest": | ||
| """ |
| 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() |
Add scoped auth API surface and add strict Cloud POS/terminal E2E setup with dedicated docs/env configuration.
Delegate all API key validation to ScopedCredentialResolver. Fix resolver_bootstrap_api_key fallback bug in Cloud POS examples. Add scope comments documenting which key each manager method resolves.
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.