wk

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 6 Imported by: 0

README

go-wanikani-api

An unofficial API client designed for the WaniKani API.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assignment

type Assignment struct {
	Type          string    `json:"subject_type"`
	Id            int       `json:"subject_id"`
	Level         int       `json:"level"`
	Stage         int       `json:"srs_stage"`
	UnlockedAt    time.Time `json:"unlocked_at"`
	StartedAt     time.Time `json:"started_at"`
	PassedAt      time.Time `json:"passed_at"`
	BurnedAt      time.Time `json:"burned_at"`
	AvailableAt   time.Time `json:"available_at"`
	ResurrectedAt time.Time `json:"resurrected_at"`
}

type Assignments

type Assignments struct {
	StartedAt time.Time `json:"started_at"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string) *Client

func (*Client) GetAssignment

func (c *Client) GetAssignment(id int, opts ...Option) (*Resource[Assignment], error)

func (*Client) GetAssignments

func (c *Client) GetAssignments(opts ...Option) (*Paginate[Assignment], error)

func (*Client) StartAssignment

func (c *Client) StartAssignment(payload Assignments, id int, opts ...Option) (*Resource[Assignment], error)

type Collection

type Collection[T any] struct {
	CollectionBase
	Data []struct {
		ResourceBase
		Data T `json:"data"`
	} `json:"data"`
}

type CollectionBase

type CollectionBase struct {
	Shared
	Pages struct {
		NextURL     string `json:"next_url"`
		PreviousURL string `json:"previous_url"`
		PerPage     int    `json:"per_page"`
	} `json:"pages"`
	Count int `json:"total_count"`
}

type Option

type Option func(*options) error

func WithAvailableAfter

func WithAvailableAfter(t time.Time) Option

func WithAvailableBefore

func WithAvailableBefore(t time.Time) Option

func WithAvailableLessons

func WithAvailableLessons() Option

func WithAvailableReviews

func WithAvailableReviews() Option

func WithBurned

func WithBurned() Option

func WithHidden

func WithHidden() Option

func WithIds

func WithIds(ids []int) Option

func WithLevels

func WithLevels(levels []int) Option

func WithStage

func WithStage(stages []int) Option

func WithSubjectIDs

func WithSubjectIDs(ids []int) Option

func WithSubjectTypes

func WithSubjectTypes(types []string) Option

func WithUnlocked

func WithUnlocked() Option

func WithUpdatedAfter

func WithUpdatedAfter(t time.Time) Option

type Paginate

type Paginate[T any] struct {
	Data Collection[T]
	// contains filtered or unexported fields
}

func (*Paginate[T]) Next

func (p *Paginate[T]) Next() error

func (*Paginate[T]) Previous

func (p *Paginate[T]) Previous() error

type Resource

type Resource[T any] struct {
	ResourceBase
	Data T `json:"data"`
}

type ResourceBase

type ResourceBase struct {
	Shared
	Id int `json:"id"`
}

type Reviews

type Reviews struct {
	Reviews struct {
		AssignmentId      int       `json:"assignment_id"`
		IncorrectMeanings int       `json:"incorrect_meaning_answers"`
		IncorrectReadings int       `json:"incorrect_reading_answers"`
		CreatedAt         time.Time `json:"created_at"`
	} `json:"reviews"`
}

type Shared

type Shared struct {
	Object    string    `json:"object"`
	URL       string    `json:"url"`
	UpdatedAt time.Time `json:"data_updated_at"`
}

type StudyMaterial

type StudyMaterial struct {
	StudyMaterial struct {
		SubjectId       int      `json:"subject_id"`
		MeaningNote     string   `json:"meaning_note"`
		ReadingNote     string   `json:"reading_note"`
		MeaningSynonyms []string `json:"meaning_synonyms"`
	} `json:"study_material"`
}

type User

type User struct {
	User struct {
		Preferences struct {
			LessonsAutoplayAudio       bool   `json:"lessons_autoplay_audio"`
			LessonsBatchSize           int    `json:"lessons_batch_size"`
			LessonsPresentationOrder   string `json:"lessons_presentation_order"`
			ReviewsAutoplayAudio       bool   `json:"reviews_autoplay_audio"`
			ReviewsDisplaySrsIndicator bool   `json:"reviews_display_srs_indicator"`
		} `json:"preferences"`
	} `json:"user"`
}

Jump to

Keyboard shortcuts

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