remote

package
Version: v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AvailabilityViewFree             = '0'
	AvailabilityViewTentative        = '1'
	AvailabilityViewBusy             = '2'
	AvailabilityViewOutOfOffice      = '3'
	AvailabilityViewWorkingElsewhere = '4'

	ScheduleStatusFree             = "free"
	ScheduleStatusTentative        = "tentative"
	ScheduleStatusBusy             = "busy"
	ScheduleStatusOof              = "oof"
	ScheduleStatusWorkingElsewhere = "workingElsewhere"
	ScheduleStatusUnknown          = "unknown"
)
View Source
const RFC3339NanoNoTimezone = "2006-01-02T15:04:05.999999999"

Variables

View Source
var Makers = map[string]func(*config.Config, bot.Logger) Remote{}

Functions

This section is empty.

Types

type Address

type Address struct {
	Street          string `json:"street,omitempty"`
	City            string `json:"city,omitempty"`
	State           string `json:"state,omitempty"`
	CountryOrRegion string `json:"countryOrRegion,omitempty"`
	PostalCode      string `json:"postalCode,omitempty"`
}

type ApiError

type ApiError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type Attendee

type Attendee struct {
	Type         string               `json:"type,omitempty"`
	Status       *EventResponseStatus `json:"status,omitempty"`
	EmailAddress *EmailAddress        `json:"emailAddress,omitempty"`
}

type AttendeeAvailability

type AttendeeAvailability struct {
	Attendee     *Attendee
	Availability string `json:"availability"`
}

type AvailabilityView

type AvailabilityView string

type Calendar

type Calendar struct {
	ID           string  `json:"id"`
	Name         string  `json:"name,omitempty"`
	Events       []Event `json:"events,omitempty"`
	CalendarView []Event `json:"calendarView,omitempty"`
	Owner        *User   `json:"owner,omitempty"`
}

type Client

type Client interface {
	AcceptEvent(remoteUserID, eventID string) error
	CallFormPost(method, path string, in url.Values, out interface{}) (responseData []byte, err error)
	CallJSON(method, path string, in, out interface{}) (responseData []byte, err error)
	CreateCalendar(remoteUserID string, calendar *Calendar) (*Calendar, error)
	CreateEvent(remoteUserID string, calendarEvent *Event) (*Event, error)
	CreateMySubscription(notificationURL string) (*Subscription, error)
	DeclineEvent(remoteUserID, eventID string) error
	DeleteCalendar(remoteUserID, calendarID string) error
	DeleteSubscription(subscriptionID string) error
	FindMeetingTimes(remoteUserID string, meetingParams *FindMeetingTimesParameters) (*MeetingTimeSuggestionResults, error)
	GetCalendars(remoteUserID string) ([]*Calendar, error)
	GetDefaultCalendarView(remoteUserID string, startTime, endTime time.Time) ([]*Event, error)
	DoBatchViewCalendarRequests([]*ViewCalendarParams) ([]*ViewCalendarResponse, error)
	GetEvent(remoteUserID, eventID string) (*Event, error)
	GetMailboxSettings(remoteUserID string) (*MailboxSettings, error)
	GetMe() (*User, error)
	GetNotificationData(*Notification) (*Notification, error)
	GetSchedule(requests []*ScheduleUserInfo, startTime, endTime *DateTime, availabilityViewInterval int) ([]*ScheduleInformation, error)
	ListSubscriptions() ([]*Subscription, error)
	RenewSubscription(subscriptionID string) (*Subscription, error)
	TentativelyAcceptEvent(remoteUserID, eventID string) error
	GetSuperuserToken() (string, error)
}

type Coordinates

type Coordinates struct {
	Latitude  float32 `json:"latitude,omitempty"`
	Longitude float32 `json:"longitude,omitempty"`
}

type DateTime

type DateTime struct {
	DateTime string `json:"dateTime"`
	TimeZone string `json:"timeZone,omitempty"`
}

func NewDateTime

func NewDateTime(t time.Time, timeZone string) *DateTime

NewDateTime creates a DateTime that is compatible with Microsoft's API.

func (DateTime) In

func (dt DateTime) In(timeZone string) *DateTime

