Documentation
¶
Overview ¶
Package goil provides an interface to iseplive.fr, it's currently a WIP Supported features:
- Posting
- Deleting a post by ID
- Retrieving a student by URL
- Retrieving a list of all students along with their data
Incoming
- Retrieving only one student's data
- Retrieving students pictures
- Retrieving publications
- Commenting
- Liking / Disliking
Index ¶
- Constants
- Variables
- type Attachment
- type Attachments
- type Category
- type Event
- type Group
- type Publication
- type PublicationID
- type Session
- func (s *Session) Cookie() (*http.Cookie, error)
- func (s *Session) DeletePublication(publicationID PublicationID) error
- func (s *Session) GetAvailableGroups() (map[Group]string, error)
- func (s *Session) GetStudentByLink(link string) (Student, error)
- func (s *Session) GetStudentList() (StudentList, error)
- func (s *Session) Logout() error
- func (s *Session) PostPublication(publication *Publication) error
- type Student
- type StudentList
- type Survey
Constants ¶
const ( MB uint = 1 << (10 * 2) AttachmentMaxSizePictures = 5 * MB AttachmentMaxSizeVideos = 800 * MB AttachmentMaxSizeAudio = 20 * MB AttachmentMaxSizeDocuments = 10 * MB )
const ( Divers Category = 8 News = 6 Photos = 1 Videos = 2 Journal = 3 Gazettes = 10 Podcasts = 4 Evenements = 5 Sondages = 9 Annales = 7 )
const BaseURLString string = "http://iseplive.fr/"
Variables ¶
var BaseURL *url.URL = &url.URL{
Scheme: "http",
Host: "iseplive.fr",
}
Functions ¶
This section is empty.
Types ¶
type Attachment ¶ added in v0.1.0
type Attachment struct {
// Filename sent to the server, optional
BasePath string
// File to be sent, be sure to check max length
Reader io.Reader
// contains filtered or unexported fields
}
An attachment
type Attachments ¶ added in v0.1.0
type Attachments struct {
/* Restrictions
- can't be more than 5Mo in size each
- must be of PNG, JPEG or GIF format
*/
Pictures []Attachment
/* Restrictions
- can't be more than 800Mo in size each
- must have an audio track
*/
Videos []Attachment
/* Restrictions
- can't be more than 20Mo in size each
- must have an .mp3 extension (and probably must be mp3 themselves)
*/
Audio []Attachment
/* Restrictions
- can't be more than 10Mo in size each
- must have an extension, (i.e must match regex "\.[a-z0-9]{2,4}")
- but can't have a .jpg, .png, .gif, .mp3, .flv extension (i.e must not match regex "\.(jpg|png|gif|mp3|flv)")
*/
Documents []Attachment
}
Attachments filepath
func (Attachments) AttachAudio ¶ added in v0.1.0
func (as Attachments) AttachAudio(filename string, r io.Reader)
Attach an audio file given a filepath and a io.Reader
func (Attachments) AttachDocument ¶ added in v0.1.0
func (as Attachments) AttachDocument(filename string, r io.Reader)
Attach a document given a filepath and a io.Reader
func (Attachments) AttachPicture ¶ added in v0.1.0
func (as Attachments) AttachPicture(filename string, r io.Reader)
Attach a picture given a filepath and a io.Reader
func (Attachments) AttachVideo ¶ added in v0.1.0
func (as Attachments) AttachVideo(filename string, r io.Reader)
Attach a video given a filepath and a io.Reader
func (Attachments) Populated ¶ added in v0.1.0
func (as Attachments) Populated() bool
Checks if there are any attachments
type Event ¶ added in v0.1.0
type Event struct {
// The name of the event, mandatory
Name string
// Start and end times
Start time.Time
End time.Time
}
An event Currently only filled in / used when publishing
type Publication ¶ added in v0.1.0
type Publication struct {
// Publication's ID
// Not populated when posting, currently unused
ID PublicationID
// Message is the text body of a publication
// Mandatory for publishing
Message string
// The category of the publication meant to be published
// Only filled in on publishing
// Mandatory for publishing
Category Category
// The Group responsible for the publication
// Only filled in on publishing
Group Group
// Whether that messages is official in reference to the group
// Only used when publishing
// If Group == 0 then it has no effect
Official bool
// Whether the publication should be private
Private bool
// Whether the dislike button should be activated
Dislike bool
// Event
Event Event
// Survey
Survey Survey
// Attachments paths for upload
Attachments Attachments
}
A publication on Iseplive Not all fields are filled in when getting publications
func CreatePublication ¶ added in v0.1.0
func CreatePublication(message string, category Category) *Publication
TODO Check if when post with no group "official" field exists
func (*Publication) AddEvent ¶ added in v0.1.0
func (p *Publication) AddEvent(event Event)
Add an event to a publication
func (*Publication) AddSurvey ¶ added in v0.1.0
func (p *Publication) AddSurvey(survey Survey)
Adds a survey to a publication
func (*Publication) Check ¶ added in v0.1.0
func (p *Publication) Check() error
func (*Publication) PublishAs ¶ added in v0.1.0
func (p *Publication) PublishAs(group Group, official bool)
Post as a group
type Session ¶
func CreateSessionByCookie ¶ added in v0.1.0
CreateSessionByCookie creates a Session with the given http.Cookie and http.Client
func CreateSessionByCookieValue ¶
CreateSessionByCookieValue creates a Session with the given cookie value and http.Client
func Login ¶
Login creates a session given a username/password combo and a *http.Client Warning: It is your responsibility to add a timeout
func (*Session) DeletePublication ¶ added in v0.1.0
func (s *Session) DeletePublication(publicationID PublicationID) error
GET http://iseplive.fr/ajax/post/PUBLICATIONID/delete TODO: More info can be retrieved before redirect, notably the success/failure of the delete. retrieve it.
func (*Session) GetAvailableGroups ¶ added in v0.1.0
Find out what groups are available to the session
func (*Session) GetStudentByLink ¶ added in v0.1.0
Get a Student given a relative link to iseplive.fr: "/student/alexandrebezri" endpoint: http://iseplive.fr/student/{studentIdentifier}
func (*Session) GetStudentList ¶
func (s *Session) GetStudentList() (StudentList, error)
Return list of every student with data
func (*Session) PostPublication ¶ added in v0.1.0
func (s *Session) PostPublication(publication *Publication) error
Publish publication
type Student ¶
type Student struct {
ID string
Promo string
Name string
ISEPEmail string
Email string
Cell string
Birthday string
Quote string
}
A Student
type StudentList ¶
type StudentList []Student
A list of students
type Survey ¶ added in v0.1.0
type Survey struct {
// Mandatory
Question string
End time.Time // Format in "DD/MM/YYYY à HH:MM"
Answers []string
// Whether the survey accepts multiple answers
Multiple bool
}
A survey Currently only filled in / used when publishing
func CreateSurvey ¶ added in v0.1.0
CreateSurvey creates a survey structure