graphapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 9 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 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"`
	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) CreateContact

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

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) DeleteContact

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

func (*Client) DeleteEvent

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

func (*Client) DeleteMessage

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

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) 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) Inner

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

Inner returns the underlying Graph SDK client

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) 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) ListMessages

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

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) SendMessage

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

func (*Client) UpdateContact

func (c *Client) UpdateContact(ctx context.Context, contactID string, firstName, lastName, email, phone, 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"`
	Phones      []string `json:"phones,omitempty"`
	Company     string   `json:"companyName"`
	JobTitle    string   `json:"jobTitle"`
}

Contact is a simplified contact representation

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

Jump to

Keyboard shortcuts

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