Conversation
Owner
ac000
commented
Apr 24, 2025
The main change is that instead of all the individual API endpoint
functions that were just a straight wrapper around do_ep(), you just
call do_ep() directly now.
Hopefully this will be easier to maintain and keep updated going
forward.
As such, do_ep() has been renamed to mtd_ep(), with the following
prototype
int mtd_ep(enum mtd_api_endpoint ep, const struct mtd_dsrc_ctx *dsctx,
char **buf, const char * const params[]);
(it has changed a bit from the old do_ep())
ep is one of the values from enum mtd_api_endpoint (in libmtdac/mtd.h)
This is what says what endpoint to call.
dsctx is either a pointer to a struct mtd_dsrc_ctx which describes
where the POST/PUT data is to be found or NULL for GET/DELETE endpoints.
That is the same from the previous API.
buf is the output buffer for the response and is the same as in the old
API. Dynamically allocated by libmtdac free(3)'s by you.
params is an array of char pointers containing the various arguments
required by the endpoint including any query string.
This array does not need to be NULL terminated as the number of params
is determined by the endpoint in question. But you do need to account
for any optional or not query string. Passing an array with more entries
than required (say NULLs) is fine as any extra entries are ignored.
Any query string should be the last parameter in the array.
If you are accessing an endpoint that takes an optional query string but
don't provide one you must pass a NULL pointer instead.
İ.e. If an endpoint takes two required parameters (that become part of
the URL) and an optional query string, then your params array should
have three entries, with the third entry either pointing to a query
string or NULL.
With this change most of the docs have been removed. New ones will be
added in time.
All the other API remains the same.
Also, as before, you don't pass in {nino} to any endpoints as that's
read from the nino.json when required.
This version supports the following endpoint APIs
Business Details 1.0
Business Source Adjustable Summary 6.0
Individual Calculations 7.0
Individual Losses 5.0
Obligations 3.0
Property Business 5.0
Self-Employment Business 4.0
It also supports the testing endpoints for creating a test user and
testing the fraud prevention headers, as before.
Signed-off-by: Andrew Clayton <ac@sigsegv.uk>
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.