graphapi

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateEmail

func ValidateEmail(email string) error

ValidateEmail checks basic email format.

func ValidatePhone

func ValidatePhone(phone string) error

ValidatePhone checks basic phone number format.

Types

type Attachment

type Attachment struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	ContentType string `json:"contentType"`
	Size        int32  `json:"size"`
	Content     []byte `json:"-"`
}

Attachment represents a mail attachment

type AttachmentInput added in v0.2.0

type AttachmentInput struct {
	Name        string
	ContentType string
	Content     []byte
}

AttachmentInput represents an attachment to be sent with a message

type AttendeeAvailabilityInfo added in v0.3.0

type AttendeeAvailabilityInfo struct {
	Email        string `json:"email"`
	Availability string `json:"availability"`
}

AttendeeAvailabilityInfo represents an attendee's availability for a time slot

type AutoReplySettings added in v0.2.0

type AutoReplySettings struct {
	Status           string `json:"status"`
	InternalMessage  string `json:"internalMessage"`
	ExternalMessage  string `json:"externalMessage"`
	StartTime        string `json:"startTime,omitempty"`
	EndTime          string `json:"endTime,omitempty"`
	ExternalAudience string `json:"externalAudience"`
}

AutoReplySettings is a simplified auto-reply configuration for output

type CalendarEvent

type CalendarEvent struct {
	ID          string   `json:"id"`
	Subject     string   `json:"subject"`
	Start       string   `json:"start"`
	End         string   `json:"end"`
	Location    string   `json:"location"`
	Organizer   string   `json:"organizer"`
	Attendees   []string `json:"attendees,omitempty"`
	IsAllDay    bool     `json:"isAllDay"`
	IsOnline    bool     `json:"isOnlineMeeting"`
	OnlineURL   string   `json:"onlineMeetingUrl,omitempty"`
	Status      string   `json:"showAs"`
	Recurrence  string   `json:"recurrence,omitempty"`
	BodyPreview string   `json:"bodyPreview"`
	Body        string   `json:"body,omitempty"`
}

CalendarEvent is a simplified calendar event for output

type CalendarInfo

type CalendarInfo struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Color string `json:"color"`
	Owner string `json:"owner"`
}

CalendarInfo is a simplified calendar representation

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the Graph SDK client

func NewClient

func NewClient(cred azcore.TokenCredential) (*Client, error)

NewClient creates a new Graph API client from a token credential

func (*Client) CategorizeMessage added in v0.2.0

func (c *Client) CategorizeMessage(ctx context.Context, messageID string, categories []string) error

CategorizeMessage sets the categories on a message

func (*Client) CompleteTodoTask added in v0.2.0

func (c *Client) CompleteTodoTask(ctx context.Context, listID, taskID string) error

CompleteTodoTask marks a task as completed.

func (*Client) CreateContact

func (c *Client) CreateContact(ctx context.Context, firstName, lastName, email, businessPhone, homePhone, mobilePhone, company, jobTitle string) (*Contact, error)

func (*Client) CreateDraft added in v0.2.0

func (c *Client) CreateDraft(ctx context.Context, subject, body string, to, cc, bcc []string, isHTML bool) (*DraftMessage, error)

CreateDraft creates a draft message without sending it

func (*Client) CreateEvent

func (c *Client) CreateEvent(ctx context.Context, subject string, start, end time.Time, location string, attendees []string, isAllDay bool, isOnlineMeeting bool) (*CalendarEvent, error)

func (*Client) CreateMailRule added in v0.3.0

func (c *Client) CreateMailRule(ctx context.Context, name string, from string, subjectContains string, hasAttachment bool, moveFolder string, markRead bool, deleteMsg bool, forwardTo string, importance string) (*MailRule, error)

func (*Client) CreateTodoTask added in v0.2.0

func (c *Client) CreateTodoTask(ctx context.Context, listID, title string, dueDate string, importance string, body string) (*TodoTask, error)

CreateTodoTask creates a new task in the given list.

func (*Client) DeleteContact

func (c *Client) DeleteContact(ctx context.Context, contactID string) error

func (*Client) DeleteDraft added in v0.2.0

func (c *Client) DeleteDraft(ctx context.Context, draftID string) error

DeleteDraft deletes a draft message

func (*Client) DeleteEvent

func (c *Client) DeleteEvent(ctx context.Context, eventID string) error

func (*Client) DeleteMailRule added in v0.3.0

func (c *Client) DeleteMailRule(ctx context.Context, ruleID string) error

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(ctx context.Context, messageID string) error

func (*Client) DeleteTodoTask added in v0.2.0

func (c *Client) DeleteTodoTask(ctx context.Context, listID, taskID string) error

DeleteTodoTask deletes a task.

func (*Client) DownloadAttachment added in v0.2.0

func (c *Client) DownloadAttachment(ctx context.Context, messageID, attachmentID string) (*Attachment, error)

func (*Client) FindMeetingTimes added in v0.3.0

func (c *Client) FindMeetingTimes(ctx context.Context, attendees []string, start, end time.Time, durationMinutes int32) ([]MeetingTimeSuggestion, error)

FindMeetingTimes finds available meeting times for the given attendees

func (*Client) FlagMessage added in v0.2.0

func (c *Client) FlagMessage(ctx context.Context, messageID string, flagStatus string) error

FlagMessage sets the follow-up flag status on a message

func (*Client) ForwardMessage

func (c *Client) ForwardMessage(ctx context.Context, messageID string, comment string, toRecipients []string) error

func (*Client) GetAttachments

func (c *Client) GetAttachments(ctx context.Context, messageID string) ([]Attachment, error)

func (*Client) GetAutoReply added in v0.2.0

func (c *Client) GetAutoReply(ctx context.Context) (*AutoReplySettings, error)

GetAutoReply retrieves the current auto-reply (out-of-office) settings

func (*Client) GetContact

func (c *Client) GetContact(ctx context.Context, contactID string) (*Contact, error)

func (*Client) GetEvent

func (c *Client) GetEvent(ctx context.Context, eventID string) (*CalendarEvent, error)

func (*Client) GetMessage

func (c *Client) GetMessage(ctx context.Context, messageID string) (*MailMessage, error)

func (*Client) GetProfile added in v0.2.0

func (c *Client) GetProfile(ctx context.Context) (*UserProfile, error)

GetProfile retrieves the current user's profile information

func (*Client) GetSchedule added in v0.2.0

func (c *Client) GetSchedule(ctx context.Context, emails []string, start, end time.Time) ([]ScheduleInfo, error)

GetSchedule retrieves free/busy availability for the specified email addresses

func (*Client) GetTodoTask added in v0.2.0

func (c *Client) GetTodoTask(ctx context.Context, listID, taskID string) (*TodoTask, error)

GetTodoTask returns a single task by ID.

func (*Client) Inner

func (c *Client) Inner() *msgraphsdk.GraphServiceClient

Inner returns the underlying Graph SDK client

func (*Client) ListCalendarView added in v0.3.0

func (c *Client) ListCalendarView(ctx context.Context, startTime, endTime time.Time, calendarID string, top int32) ([]CalendarEvent, error)

ListCalendarView returns expanded occurrences (including recurring) in a date range.

func (*Client) ListCalendars

func (c *Client) ListCalendars(ctx context.Context) ([]CalendarInfo, error)

func (*Client) ListContacts

func (c *Client) ListContacts(ctx context.Context, top int32) ([]Contact, error)

func (*Client) ListDrafts added in v0.2.0

func (c *Client) ListDrafts(ctx context.Context, top int32) ([]DraftMessage, error)

ListDrafts lists messages in the Drafts folder

func (*Client) ListEvents

func (c *Client) ListEvents(ctx context.Context, startTime, endTime time.Time, calendarID string, top int32) ([]CalendarEvent, error)

func (*Client) ListMailFolders

func (c *Client) ListMailFolders(ctx context.Context) ([]MailFolder, error)

func (*Client) ListMailRules added in v0.3.0

func (c *Client) ListMailRules(ctx context.Context) ([]MailRule, error)

func (*Client) ListMessages

func (c *Client) ListMessages(ctx context.Context, opts ListMessagesOptions) ([]MailMessage, error)

func (*Client) ListTodoLists added in v0.2.0

func (c *Client) ListTodoLists(ctx context.Context) ([]TodoList, error)

ListTodoLists returns all task lists for the current user.

func (*Client) ListTodoTasks added in v0.2.0

func (c *Client) ListTodoTasks(ctx context.Context, listID string, top int32, status string) ([]TodoTask, error)

ListTodoTasks returns tasks in a given task list.

func (*Client) MarkMessage

func (c *Client) MarkMessage(ctx context.Context, messageID string, isRead bool) error

func (*Client) MoveMessage

func (c *Client) MoveMessage(ctx context.Context, messageID string, folderID string) error

func (*Client) ReplyMessage

func (c *Client) ReplyMessage(ctx context.Context, messageID string, comment string, replyAll bool) error

func (*Client) RespondToEvent

func (c *Client) RespondToEvent(ctx context.Context, eventID string, response string) error

func (*Client) SearchContacts

func (c *Client) SearchContacts(ctx context.Context, query string, top int32) ([]Contact, error)

func (*Client) SearchMessages

func (c *Client) SearchMessages(ctx context.Context, query string, top int32) ([]MailMessage, error)

func (*Client) SearchPeople added in v0.3.0

func (c *Client) SearchPeople(ctx context.Context, query string, top int32) ([]Person, error)

func (*Client) SendDraft added in v0.2.0

func (c *Client) SendDraft(ctx context.Context, draftID string) error

SendDraft sends an existing draft message

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, subject string, body string, toRecipients []string, ccRecipients []string, bccRecipients []string, isHTML bool, attachments []AttachmentInput, importance string, readReceipt bool) error

func (*Client) SetAutoReply added in v0.2.0

func (c *Client) SetAutoReply(ctx context.Context, status, internalMsg, externalMsg, startTime, endTime, audience string) error

SetAutoReply updates the auto-reply (out-of-office) settings

func (*Client) SetImportance added in v0.2.0

func (c *Client) SetImportance(ctx context.Context, messageID string, importance string) error

SetImportance sets the importance level on a message

func (*Client) UpdateContact

func (c *Client) UpdateContact(ctx context.Context, contactID string, firstName, lastName, email, businessPhone, homePhone, mobilePhone, company, jobTitle *string) (*Contact, error)

func (*Client) UpdateEvent

func (c *Client) UpdateEvent(ctx context.Context, eventID string, subject *string, start, end *time.Time, location *string) (*CalendarEvent, error)

type Contact

type Contact struct {
	ID             string   `json:"id"`
	DisplayName    string   `json:"displayName"`
	FirstName      string   `json:"givenName"`
	LastName       string   `json:"surname"`
	Emails         []string `json:"emailAddresses"`
	BusinessPhones []string `json:"businessPhones,omitempty"`
	HomePhones     []string `json:"homePhones,omitempty"`
	MobilePhone    string   `json:"mobilePhone,omitempty"`
	Company        string   `json:"companyName"`
	JobTitle       string   `json:"jobTitle"`
}

Contact is a simplified contact representation

type DraftMessage added in v0.2.0

type DraftMessage struct {
	ID      string   `json:"id"`
	Subject string   `json:"subject"`
	To      []string `json:"to"`
	Body    string   `json:"body,omitempty"`
	Created string   `json:"createdDateTime"`
}

DraftMessage is a simplified draft message for output

type ListMessagesOptions

type ListMessagesOptions struct {
	FolderID string
	Top      int32
	Filter   string
	OrderBy  string
	Search   string
	Select   []string
}

ListMessagesOptions for filtering messages

type MailFolder

type MailFolder struct {
	ID             string `json:"id"`
	DisplayName    string `json:"displayName"`
	TotalCount     int32  `json:"totalItemCount"`
	UnreadCount    int32  `json:"unreadItemCount"`
	ParentFolderID string `json:"parentFolderId,omitempty"`
}

MailFolder is a simplified folder representation

type MailMessage

type MailMessage struct {
	ID             string   `json:"id"`
	Subject        string   `json:"subject"`
	From           string   `json:"from"`
	To             []string `json:"to"`
	ReceivedAt     string   `json:"receivedDateTime"`
	IsRead         bool     `json:"isRead"`
	HasAttachments bool     `json:"hasAttachments"`
	BodyPreview    string   `json:"bodyPreview"`
	Body           string   `json:"body,omitempty"`
	BodyType       string   `json:"bodyType,omitempty"`
}

MailMessage is a simplified mail message for output

type MailRule added in v0.3.0

type MailRule struct {
	ID          string `json:"id"`
	DisplayName string `json:"displayName"`
	Sequence    int32  `json:"sequence"`
	IsEnabled   bool   `json:"isEnabled"`
	Conditions  string `json:"conditions"`
	Actions     string `json:"actions"`
}

MailRule is a simplified message rule for output

type MeetingTimeSuggestion added in v0.3.0

type MeetingTimeSuggestion struct {
	Start                  string                     `json:"start"`
	End                    string                     `json:"end"`
	Confidence             float64                    `json:"confidence"`
	OrganizerAvailability  string                     `json:"organizerAvailability"`
	AttendeeAvailabilities []AttendeeAvailabilityInfo `json:"attendeeAvailabilities,omitempty"`
}

MeetingTimeSuggestion represents a suggested meeting time

type Person added in v0.3.0

type Person struct {
	DisplayName string `json:"displayName"`
	Email       string `json:"email"`
	JobTitle    string `json:"jobTitle,omitempty"`
	Department  string `json:"department,omitempty"`
	Company     string `json:"companyName,omitempty"`
}

Person is a simplified person for output

type ScheduleInfo added in v0.2.0

type ScheduleInfo struct {
	Email        string         `json:"email"`
	Availability string         `json:"availability"`
	Items        []ScheduleItem `json:"scheduleItems"`
}

ScheduleInfo represents the free/busy schedule for a user

type ScheduleItem added in v0.2.0

type ScheduleItem struct {
	Status  string `json:"status"`
	Start   string `json:"start"`
	End     string `json:"end"`
	Subject string `json:"subject,omitempty"`
}

ScheduleItem represents a single busy block in a user's schedule

type TodoList added in v0.2.0

type TodoList struct {
	ID          string `json:"id"`
	DisplayName string `json:"displayName"`
	IsOwner     bool   `json:"isOwner"`
}

TodoList is a simplified task list for output

type TodoTask added in v0.2.0

type TodoTask struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Status      string `json:"status"`
	Importance  string `json:"importance"`
	DueDate     string `json:"dueDateTime,omitempty"`
	CreatedAt   string `json:"createdDateTime"`
	CompletedAt string `json:"completedDateTime,omitempty"`
	Body        string `json:"body,omitempty"`
}

TodoTask is a simplified task for output

type UserProfile added in v0.2.0

type UserProfile struct {
	DisplayName string `json:"displayName"`
	Email       string `json:"mail"`
	UPN         string `json:"userPrincipalName"`
	JobTitle    string `json:"jobTitle,omitempty"`
	Department  string `json:"department,omitempty"`
	Office      string `json:"officeLocation,omitempty"`
	Phone       string `json:"businessPhones,omitempty"`
}

UserProfile is a simplified user profile for output

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL