Skip to content

Conversation

@ac000
Copy link
Owner

@ac000 ac000 commented Apr 24, 2025

    This is basically a new version
    
    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>

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>
@ac000 ac000 merged commit ab39737 into master Apr 24, 2025
9 checks passed
@ac000 ac000 deleted the skx branch April 24, 2025 22:36
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.

1 participant