]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/opac/ebook_api/ebook.js
LP#1541559: ebook API integration for TPAC
[working/Evergreen.git] / Open-ILS / web / js / ui / default / opac / ebook_api / ebook.js
1 // define our classes
2 function Vendor(name) {
3     this.name = name;
4     this.ebooks = [];
5 }
6
7 function Ebook(vendor, id) {
8     this.vendor = vendor;
9     this.id = id; // external ID for this title
10     this.rec_id;  // bre.id for this title's MARC record
11     this.avail;   // availability info for this title
12     this.holdings = {}; // holdings info
13 }
14
15 Ebook.prototype.getAvailability = function(callback) {
16     var ses = dojo.cookie(this.vendor);
17     new OpenSRF.ClientSession('open-ils.ebook_api').request({
18         method: 'open-ils.ebook_api.title.availability',
19         params: [ ses, this.id ],
20         async: true,
21         oncomplete: function(r) {
22             var resp = r.recv();
23             if (resp) {
24                 console.log('availability response: ' + resp.content());
25                 this.avail = resp.content();
26                 return callback(resp.content());
27             }
28         }
29     }).send();
30 }
31
32 Ebook.prototype.getHoldings = function(callback) {
33     var ses = dojo.cookie(this.vendor);
34     new OpenSRF.ClientSession('open-ils.ebook_api').request({
35         method: 'open-ils.ebook_api.title.holdings',
36         params: [ ses, this.id ],
37         async: true,
38         oncomplete: function(r) {
39             var resp = r.recv();
40             if (resp) {
41                 console.log('holdings response: ' + resp.content());
42                 this.holdings = resp.content();
43                 return callback(resp.content());
44             }
45         }
46     }).send();
47 }
48