1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 cr.define('print_preview', function() { 6 'use strict'; 7 8 /** 9 * Printer sharing invitation data object. 10 * @param {string} sender Text identifying invitation sender. 11 * @param {string} receiver Text identifying invitation receiver. Empty in 12 * case of a personal invitation. Identifies a group or domain in case 13 * of an invitation received by a group manager. 14 * @param {!print_preview.Destination} destination Shared destination. 15 * @param {!Object} aclEntry JSON representation of the ACL entry this 16 * invitation was sent to. 17 * @param {string} account User account this invitation is sent for. 18 * @constructor 19 */ 20 function Invitation(sender, receiver, destination, aclEntry, account) { 21 /** 22 * Text identifying invitation sender. 23 * @private {string} 24 */ 25 this.sender_ = sender; 26 27 /** 28 * Text identifying invitation receiver. Empty in case of a personal 29 * invitation. Identifies a group or domain in case of an invitation 30 * received by a group manager. 31 * @private {string} 32 */ 33 this.receiver_ = receiver; 34 35 /** 36 * Shared destination. 37 * @private {!print_preview.Destination} 38 */ 39 this.destination_ = destination; 40 41 /** 42 * JSON representation of the ACL entry this invitation was sent to. 43 * @private {!Object} 44 */ 45 this.aclEntry_ = aclEntry; 46 47 /** 48 * Account this invitation is sent for. 49 * @private {string} 50 */ 51 this.account_ = account; 52 }; 53 54 Invitation.prototype = { 55 /** @return {string} Text identifying invitation sender. */ 56 get sender() { 57 return this.sender_; 58 }, 59 60 /** @return {string} Text identifying invitation receiver. */ 61 get receiver() { 62 return this.receiver_; 63 }, 64 65 /** 66 * @return {boolean} Whether this user acts as a manager for a group of 67 * users. 68 */ 69 get asGroupManager() { 70 return !!this.receiver_; 71 }, 72 73 /** @return {!print_preview.Destination} Shared destination. */ 74 get destination() { 75 return this.destination_; 76 }, 77 78 /** @return {string} Scope (account) this invitation was sent to. */ 79 get scopeId() { 80 return this.aclEntry_['scope'] || ''; 81 }, 82 83 /** @return {string} Account this invitation is sent for. */ 84 get account() { 85 return this.account_; 86 } 87 }; 88 89 // Export 90 return { 91 Invitation: Invitation 92 }; 93 }); 94