View | Details | Raw Unified | Return to bug 38993
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js (-3 / +22 lines)
Lines 1-7 Link Here
1
export class PatronAPIClient {
1
export class PatronAPIClient {
2
    constructor(HttpClient) {
2
    constructor(HttpClient) {
3
        this.httpClient = new HttpClient({
3
        this.httpClient = new HttpClient({
4
            baseURL: "/api/v1/",
4
            baseURL: "",
5
        });
5
        });
6
    }
6
    }
7
7
Lines 9-18 export class PatronAPIClient { Link Here
9
        return {
9
        return {
10
            get: id =>
10
            get: id =>
11
                this.httpClient.get({
11
                this.httpClient.get({
12
                    endpoint: "patrons/" + id,
12
                    endpoint: "/api/v1/patrons/" + id,
13
                }),
13
                }),
14
        };
14
        };
15
    }
15
    }
16
17
    get lists() {
18
         return {
19
            add_patrons: ({ patron_ids, list_id, new_list_name }) =>
20
                this.httpClient.post({
21
                    endpoint: "/cgi-bin/koha/svc/members/add_to_list",
22
                    body: "add_to_patron_list=%s&new_patron_list=%s&%s".format(
23
                        list_id,
24
                        new_list_name,
25
                        patron_ids
26
                            .map(id => "borrowernumber=%s".format(id))
27
                            .join("&")
28
                    ),
29
                    headers: {
30
                        "Content-Type":
31
                            "application/x-www-form-urlencoded;charset=utf-8",
32
                    },
33
                 }),
34
         };
35
     }
16
}
36
}
17
37
18
export default PatronAPIClient;
38
export default PatronAPIClient;
19
- 

Return to bug 38993