Koha/koha-tmpl/intranet-tmpl/prog/js/fetch/club-api-client.js
Jonathan Druart 37a16e69c7
Bug 36374: Keep tidy files from 'fetch' directory
And tidy them

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-29 15:19:33 +02:00

67 lines
2 KiB
JavaScript

/* keep tidy */
import HttpClient from "./http-client.js";
export class ClubAPIClient extends HttpClient {
constructor() {
super({
baseURL: "/cgi-bin/koha/svc/club/",
});
}
get templates() {
return {
delete: template_id =>
this.post({
endpoint: "template/delete",
body: "id=%s&op=%s".format(template_id, "cud-delete"),
headers: {
"Content-Type":
"application/x-www-form-urlencoded;charset=utf-8",
},
}),
};
}
get clubs() {
return {
delete: club_id =>
this.post({
endpoint: "delete",
body: "id=%s&op=%s".format(club_id, "cud-delete"),
headers: {
"Content-Type":
"application/x-www-form-urlencoded;charset=utf-8",
},
}),
};
}
get enrollments() {
return {
cancel: enrollment_id =>
this.post({
endpoint: "cancel_enrollment",
body: "id=%s&op=%s".format(enrollment_id, "cud-delete"),
headers: {
"Content-Type":
"application/x-www-form-urlencoded;charset=utf-8",
},
}),
enroll: data =>
this.post({
endpoint: "enroll",
body: "%s&op=%s".format(
data, // Could do better, but too much work for now!
"cud-enroll"
),
headers: {
"Content-Type":
"application/x-www-form-urlencoded;charset=utf-8",
},
}),
};
}
}
export default ClubAPIClient;