remote

package
v0.0.0-...-5de3a08 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RFC3339NanoNoTimezone = "2006-01-02T15:04:05.999999999"
	UndefinedDatetime     = "n/a"
)
View Source
const (
	EventResponseStatusNotAnswered = "not_answered"
	EventResponseStatusAccepted    = "accepted"
	EventResponseStatusTentative   = "tentative"
	EventResponseStatusDeclined    = "declined"
)
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"
)

Variables

View Source
var (
	ErrSuperUserClientNotSupported = errors.New("superuser client is not supported")
	ErrNotImplemented              = errors.New("not implemented")
)
View Source
var Makers = map[string]func(*config.Config, bot.Logger) Remote{}

Functions

This section is empty.

Types

type APIError

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

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 Attendee

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

type AttendeeAvailability

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

type AvailabilityView

type AvailabilityView string

type Calendar

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

type Calendars

type Calendars interface {
	GetEvent(remoteUserID, eventID string) (*Event, error)
	GetCalendars(remoteUserID string) ([]*Calendar, error)
	GetDefaultCalendarView(remoteUserID string, startTime, endTime time.Time) ([]*Event, error)
	DoBatchViewCalendarRequests([]*ViewCalendarParams) ([]*ViewCalendarResponse, error)
	GetMailboxSettings(remoteUserID string) (*MailboxSettings, error)
}

type Client

type Client interface {
	Core
	Calendars
	Events
	Subscriptions
	Utils
	Unsupported
}

type Conference

type Conference struct {
	Application string `json:"application"`
	URL         string `json:"url"`
}

type Coordinates

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

type Core

type Core interface {
	GetMe() (*User, error)
}

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

String returns the RFC3339 representation of the provided datetime. UndefinedDatetime if not set.

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

REVIEW: we should vet exactly what fields are used from the remote package, and get rid of any "dead fields" from these structs

type EventResponseStatus

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

type Events

type Events interface {
	CreateEvent(remoteUserID string, calendarEvent *Event) (*Event, error)
	AcceptEvent(remoteUserID, eventID string) error
	DeclineEvent(remoteUserID, eventID string) error
	TentativelyAcceptEvent(remoteUserID, eventID string) error
	GetEventsBetweenDates(remoteUserID string, start, end time.Time) ([]*Event, error)
}

type FindMeetingTimesParameters

type FindMeetingTimesParameters struct {
	ReturnSuggestionReasons   *bool               `json:"returnSuggestionReasons,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"`
	MinimumAttendeePercentage *float64            `json:"minimumAttendeePercentage,omitempty"`
	Attendees                 []Attendee          `json:"attendees,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 {
	IsRequired      *bool                    `json:"isRequired,omitempty"`
	SuggestLocation *bool                    `json:"suggestLocation,omitempty"`
	Locations       []LocationConstraintItem `json:"locations,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 {
	MeetingTimeSlot       *TimeSlot
	SuggestionReason      string `json:"suggestionReason"`
	OrganizerAvailability string `json:"organizerAvailability"`
	Locations             []*Location
	AttendeeAvailability  []*AttendeeAvailability
	Confidence            float32 `json:"confidence"`
	Order                 int32   `json:"order"`
}

type MeetingTimeSuggestionResults

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

type Notification

type Notification struct {
	Webhook interface{}

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

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

	// Notification type
	ChangeType string

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

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

	// 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
}

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
	CheckConfiguration(configuration config.StoredConfig) error
}

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 {
	Start     *DateTime
	End       *DateTime
	Status    string
	Subject   string
	Location  string
	IsPrivate bool
}

type ScheduleUserInfo

type ScheduleUserInfo struct {
	RemoteUserID string
	Mail         string
}

type Subscription

type Subscription struct {
	ID                 string `json:"id"`
	ResourceID         string `json:"resourceId,omitempty"`
	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 Subscriptions

type Subscriptions interface {
	CreateMySubscription(notificationURL, remoteUserID string) (*Subscription, error)
	DeleteSubscription(sub *Subscription) error
	GetNotificationData(*Notification) (*Notification, error)
	ListSubscriptions() ([]*Subscription, error)
	RenewSubscription(notificationURL, remoteUserID string, sub *Subscription) (*Subscription, error)
}

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 Unsupported

type Unsupported interface {
	CreateCalendar(remoteUserID string, calendar *Calendar) (*Calendar, error)
	DeleteCalendar(remoteUserID, calendarID string) error
	FindMeetingTimes(remoteUserID string, meetingParams *FindMeetingTimesParameters) (*MeetingTimeSuggestionResults, error)
}

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 Utils

type Utils interface {
	GetSuperuserToken() (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)
}

type ViewCalendarParams

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

type ViewCalendarResponse

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

type WorkingHours

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

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
y or Y : Canonical URL