func (DateTime) PrettyString

func (dt DateTime) PrettyString() string

func (DateTime) String

func (dt DateTime) String() string

func (DateTime) Time

func (dt DateTime) Time() time.Time

type EmailAddress

type EmailAddress struct {
	Address string `json:"address"`
	Name    string `json:"name,omitempty"`
}

type Event

type Event struct {
	ID                         string               `json:"id,omitempty"`
	ICalUID                    string               `json:"iCalUId,omitempty"`
	Subject                    string               `json:"subject,omitempty"`
	BodyPreview                string               `json:"bodyPreview,omitempty"`
	Body                       *ItemBody            `json:"Body,omitempty"`
	Importance                 string               `json:"importance,omitempty"`
	IsAllDay                   bool                 `json:"isAllDay,omitempty"`
	IsCancelled                bool                 `json:"isCancelled,omitempty"`
	IsOrganizer                bool                 `json:"isOrganizer,omitempty"`
	ResponseRequested          bool                 `json:"responseRequested,omitempty"`
	ShowAs                     string               `json:"showAs,omitempty"`
	Weblink                    string               `json:"weblink,omitempty"`
	Start                      *DateTime            `json:"start,omitempty"`
	End                        *DateTime            `json:"end,omitempty"`
	ReminderMinutesBeforeStart int                  `json:"reminderMinutesBeforeStart,omitempty"`
	Location                   *Location            `json:"location,omitempty"`
	ResponseStatus             *EventResponseStatus `json:"responseStatus,omitempty"`
	Attendees                  []*Attendee          `json:"attendees,omitempty"`
	Organizer                  *Attendee            `json:"organizer,omitempty"`
}

type EventResponseStatus

type EventResponseStatus struct {
	Response string `json:"response,omitempty"`
	Time     string `json:"time,omitempty"`
}

type FindMeetingTimesParameters

type FindMeetingTimesParameters struct {
	Attendees                 []Attendee          `json:"attendees,omitempty"`
	LocationConstraint        *LocationConstraint `json:"locationConstraint,omitempty"`
	TimeConstraint            *TimeConstraint     `json:"timeConstraint,omitempty"`
	MeetingDuration           *time.Duration      `json:"meetingDuration,omitempty"`
	MaxCandidates             *int                `json:"maxCandidates,omitempty"`
	IsOrganizerOptional       *bool               `json:"isOrganizerOptional,omitempty"`
	ReturnSuggestionReasons   *bool               `json:"returnSuggestionReasons,omitempty"`
	MinimumAttendeePercentage *float64            `json:"minimumAttendeePercentage,omitempty"`
}

type ItemBody

type ItemBody struct {
	Content     string `json:"content,omitempty"`
	ContentType string `json:"contentType,omitempty"`
}

type Location

type Location struct {
	DisplayName  string       `json:"displayName,omitempty"`
	Address      *Address     `json:"address"`
	Coordinates  *Coordinates `json:"coordinates"`
	LocationType string       `json:"locationType"`
}

type LocationConstraint

type LocationConstraint struct {
	Locations       []LocationConstraintItem `json:"locations,omitempty"`
	IsRequired      *bool                    `json:"isRequired,omitempty"`
	SuggestLocation *bool                    `json:"suggestLocation,omitempty"`
}

type LocationConstraintItem

type LocationConstraintItem struct {
	Location            *Location
	ResolveAvailability *bool `json:"resolveAvailability,omitempty"`
}

type MailboxSettings

type MailboxSettings struct {
	TimeZone     string       `json:"timeZone"`
	WorkingHours WorkingHours `json:"workingHours"`
}

type MeetingTimeSuggestion

type MeetingTimeSuggestion struct {
	AttendeeAvailability  []*AttendeeAvailability
	Confidence            float32 `json:"confidence"`
	Locations             []*Location
	MeetingTimeSlot       *TimeSlot
	Order                 int32  `json:"order"`
	OrganizerAvailability string `json:"organizerAvailability"`
	SuggestionReason      string `json:"suggestionReason"`
}

type MeetingTimeSuggestionResults

