MPT-24264 Add the exchange pairs service - #387
Draft
jentyk wants to merge 1 commit into
Draft
Conversation
|
Warning Review limit reached
On-demand reviews are free for the next 24 days. After that, they cost $0.25 per reviewed file. Or wait 48 minutes for your next included review. View limit detailsLimit details: You’ve used all 5 included reviews currently available. Your 29 included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. Review configuration: ⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
Comment |
The /public/v1/exchange/pairs collection endpoint had no service class, so
currency pairs were unreachable from both the sync and async clients. Add
PairsService and AsyncPairsService with the Pair model, and expose them as
the `pairs` property on Exchange and AsyncExchange.
Mixins follow what the OpenAPI spec documents for this endpoint: a GET
collection (CollectionMixin) and a GET by id on /pairs/{id} (GetMixin). The
collection-level bulk POST, PUT and DELETE operations take a PairBulkData
envelope and have no matching mixin or precedent in this client, so they are
left out of this change. Streaming support is tracked separately in MPT-24241.
MPT-24264
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jentyk
force-pushed
the
feature/MPT-24264/add-exchange-pairs-service
branch
from
August 27, 2026 08:32
b69bf90 to
e0c2e00
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



🤖 AI-generated PR — Please review carefully.
Summary
/public/v1/exchange/pairswas the onlyexchangeendpoint in the Marketplace OpenAPI spec without a service class, so currency pairs were unreachable from the client. This adds the service and registers it on the resource group.mpt_api_client/resources/exchange/pairs.pywith:Pairmodel covering the documentedPairschema attributes.PairsServiceConfig(_endpoint = "/public/v1/exchange/pairs",_model_class,_collection_key = "data").PairsServiceandAsyncPairsService.pairsproperty registered on bothExchangeandAsyncExchange.The module follows the existing service pattern (
notifications/contacts.py,accounts/modules.py); no new abstraction was introduced.Mixin selection
Mixins were picked from what the spec actually documents for this endpoint, not from an assumed CRUD shape:
GET /exchange/pairsCollectionMixin/AsyncCollectionMixinGET /exchange/pairs/{id}GetMixin/AsyncGetMixinThe collection also documents bulk
POST,PUTandDELETE, all of which take aPairBulkDataenvelope ({"data": [Pair, ...]}) and return an envelope or a bare array. These do not match any existing mixin —CreateMixinreturns a single model, andUpdateMixin/DeleteMixinoperate on/{id}, which the spec does not define forPUT/DELETEhere. There is no bulk-operation precedent anywhere in this client, so adding them would mean inventing a pattern. They are deliberately left out of this change; see the note below.Streaming support for this endpoint is out of scope here and tracked in MPT-24241.
Testing
make check-allpasses: ruff format, ruff, flake8/WPS, mypy,uv lock --check, and the full unit suite (2391 passed).pairs.pyreports 100% coverage.tests/unit/resources/exchange/test_pairs.pycovers mixin presence, endpoint construction,Pairfield typing and optional-field absence, and mockedget/fetch_pagefor both sync and async.tests/unit/resources/exchange/test_exchange.pygained thepairsproperty assertions for bothExchangeandAsyncExchange.MPTClient.from_config/AsyncMPTClient.from_configresolvesclient.exchange.pairsto the right class,build_path()returns/public/v1/exchange/pairs, and that path was checked against the live OpenAPI spec.pyproject.tomlchange was needed:Exchangegoes from 2 to 3 methods, well under wemake'smax_methodslimit, and flake8 reported noWPS214.Docs
docs/usage.mdanddocs/architecture.mdwere deliberately left untouched — this is not an omission. Neither enumerates individual services:usage.mdhas no service list, and the resource tree inarchitecture.mdis group-granular with ellipses, so a new service under an existing group is already covered. Sibling work on other resource groups is in flight, and doc edits would be the only collision point.Reported, not changed
Two things worth a reviewer's attention rather than a unilateral fix:
POST/PUT/DELETEon/exchange/pairsneed a bulk-capable mixin (request and response both use adataarray). That is a framework addition, not a per-service one, and belongs in its own ticket.test_exchange.pyuses per-service tests, not parametrized lists. Every other group test (test_accounts.py,test_catalog.py,test_billing.py,test_commerce.py,test_notifications.py) enumerates group properties with@pytest.mark.parametrize;test_exchange.pyis the outlier with individual test functions. The new coverage follows the file's existing local style for consistency. Converting this file to the repo-wide parametrized convention is a reasonable tidy-up, but out of scope here.MPT-24264