Documentation ¶
Overview ¶
Package to interact programmatically with the school register ClasseViva by Spaggiari
Index ¶
- type ApiError
- type BoardItem
- type BoardItemAnswer
- type BoardItemDetail
- type BoardItemTextAnswer
- type Class
- type ContentItem
- type CvvDate
- type CvvDateTime
- type FileResource
- type HttpError
- type HttpHandler
- type HttpMiddleware
- type ItemAttachment
- type Message
- type NetworkError
- type NotAuthenticatedError
- type PkgConfig
- func (o *PkgConfig) GetClient() *http.Client
- func (o *PkgConfig) SetClientProvider(provider func() *http.Client) *PkgConfig
- func (o *PkgConfig) SetHostname(hostname string) *PkgConfig
- func (o *PkgConfig) SetSessionCheckTimeout(timeout time.Duration) *PkgConfig
- func (o *PkgConfig) Use(mw HttpMiddleware) *PkgConfig
- type Session
- func (o *Session) AnswerBoardItemWithFile(answerId string, file []byte) error
- func (o *Session) AnswerBoardItemWithText(answerId string, text string) error
- func (o *Session) CheckActive() (bool, error)
- func (o *Session) ConfirmBoardItem(answerId string) error
- func (o *Session) EnsureActive() error
- func (o *Session) GetBoardItem(boardItemId string) (*BoardItem, error)
- func (o *Session) GetBoardItems(unreadOnly bool) ([]BoardItem, error)
- func (o *Session) GetClasses() ([]Class, error)
- func (o *Session) GetContentItem(contentId string) (*ContentItem, error)
- func (o *Session) GetFileResource(resourceUrl string) (*FileResource, error)
- func (o *Session) GetMessages(unreadOnly bool, page int, pageSize int) ([]Message, error)
- func (o *Session) GetStudents(classId string) ([]Student, error)
- func (o *Session) GetTaughtSubjects() ([]Subject, error)
- func (o *Session) IsActive() bool
- func (o *Session) LoadBoardItemAttachments(boardItem *BoardItem) error
- func (o *Session) LoadBoardItemDetails(boardItem *BoardItem) error
- func (o *Session) LoadContentItemAttachments(contentItem *ContentItem) error
- func (o *Session) LoadMessageAttachments(message *Message) error
- func (o *Session) LoadMessageDetails(message *Message) error
- func (o *Session) MarkBoardItemsAsRead(items []BoardItem) error
- func (o *Session) MarkMessagesAsRead(messages []Message) error
- func (o *Session) Refresh() error
- type Student
- type Subject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiError ¶
type ApiError struct {
// contains filtered or unexported fields
}
func NewApiError ¶
type BoardItem ¶
type BoardItem struct { Id string CreatedAt time.Time Type string TypeDesc string Read bool SingleDoc bool Detail *BoardItemDetail }
Board item descriptor
func (*BoardItem) ExpectAnswer ¶
Check if an answer is expected for a board item
type BoardItemAnswer ¶
Board item answer descriptor
type BoardItemDetail ¶
type BoardItemDetail struct { Title string Text string Attachments []ItemAttachment ExpectConfirmAnswer BoardItemAnswer ExpectTextAnswer BoardItemTextAnswer ExpectAttachmentAnswer BoardItemAnswer }
Board item detail descriptor
type BoardItemTextAnswer ¶
type BoardItemTextAnswer struct { BoardItemAnswer Value string }
Board item text answer descriptor
type Class ¶
type Class struct { Id string Name string Grade int Section string Building string Course string Owned bool Link string }
Class descriptor
type ContentItem ¶
type ContentItem struct { Id string Title string FolderId string Attachments []ItemAttachment }
Message content item descriptor
type CvvDate ¶
Date in ClasseViva format
func (CvvDate) MarshalJSON ¶
func (*CvvDate) UnmarshalJSON ¶
type CvvDateTime ¶
Date and time in ClasseViva format
func (CvvDateTime) MarshalJSON ¶
func (o CvvDateTime) MarshalJSON() ([]byte, error)
func (*CvvDateTime) UnmarshalJSON ¶
func (o *CvvDateTime) UnmarshalJSON(b []byte) error
type FileResource ¶
Resource obtained as a download from the download resource endpoint
type HttpError ¶
type HttpError struct { StatusCode int // contains filtered or unexported fields }
func NewHttpError ¶
type HttpMiddleware ¶
func HttpSnapshoterBuilder ¶
func HttpSnapshoterBuilder(path string, printHash bool) HttpMiddleware
Middleware to obtain a snapshot of a test run. It saves to disk the result of every http request, hashing url and body, and reading the snapshotted response if a corresponding file is found
func MemoryCacheBuilder ¶
func MemoryCacheBuilder(expiration time.Duration) HttpMiddleware
Creates a simple in memory cache for http requests hashing url and body. Usable for testing optimization purposes.
type ItemAttachment ¶
type ItemAttachment struct { Id string Title string Url string Link string Resource *FileResource }
Attachment descriptor, both content and board
type Message ¶
type Message struct { Id string Read bool CreatedAt time.Time Sender string Subject string Body string UserLink string BoardItemId string BoardItem *BoardItem ContentItemId string ContentItem *ContentItem }
Message descriptor
type NetworkError ¶
type NetworkError struct {
// contains filtered or unexported fields
}
func NewNetworkError ¶
func NewNetworkError(e error) *NetworkError
type NotAuthenticatedError ¶
type NotAuthenticatedError struct {
// contains filtered or unexported fields
}
func NewNotAuthenticatedError ¶
func NewNotAuthenticatedError(e error) *NotAuthenticatedError
type PkgConfig ¶
type PkgConfig struct {
// contains filtered or unexported fields
}
Configuration structure accessible through chainable setters
func (*PkgConfig) SetClientProvider ¶
Set the http client provider function. Default shared client
func (*PkgConfig) SetHostname ¶
Set the configured hostname. Default "web.spaggiari.eu"
func (*PkgConfig) SetSessionCheckTimeout ¶
Set the timeout of the cvv session. Default 20 minutes
func (*PkgConfig) Use ¶
func (o *PkgConfig) Use(mw HttpMiddleware) *PkgConfig
Add a request middleware to the middleware pipeline. Middlewares are executed in the order in which they are added
type Session ¶
type Session struct { Username string // contains filtered or unexported fields }
Session of interaction with ClasseViva. It is able to refresh the session token if necessary.
func NewSession ¶
Creates a new Session, storing the necessary information to refresh the token.
func (*Session) AnswerBoardItemWithFile ¶
Answer a call to action with a file
func (*Session) AnswerBoardItemWithText ¶
Answer a call to action with text
func (*Session) CheckActive ¶
Check if a session is stil usable Asking ClasseViva website
func (*Session) ConfirmBoardItem ¶
Answer a simple call to action
func (*Session) EnsureActive ¶
func (*Session) GetBoardItem ¶
Get a specific board item with its details
func (*Session) GetBoardItems ¶
Get all the available board items.
func (*Session) GetClasses ¶
Get students of a given class
func (*Session) GetContentItem ¶
func (o *Session) GetContentItem(contentId string) (*ContentItem, error)
Get a content item of a message
func (*Session) GetFileResource ¶
func (o *Session) GetFileResource(resourceUrl string) (*FileResource, error)
func (*Session) GetMessages ¶
Get own messages
func (*Session) GetStudents ¶
Get students of a given class
func (*Session) GetTaughtSubjects ¶
Get own courses
func (*Session) LoadBoardItemAttachments ¶
Load the attachments files of a board item
func (*Session) LoadBoardItemDetails ¶
Load the detail of a board item obtained with [GetBoardItems]
func (*Session) LoadContentItemAttachments ¶
func (o *Session) LoadContentItemAttachments(contentItem *ContentItem) error
func (*Session) LoadMessageAttachments ¶
Load message attachments files
func (*Session) LoadMessageDetails ¶
Load message detail (content or boardItem) if any is present
func (*Session) MarkBoardItemsAsRead ¶
Mark a slice of items as read
func (*Session) MarkMessagesAsRead ¶
Mark a slice of messages as read