neugo

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: MIT Imports: 13 Imported by: 3

README

NEU API

Codecov Go Report Card Latest Tag

🚧 WIP

📈 Roadmap

  • Login
  • Query Token
  • Query Personal Info

🎨 Usage

session := neugo.NewSession()
neugo.Use(session).WithAuth("student_id","pass").On(neugo.CAS).Login()
neugo.Use(session).WithAuth("student_id","pass").On(neugo.WebVPN).Login()
neugo.Use(session).WithAuth("student_id","pass").On(neugo.CAS).LoginService("xxx")
neugo.Use(session).WithAuth("student_id","pass").On(neugo.WebVPN).LoginService("xxx")
neugo.Use(session).WithToken("xxx").On(neugo.CAS).Login()
neugo.Use(session).WithToken("xxx").On(neugo.WebVPN).Login()
neugo.Use(session).WithToken("xxx").On(neugo.CAS).LoginService("xxx")
neugo.Use(session).WithToken("xxx").On(neugo.WebVPN).LoginService("xxx")

neugo.About(session).Token(neugo.WebVPN)
neugo.About(session).Token(neugo.CAS)

📃 License

MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncryptWebVPNUrl added in v0.2.0

func EncryptWebVPNUrl(url string) string

func NewSession

func NewSession() *http.Client

NewSession 获取带有cookiejar的http.Client,默认Timeout为3秒

Types

type ActionSelector

type ActionSelector interface {
	Login() error
	LoginService(url string) (string, error)
}

ActionSelector 选择要执行的动作

type AuthSelector

type AuthSelector interface {
	WithAuth(username, password string) PlatformSelector
	WithToken(token string) PlatformSelector
}

AuthSelector 选择鉴权方式

func Use

func Use(client *http.Client) AuthSelector

Use 接收一个 *http.Client,提供登陆动作的链式调用。如果 client 没有 cookiejar 会自动加上一个空 cookiejar.

type PersonalInfo

type PersonalInfo struct {
	Profile profile // 基本信息
	Mail    mail    // 校邮箱信息
	Wallet  wallet  // 校园卡余额信息
	Network network // 校园网余额信息
	Library library // 图书馆借阅情况
}

PersonalInfo 个人信息

type Platform

type Platform = byte

Platform 需要操作的平台

const (
	CAS    Platform = iota // 一网通 pass.neu.edu.cn
	WebVPN                 // webvpn webvpn.neu.edu.cn
)

type PlatformSelector

type PlatformSelector interface {
	On(platform Platform) ActionSelector
}

PlatformSelector 选择平台

type QuerySelector

type QuerySelector interface {
	Token(platform Platform) (string, error)
	Info(platform Platform) (*PersonalInfo, error)
}

QuerySelector 选择要查询的内容

func About

func About(client *http.Client) QuerySelector

TODO 查询 About 接收一个 *http.Client,提供查询相关信息的链式调用

Jump to

Keyboard shortcuts

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