type MeetingTimeSuggestionResults struct {
	MeetingTimeSuggestions []*MeetingTimeSuggestion `json:"meetingTimeSuggestions"`
	EmptySuggestionReason  string                   `json:"emptySuggestionReason"`
}

type Notification

type Notification struct {
	// Notification type
	ChangeType string

	// The (remote) subscription ID the notification is for
	SubscriptionID string

	// Set if subscription renewal is recommended. The date/time logic is
	// internal to the remote implementation. The handler is to call
	// RenewSubscription() as applicable, with the appropriate user credentials.
	RecommendRenew bool

	// Set if there is no data pre-filled from processing the webhook. The
	// handler is to call GetNofiticationData(), with the appropriate user
	// credentials.
	IsBare bool

	// ClientState from the webhook. The handler is to validate against its own
	// persistent secret.
	ClientState string

	// Remote-specific data: full raw JSON of the webhook, and the decoded
	// backend-specific struct.
	WebhookRawData []byte
	Webhook        interface{}

	// Notification data
	Subscription        *Subscription
	SubscriptionCreator *User
	Event               *Event
}

type Remote

type Remote interface {
	MakeClient(context.Context, *oauth2.Token) Client
	MakeSuperuserClient(ctx context.Context) (Client, error)
	NewOAuth2Config() *oauth2.Config
	HandleWebhook(http.ResponseWriter, *http.Request) []*Notification
}

type ScheduleInformation

type ScheduleInformation struct {
	// Email of user
	ScheduleID string `json:"scheduleId,omitempty"`

	// 0= free, 1= tentative, 2= busy, 3= out of office, 4= working elsewhere.
	// example "0010", which means free for first and second block, tentative for third, and free for fourth
	AvailabilityView AvailabilityView `json:"availabilityView,omitempty"`

	Error *ScheduleInformationError `json:"error"`

	ScheduleItems []*ScheduleItem `json:"scheduleItems,omitempty"`
}

ScheduleInformation undocumented

type ScheduleInformationError

type ScheduleInformationError struct {
	Message      string `json:"message"`
	ResponseCode string `json:"responseCode"`
}

type ScheduleItem

type ScheduleItem struct {
	IsPrivate bool
	Status    string
	Subject   string
	Location  string
	Start     *DateTime
	End       *DateTime
}

type ScheduleUserInfo

type ScheduleUserInfo struct {
	RemoteUserID string
	Mail         string
}

type Subscription

type Subscription struct {
	ID                 string `json:"id"`
	Resource           string `json:"resource,omitempty"`
	ApplicationID      string `json:"applicationId,omitempty"`
	ChangeType         string `json:"changeType,omitempty"`
	ClientState        string `json:"clientState,omitempty"`
	NotificationURL    string `json:"notificationUrl,omitempty"`
	ExpirationDateTime string `json:"expirationDateTime,omitempty"`
	CreatorID          string `json:"creatorId,omitempty"`
}

type TimeConstraint

type TimeConstraint struct {
	ActivityDomain string     `json:"activityDomain,omitempty"`
	TimeSlots      []TimeSlot `json:"timeSlots,omitempty"`
}

type TimeSlot

type TimeSlot struct {
	Start *DateTime `json:"start,omitempty"`
	End   *DateTime `json:"end,omitempty"`
}

type User

type User struct {
	ID                string `json:"id"`
	DisplayName       string `json:"displayName,omitempty"`
	UserPrincipalName string `json:"userPrincipalName,omitempty"`
	Mail              string `json:"mail,omitempty"`
}

type ViewCalendarParams

type ViewCalendarParams struct {
	RemoteUserID string
	StartTime    time.Time
	EndTime      time.Time
}

type ViewCalendarResponse

type ViewCalendarResponse struct {
	RemoteUserID string
	Events       []*Event
	Error        *ApiError
}

type WorkingHours

type WorkingHours struct {
	DaysOfWeek []string `json:"daysOfWeek"`
	StartTime  string   `json:"startTime"`
	EndTime    string   `json:"endTime"`
	TimeZone   struct {
		Name string `json:"name"`
	}
}

Directories

Path Synopsis
Package mock_remote is a generated GoMock package.
Package mock_remote is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL