wk

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 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 {
	SubjectType   string    `json:"subject_type"`
	SubjectId     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) CreateReview added in v0.1.0

func (c *Client) CreateReview(payload Reviews, opts ...Option) (*Resource[Review], error)

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) GetReview added in v0.1.0

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

func (*Client) GetSubject added in v0.1.0

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

func (*Client) GetSubjects added in v0.1.0

func (c *Client) GetSubjects(opts ...Option) (*Paginate[Subject], error)

func (*Client) GetUser added in v0.2.0

func (c *Client) GetUser(opts ...Option) (*Resource[User], error)

func (*Client) StartAssignment

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

func (*Client) UpdateUser added in v0.2.0

func (c *Client) UpdateUser(payload Users, opts ...Option) (*Resource[User], 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(available bool) Option

func WithAvailableReviews

func WithAvailableReviews(available bool) Option

func WithBurned

func WithBurned(burned bool) Option

func WithHidden

func WithHidden(hidden bool) Option

func WithIds

func WithIds(ids []int) Option

func WithLevels

func WithLevels(levels []int) Option

func WithSlugs added in v0.1.0

func WithSlugs(slugs []string) Option

func WithStage

func WithStage(stages []int) Option

func WithSubjectIDs

func WithSubjectIDs(ids []int) Option

func WithSubjectTypes

func WithSubjectTypes(types []string) Option

func WithTypes added in v0.1.0

func WithTypes(types []string) Option

func WithUnlocked

func WithUnlocked(unlocked bool) 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 Preferences added in v0.2.0

type Preferences struct {
	DefaultVoiceActorID        int    `json:"default_voice_actor_id"`
	ExtraStudyAutoplayAudio    bool   `json:"extra_study_autoplay_audio"`
	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"`
	ReviewsPresentationOrder   string `json:"reviews_presentation_order"`
}

type Resource

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

type ResourceBase

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

type Review added in v0.1.0

type Review struct {
	ReviewBase
	SubjectId   int `json:"subject_id"`
	StartingSRS int `json:"starting_srs_stage"`
	EndingSRS   int `json:"ending_srs_stage"`
	SRSId       int `json:"spaced_repetition_system_id"`
}

type ReviewBase added in v0.1.0

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

type Reviews

type Reviews struct {
	Review ReviewBase `json:"review"`
}

type Shared

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

type StudyMaterials added in v0.1.0

type StudyMaterials 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 Subject added in v0.1.0

type Subject struct {
	AuxiliaryMeanings []struct {
		Meaning        string `json:"meaning"`
		Primary        bool   `json:"primary"`
		AcceptedAnswer bool   `json:"accepted_answer"`
	}
	Characters      string    `json:"characters"`
	CreatedAt       time.Time `json:"created_at"`
	DocumentURL     string    `json:"document_url"`
	HiddenAt        time.Time `json:"hidden_at"`
	Level           int       `json:"level"`
	MeaningMnemonic string    `json:"meaning_mnemonic"`
	Meanings        []struct {
		Meaning string `json:"meaning"`
		Type    string `json:"type"`
	}
	Slug  string `json:"slug"`
	SRSId int    `json:"spaced_repetition_system_id"`
}

type User

type User struct {
	UserId                   string    `json:"id"`
	Name                     string    `json:"username"`
	Level                    int       `json:"level"`
	ProfileURL               string    `json:"profile_url"`
	StartedAt                time.Time `json:"started_at"`
	CurrentVacationStartedAt time.Time `json:"current_vacation_started_at"`
	Subscription             struct {
		Active          bool      `json:"active"`
		Type            string    `json:"type"`
		MaxLevelGranted int       `json:"max_level_granted"`
		PeriodEndsAt    time.Time `json:"period_ends_at"`
	} `json:"subscription"`
	Preferences Preferences `json:"preferences"`
}

type Users added in v0.1.0

type Users struct {
	User struct {
		Preferences Preferences `json:"preferences"`
	} `json:"user"`
}

Jump to

Keyboard shortcuts

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