Repository navigation
feat: read organizations back, import from GS1, pick values out of a document - #2
Merged
Merged
Conversation
Adds the read side a synchroniser needs, for the CRM sync programme
(Twenty and Odoo kept in step through the catalog):
- get_organization(gln): one record of the caller's tenant, None on 404
- iter_organizations(): every organization, newest change first, paged
- preview_from_gs1(key) / import_from_gs1(key): GET and POST
/masterdata/sync/{key}, the inbound GS1 Germany derivation
The resolver sorts by updatedAt but does not return it (WRITE_ONLY on
the DTO), so there is no cursor yet: callers walk the list and compare
payload hashes. A modifiedSince filter on the server is the next step.
Signed-off-by: Sven Boeckelmann <sboeckelmann@benelog.com>
pick(document, path) is the reading counterpart of place(), same path grammar ([] takes the first element); pick_localized() takes one text out of a language map in a preferred order, falling back to English and then to whatever is there. A host that synchronises from the catalog back into its own fields needs both, and the path grammar should stay in one place. Signed-off-by: Sven Boeckelmann <sboeckelmann@benelog.com>
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.
Why
Read side for the CRM sync programme: a host that keeps organizations in step with the catalog (the Odoo addon first, see the companion PR in openepcis-odoo) has to read records back, not only publish them.
What
Masterdata.get_organization(gln): one record of the caller's tenant,Noneon 404Masterdata.iter_organizations(): every organization of the tenant, newest change first, paged lazilyMasterdata.preview_from_gs1(key)/import_from_gs1(key):GET/POST /masterdata/sync/{key}, the inbound GS1 Germany derivation;Gs1Recordmirrors the resolver'sMasterDataPreview(product / organization / place)payload.pick(document, path): the reading counterpart ofplace(), same path grammar;pick_localized()takes one text out of a language mapKnown limitation
The resolver sorts by
updatedAtbut does not return it (WRITE_ONLYon the DTO), so there is no cursor yet. Callers walk the list and compare payload hashes. AmodifiedSincefilter on the resolver is the follow-up.Checks
ruff format --check,ruff check,mypy --strict,reuse lint,pytest: 191 passed.