Bug 33289: Add API client class to interact with svc/config/systempreferences

On bug 30708 we will need to modify sysprefs from the UI (Vue app), it
could be useful for other developments as well and so it is moved on its
own bug report.

Test plan:
It can be tested independently of bug 30708 using the following code:

const client = APIClient.sysprefs
client.sysprefs
    .update(
        "CardnumberLength",
        "42"
    )

Sponsored-by: BULAC - http://www.bulac.fr/
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-03-21 09:00:10 +01:00 committed by Tomas Cohen Arazi
parent f92f967626
commit 9597b88ed2
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 27 additions and 0 deletions

View file

@ -2,10 +2,12 @@ import ERMAPIClient from "./erm-api-client";
import PatronAPIClient from "./patron-api-client";
import AcquisitionAPIClient from "./acquisition-api-client";
import AVAPIClient from "./authorised-values";
import SysprefAPIClient from "./system-preferences-api-client";
export const APIClient = {
erm: new ERMAPIClient(),
patron: new PatronAPIClient(),
acquisition: new AcquisitionAPIClient(),
authorised_values: new AVAPIClient(),
sysprefs: new SysprefAPIClient(),
};

View file

@ -0,0 +1,25 @@
import HttpClient from "./http-client";
export class SysprefAPIClient extends HttpClient {
constructor() {
super({
baseURL: "/cgi-bin/koha/svc/config/systempreferences",
});
}
get sysprefs() {
return {
update: (variable, value) =>
this.post({
endpoint: "",
body: "pref_%s=%s".format(variable, value),
headers: {
"Content-Type":
"application/x-www-form-urlencoded;charset=utf-8",
},
}),
};
}
}
export default SysprefAPIClient;