fandyy / moodle-2

Go Moodle API Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

moodle

License: MIT Tests Workflow codecov Go Report Card

Go Moodle API Client

Example

package main

import (
	"context"
	"fmt"
	"github.com/k-yomo/moodle"
	"net/url"
)

func main() {
	ctx := context.Background()
	serviceURL, err := url.Parse("https://my.uopeople.edu")
	if err != nil {
		panic(err)
	}
	moodleClient, err := moodle.NewClientWithLogin(
		ctx,
		serviceURL,
		"SXXXXXX",
		"password",
	)
	if err != nil {
		panic(err)
	}

	siteInfo, err := moodleClient.SiteAPI.GetSiteInfo(ctx)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%#v\n", siteInfo)

	courses, err := moodleClient.CourseAPI.GetEnrolledCoursesByTimelineClassification(
		ctx,
		moodle.CourseClassificationInProgress,
	)
	if err != nil {
		panic(err)
	}

	for _, c := range courses {
		fmt.Printf("%#v\n", c)
	}
}

About

Go Moodle API Client

License:MIT License


Languages

Language:Go 99.7%Language:Makefile 0.3%