jaccount

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Issuer    = "https://jaccount.sjtu.edu.cn/oauth2/"
	LogoutURL = "https://jaccount.sjtu.edu.cn/oauth2/logout"
)
View Source
const (
	// ScopeOpenID is the mandatory scope for all OpenID Connect OAuth2 requests.
	ScopeOpenID = "openid"

	// Read Scope
	ScopeBasic         = "basic"
	ScopeEssential     = "essential"
	ScopeProfile       = "profile"
	ScopeTasks         = "tasks"
	ScopeNotifications = "notifications"
	ScopePrivacy       = "privacy"
	ScopeIntrospect    = "introspect"
	ScopeReadApps      = "read_apps"
	ScopeWriteApps     = "write_apps"
	ScopeExchangeData  = "exchange_data"

	// Write Scope
	ScopeSendNotification   = "send_notification"
	ScopeReadMails          = "read_mails"
	ScopeSendMail           = "send_mail"
	ScopeStorage            = "storage"
	ScopeModifyNotification = "modify_notification"
	ScopeLessons            = "lessons"
	ScopeClasses            = "classes"
	ScopeExams              = "exams"
	ScopeScores             = "scores"
	ScopeStudentList        = "student_list"
	ScopeCardInfo           = "card_info"
	ScopeCardTransactions   = "card_transactions"
	ScopeWriteCardInfo      = "write_card_info"
	ScopeIncome             = "income"
	ScopeCreateJAccount     = "create_jaccount"
	ScopeEditJAccount       = "edit_jaccount"
	ScopeNetServiceInfo     = "net_service_info"
	ScopeConnectWechat      = "connect_wechat"
	ScopeConnectShmec       = "connect_shmec"
	ScopePrint              = "print"
	ScopeConnectFinance     = "connect_finance"
	ScopeStudentAffairs     = "student_affairs"
)

Variables

View Source
var Endpoint = oauth2.Endpoint{
	AuthURL:  "https://jaccount.sjtu.edu.cn/oauth2/authorize",
	TokenURL: "https://jaccount.sjtu.edu.cn/oauth2/token",
}

Endpoint is jAccount's OAuth 2.0 endpoint.

See https://developer.sjtu.edu.cn

Functions

This section is empty.

Types

type Birthday

type Birthday struct {
	BirthYear  string `json:"birthYear,omitempty"`
	BirthMonth string `json:"birthMonth,omitempty"`
	BirthDay   string `json:"birthDay,omitempty"`
}

Birthday represents the birthday of the user.

type CardInfo

type CardInfo struct {
	User         *Profile `json:"user,omitempty"`
	CardNO       string   `json:"cardNo,omitempty"`
	CardID       string   `json:"cardId,omitempty"`
	BankNO       string   `json:"bankNo,omitempty"`
	CardBalance  float64  `json:"cardBalance,omitempty"`
	Transbalance float64  `json:"transbalance,omitempty"`
	Lost         bool     `json:"lost,omitempty"`
	Frozen       bool     `json:"frozen,omitempty"`
}

type CardListTransactionsOptions

type CardListTransactionsOptions struct {
	CardNo    string `url:"cardNo,omitempty"`
	BeginDate int64  `url:"beginDate,omitempty"`
	EndDate   int64  `url:"endDate,omitempty"`
}

type CardService

type CardService service

CardService handles communications with the card data related methods of the jAccount API.

See https://developer.sjtu.edu.cn/api/card.html for more information.

func (*CardService) GetCardInfo

func (s *CardService) GetCardInfo(ctx context.Context) (*CardInfo, error)

GetCardInfo returns the card information for the user.

See https://developer.sjtu.edu.cn/api/card.html#%E8%8E%B7%E5%8F%96%E6%A0%A1%E5%9B%AD%E5%8D%A1%E4%BF%A1%E6%81%AF for more information.

func (*CardService) ListTransactions

func (s *CardService) ListTransactions(ctx context.Context, opts *CardListTransactionsOptions) ([]*CardTransaction, error)

ListTransactions returns a list of transactions for the given card.

See https://developer.sjtu.edu.cn/api/card.html#%E8%8E%B7%E5%8F%96%E4%BA%A4%E6%98%93%E8%AE%B0%E5%BD%95%E4%BF%A1%E6%81%AF for more information.

type CardTransaction

type CardTransaction struct {
	DateTime    int64   `json:"dateTime,omitempty"`
	System      string  `json:"system,omitempty"`
	Merchant    string  `json:"merchant,omitempty"`
	Description string  `json:"description,omitempty"`
	Amount      float64 `json:"amount,omitempty"`
	CardBalance float64 `json:"cardBalance,omitempty"`
}

type Client

type Client struct {
	BaseURL *url.URL

	UserAgent string

	Profile    *ProfileService
	Card       *CardService
	Enterprise *EnterpriseService
	// contains filtered or unexported fields
}

Client manages communication with the jAccount API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new jAccount API client.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response.

func (*Client) NewRequest

func (c *Client) NewRequest(method string, path string, queries url.Values) (*http.Request, error)

NewRequest creates an API request.

type Dept

type Dept struct {
	OrganizeID       string `json:"organizeId,omitempty"`
	OrganizeName     string `json:"organizeName,omitempty"`
	ParentOrganizeID string `json:"parentOrganizeId,omitempty"`
	Independent      bool   `json:"independent,omitempty"`
}

