2 function Vendor(name) {
7 function Ebook(vendor, id) {
9 this.id = id; // external ID for this title
10 this.rec_id; // bre.id for this title's MARC record
11 this.title; // title of ebook
12 this.author; // author of ebook
13 this.avail; // availability info for this title
14 this.holdings = {}; // holdings info
15 this.conns = {}; // references to Dojo event connection for performing actions with this ebook
19 Ebook.prototype.getDetails = function(callback) {
20 var ses = dojo.cookie(this.vendor);
22 new OpenSRF.ClientSession('open-ils.ebook_api').request({
23 method: 'open-ils.ebook_api.title.details',
24 params: [ ses, ebook.id ],
26 oncomplete: function(r) {
29 console.log('title details response: ' + resp.content());
30 ebook.title = resp.content().title;
31 ebook.author = resp.content().author;
32 return callback(ebook);
38 Ebook.prototype.getAvailability = function(callback) {
39 var ses = dojo.cookie(this.vendor);
40 new OpenSRF.ClientSession('open-ils.ebook_api').request({
41 method: 'open-ils.ebook_api.title.availability',
42 params: [ ses, this.id ],
44 oncomplete: function(r) {
47 console.log('availability response: ' + resp.content());
48 this.avail = resp.content();
49 return callback(resp.content());
55 Ebook.prototype.getHoldings = function(callback) {
56 var ses = dojo.cookie(this.vendor);
57 new OpenSRF.ClientSession('open-ils.ebook_api').request({
58 method: 'open-ils.ebook_api.title.holdings',
59 params: [ ses, this.id ],
61 oncomplete: function(r) {
64 console.log('holdings response: ' + resp.content());
65 this.holdings = resp.content();
66 return callback(resp.content());
72 Ebook.prototype.checkout = function(authtoken, patron_id, callback) {
73 var ses = dojo.cookie(this.vendor);
75 new OpenSRF.ClientSession('open-ils.ebook_api').request({
76 method: 'open-ils.ebook_api.checkout',
77 params: [ authtoken, ses, ebook.id, patron_id ],
79 oncomplete: function(r) {
82 console.log('checkout response: ' + resp.content());
83 return callback(resp.content());
89 Ebook.prototype.placeHold = function(authtoken, patron_id, callback) {
90 var ses = dojo.cookie(this.vendor);
92 new OpenSRF.ClientSession('open-ils.ebook_api').request({
93 method: 'open-ils.ebook_api.place_hold',
94 params: [ authtoken, ses, ebook.id, patron_id ],
96 oncomplete: function(r) {
99 console.log('place hold response: ' + resp.content());
100 return callback(resp.content());
106 Ebook.prototype.cancelHold = function(authtoken, patron_id, callback) {
107 var ses = dojo.cookie(this.vendor);
109 new OpenSRF.ClientSession('open-ils.ebook_api').request({
110 method: 'open-ils.ebook_api.cancel_hold',
111 params: [ authtoken, ses, ebook.id, patron_id ],
113 oncomplete: function(r) {
116 console.log('cancel hold response: ' + resp.content());
117 return callback(resp.content());