function parseInvitation(json, account) {
    if (!json.hasOwnProperty(InvitationField.SENDER) ||
        !json.hasOwnProperty(InvitationField.RECEIVER) ||
        !json.hasOwnProperty(InvitationField.PRINTER)) {
      throw Error('Invitation does not have necessary info.');
    }

    const nameFormatter = function(name, scope) {
      return name && scope ? (name + ' (' + scope + ')') : (name || scope);
    };

    const sender = json[InvitationField.SENDER];
    const senderName = nameFormatter(sender['name'], sender['email']);

    const receiver = json[InvitationField.RECEIVER];
    let receiverName = '';
    const receiverType = receiver['type'];
    if (receiverType == InvitationAclType.USER) {
      // It's a personal invitation, empty name indicates just that.
    } else if (
        receiverType == InvitationAclType.GROUP ||
        receiverType == InvitationAclType.DOMAIN) {
      receiverName = nameFormatter(receiver['name'], receiver['scope']);
    } else {
      throw Error('Invitation of unsupported receiver type');
    }

    const destination = cloudprint.parseCloudDestination(
        json[InvitationField.PRINTER], print_preview.DestinationOrigin.COOKIES,
        account);

    return new print_preview.Invitation(
        senderName, receiverName, destination, receiver, account);
  }
/**
   * Parses printer sharing invitation from JSON from GCP invite API response.
   * @param {!Object} json Object that represents a invitation search response.
   * @param {string} account The account this invitation is sent for.
   * @return {!print_preview.Invitation} Parsed invitation.
   */
Parses printer sharing invitation from JSON from GCP invite API response.
@param {!Object} json Object that represents a invitation search response.
@param {string} account The account this invitation is sent for.
Parses printer sharing invitation from JSON from GCP invite API response . @param { !Object } json Object that represents a invitation search response . @param { string } account The account this invitation is sent for .
function parseInvitation(json, account) {
    if (!json.hasOwnProperty(InvitationField.SENDER) ||
        !json.hasOwnProperty(InvitationField.RECEIVER) ||
        !json.hasOwnProperty(InvitationField.PRINTER)) {
      throw Error('Invitation does not have necessary info.');
    }
    const nameFormatter = function(name, scope) {
      return name && scope ? (name + ' (' + scope + ')') : (name || scope);
    };
    const sender = json[InvitationField.SENDER];
    const senderName = nameFormatter(sender['name'], sender['email']);
    const receiver = json[InvitationField.RECEIVER];
    let receiverName = '';
    const receiverType = receiver['type'];
    if (receiverType == InvitationAclType.USER) {
    } else if (
        receiverType == InvitationAclType.GROUP ||
        receiverType == InvitationAclType.DOMAIN) {
      receiverName = nameFormatter(receiver['name'], receiver['scope']);
    } else {
      throw Error('Invitation of unsupported receiver type');
    }
    const destination = cloudprint.parseCloudDestination(
        json[InvitationField.PRINTER], print_preview.DestinationOrigin.COOKIES,
        account);
    return new print_preview.Invitation(
        senderName, receiverName, destination, receiver, account);
  }
function parseInvitation ( json , account ) { if ( ! json . hasOwnProperty ( InvitationField . SENDER ) || ! json . hasOwnProperty ( InvitationField . RECEIVER ) || ! json . hasOwnProperty ( InvitationField . PRINTER ) ) { throw Error ( 'Invitation does not have necessary info.' ) ; } const nameFormatter = function ( name , scope ) { return name && scope ? ( name + ' (' + scope + ')' ) : ( name || scope ) ; } ; const sender = json [ InvitationField . SENDER ] ; const senderName = nameFormatter ( sender [ 'name' ] , sender [ 'email' ] ) ; const receiver = json [ InvitationField . RECEIVER ] ; let receiverName = '' ; const receiverType = receiver [ 'type' ] ; if ( receiverType == InvitationAclType . USER ) { } else if ( receiverType == InvitationAclType . GROUP || receiverType == InvitationAclType . DOMAIN ) { receiverName = nameFormatter ( receiver [ 'name' ] , receiver [ 'scope' ] ) ; } else { throw Error ( 'Invitation of unsupported receiver type' ) ; } const destination = cloudprint . parseCloudDestination ( json [ InvitationField . PRINTER ] , print_preview . DestinationOrigin . COOKIES , account ) ; return new print_preview . Invitation ( senderName , receiverName , destination , receiver , account ) ; }
Parses printer sharing invitation from JSON from GCP invite API response.
Parses printer sharing invitation from JSON from GCP invite API response .
// It's a personal invitation, empty name indicates just that.