1 import { setError } from "./messages";
3 export const fetchAgreement = async function (agreement_id) {
4 if (!agreement_id) return;
5 const apiUrl = "/api/v1/erm/agreements/" + agreement_id;
10 "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents",
25 export const fetchAgreements = async function () {
26 const apiUrl = "/api/v1/erm/agreements";
41 export const fetchLicense = async function (license_id) {
42 if (!license_id) return;
43 const apiUrl = "/api/v1/erm/licenses/" + license_id;
58 export const fetchLicenses = async function () {
59 const apiUrl = "/api/v1/erm/licenses";
74 export const fetchPatron = async function (patron_id) {
75 if (!patron_id) return;
76 const apiUrl = "/api/v1/patrons/" + patron_id;
91 export const fetchVendors = async function () {
92 const apiUrl = "/api/v1/acquisitions/vendors";
107 export const fetchPackage = async function (package_id) {
108 if (!package_id) return;
109 const apiUrl = "/api/v1/erm/eholdings/packages/" + package_id;
111 await fetch(apiUrl, {
113 "x-koha-embed": "package_agreements,package_agreements.agreement,resources,resources.title",
119 erm_package = result;
128 export const fetchPackages = async function () {
129 const apiUrl = "/api/v1/erm/eholdings/packages";
144 export const fetchTitle = async function (title_id) {
145 if (!title_id) return;
146 const apiUrl = "/api/v1/erm/eholdings/titles/" + title_id;
148 await fetch(apiUrl, {
150 "x-koha-embed": "resources,resources.package",
165 export const fetchTitles = async function () {
166 const apiUrl = "/api/v1/erm/eholdings/titles";
181 export const fetchResource = async function (resource_id) {
182 if (!resource_id) return;
183 const apiUrl = "/api/v1/erm/eholdings/resources/" + resource_id;
185 await fetch(apiUrl, {
187 "x-koha-embed": "title,package",
202 export const fetchresources = async function () {
203 const apiUrl = "/api/v1/erm/eholdings/resources";
218 function checkError(response) {
219 if (response.status >= 200 && response.status <= 299) {
220 return response.json();
222 console.log("Server returned an error:");
223 console.log(response);
224 setError("%s (%s)".format(response.statusText, response.status));