如何从GuestStatus对象获取Enum类型的值 - Google Script

时间:2018-04-22 15:43:23

标签: google-apps-script google-calendar-api

我正在尝试获取特定Google日历活动的受邀嘉宾的状态。

// receives and EventGuest object
// https://developers.google.com/apps-script/reference/calendar/event-guest
function getInviteeStatus(eventguest) {
  var gueststatus,
      guestname = eventguest.getName(),
      guestemail = eventguest.getEmail(),
      guestguestcount = eventguest.getAdditionalGuests(),
      gueststatusObj = eventguest.getGuestStatus(); // returns a GuestStatus object

  // export enum GuestStatus { INVITED, MAYBE, NO, OWNER, YES } - this is from some docs I found
  // how do I convert the GuestStatus object to a string that represents the status?
  //gueststatus = ???

  return [guestname, guestemail, guestguestcount, gueststatus]
}

1 个答案:

答案 0 :(得分:1)

您想要将INVITED, MAYBE, NO, OWNER, YES检索为字符串。如果我的理解是正确的,那么这个修改怎么样?

来自:

gueststatusObj = eventguest.getGuestStatus();
Logger.log("%s, %s", gueststatusObj, typeof gueststatusObj) // INVITED, object

致:

gueststatusObj = eventguest.getGuestStatus().toString();
Logger.log("%s, %s", gueststatusObj, typeof gueststatusObj) // INVITED, string

注意:

  • 在此修改过的脚本中,INVITED用作示例。

如果我误解了你的问题,我很抱歉。