type EnterpriseService

type EnterpriseService service

EnterpriseService handles communications with the enterprise data related methods of the jAccount API.

See https://developer.sjtu.edu.cn/api/enterprise.html for more information.

func (*EnterpriseService) GetUserPositions

func (s *EnterpriseService) GetUserPositions(ctx context.Context) (*Positions, error)

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response

	ErrNO         int    `json:"errno,omitempty"`
	InternalError string `json:"error,omitempty"`
	Total         int    `json:"total,omitempty"`
}

ErrorResponse reports one or more errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type IDToken

type IDToken struct {
	Issuer   string
	Audience string
	Subject  string
	Expiry   time.Time
	IssuedAt time.Time
	Nonce    string
	Name     string
	Code     string
	Type     Type
}

func VerifyToken

func VerifyToken(rawToken string) (*IDToken, error)

type Identity

type Identity struct {
	Kind          string    `json:"kind,omitempty"`
	IsDefault     bool      `json:"isDefault,omitempty"`
	Code          string    `json:"code,omitempty"`
	UserType      string    `json:"userType,omitempty"`
	Organize      *Organize `json:"organize,omitempty"`
	MgtOrganize   *Organize `json:"mgtOrganize,omitempty"`
	Status        string    `json:"status,omitempty"`
	ExpireDate    string    `json:"expireDate,omitempty"`
	CreateDate    int64     `json:"createDate,omitempty"`
	UpdateDate    int64     `json:"updateDate,omitempty"`
	ClassNO       string    `json:"classNo,omitempty"`
	Gjm           string    `json:"gjm,omitempty"`
	Major         *Major    `json:"major,omitempty"`
	AdmissionDate string    `json:"admissionDate,omitempty"`
	TrainLevel    string    `json:"trainLevel,omitempty"`
	GraduateDate  string    `json:"graduateDate,omitempty"`
}

Identity represents the identification of the user.

type Major

type Major struct {
	Name string `json:"name,omitempty"`
	ID   string `json:"id,omitempty"`
}

Major represents the major of the user.

type Organize

type Organize struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

Organize represents the organization of the user.

type Position

type Position struct {
	Post Post `json:"post,omitempty"`
	Dept Dept `json:"dept,omitempty"`
}

type Positions

type Positions struct {
	Account   string     `json:"account,omitempty"`
	Name      string     `json:"name,omitempty"`
	Positions []Position `json:"positions,omitempty"`
}

type Post

type Post struct {
	PostCode string `json:"postCode,omitempty"`
	PostName string `json:"postName,omitempty"`
	Formal   bool   `json:"formal,omitempty"`
}

type Profile

type Profile struct {
	ID         string      `json:"id,omitempty"`
	Account    string      `json:"account,omitempty"`
	Name       string      `json:"name,omitempty"`
	Kind       string      `json:"kind,omitempty"`
	Code       string      `json:"code,omitempty"`
	UserType   string      `json:"userType,omitempty"`
	Organize   *Organize   `json:"organize,omitempty"`
	ClassNO    string      `json:"classNo,omitempty"`
	Birthday   *Birthday   `json:"birthday,omitempty"`
	Gender     string      `json:"gender,omitempty"`
	Email      string      `json:"email,omitempty"`
	TimeZone   int         `json:"timeZone,omitempty"`
	Identities []*Identity `json:"identities,omitempty"`
	CardNO     string      `json:"cardNo,omitempty"`
	CardType   string      `json:"cardType,omitempty"`
	UnionID    string      `json:"unionId,omitempty"`
}

Profile represents the profile of the user.

type ProfileService

type ProfileService service

ProfileService handles communications with the profile data related methods of the jAccount API.

See https://developer.sjtu.edu.cn/api/profile.html for more information.

func (*ProfileService) Get

func (s *ProfileService) Get(ctx context.Context) (*Profile, error)

Get gets the profile of the user.

type Response

type Response struct {
	ErrNO     int             `json:"errno,omitempty"`
	Error     string          `json:"error,omitempty"`
	Total     int             `json:"total,omitempty"`
	NextToken string          `json:"nextToken,omitempty"`
	Entities  json.RawMessage `json:"entities,omitempty"`
}

Response is a jAccount API response.

type Type

type Type string
const (
	// FACULTY represents "教职工".
	FACULTY Type = "faculty"
	// STUDENT represents "学生".
	STUDENT Type = "student"
	// MEDICAL_SCHOOL_FACULTY represents "医学院教职工".
	MEDICAL_SCHOOL_FACULTY Type = "yxy"
	// AFFILIATED_UNIT_FACULTY represents "附属单位职工".
	AFFILIATED_UNIT_FACULTY Type = "fsyyjzg"
	// VIP represents "贵宾".
	VIP Type = "vip"
	// POSTPHD represents "博士后".
	POSTPHD Type = "postphd"
	// EXTERNAL_TEACHER represents "外聘教师".
	EXTERNAL_TEACHER Type = "external_teacher"
	// SUMMER represents "暑期生".
	SUMMER Type = "summer"
	// TEAM represents "集体账号".
	TEAM Type = "team"
	// ALUMNI represents "校友".
	ALUMNI Type = "alumni"
	// GREEN represents "绿色通道".
	GREEN Type = "green"
	// OUTSIDE represents "合作交流".
	OUTSIDE Type = "outside"
)

Jump to

Keyboard shortcuts

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