Options
All
  • Public
  • Public/Protected
  • All
Menu

Module services/kitsu

Service for kitsu.io.

Index

Type aliases

UrlChangeCallback

UrlChangeCallback: function

Type declaration

    • (old: string | undefined, updated: string): void
    • Parameters

      • old: string | undefined
      • updated: string

      Returns void

Variables

Const EMBER_BASE

EMBER_BASE: string = `const getApp = ${(() => {// @ts-ignoreconst {Namespace, Application} = window.Ember;return Namespace.NAMESPACES.find((namespace: any) => (namespace instanceof Application));}).toString()};const getContainer = () => getApp().__container__;const getQueryCache = () => getContainer().lookup("service:query-cache");`

Code mix-in to get access to various Ember elements. This code grants access to the following methods:

  • getApp(): Ember.Application - Returns the Ember Application.
  • getContainer(): Ember.Container - Returns the App's container
  • getQueryCache():kitsu.services.QueryCache - Get the query cache service

Const GET_PROGRESS

GET_PROGRESS: string = `return await new Promise(${(// @ts-ignoreres => getQueryCache().query("library-entry", {filter: {animeId: "{{animeId}}", userId: "{{userId}}"}}).then((records: any) => {const entry = records.firstObject;res(entry.progress);}).catch((reason: any) => res(reason))).toString()});`

Code mix-in to get the Anime progress. Requires the getQueryCache function from EMBER_BASE to be loaded. The variables animeId, and userId need to be set using formatCode.

see

getProgress

Const SET_PROGRESS

SET_PROGRESS: string = `return await new Promise(${(// @ts-ignoreres => getQueryCache().query("library-entry", {filter: {animeId: "{{animeId}}", userId: "{{userId}}"}}).then((records: any) => {const entry = records.firstObject;entry.set("progress", "{{progress}}");return entry.save();}).then(() => res(true)).catch((reason: any) => res(reason))).toString()});`

Code mix-in to set the Anime progress. Requires the getQueryCache function from EMBER_BASE to be loaded. The variables animeId, userId, and progress need to be set using formatCode.

see

setProgress

Functions

getAccessToken

  • getAccessToken(): Promise<string | undefined>

getAnime

getProgress

  • getProgress(animeId: string, userId: string): Promise<number | undefined>

kitsuAPIRequest

  • kitsuAPIRequest(method: string, endpoint: string, auth?: undefined | string, config?: AxiosRequestConfig, silent?: undefined | false | true): Promise<any | null>
  • Perform a request to the Kitsu API.

    Parameters

    • method: string
    • endpoint: string
    • Optional auth: undefined | string

      Authorization header value

    • Optional config: AxiosRequestConfig
    • Optional silent: undefined | false | true

      ignore errors and return null

    Returns Promise<any | null>

setProgress

  • setProgress(animeId: string, userId: string, progress: number): Promise<boolean>

transitionTo

  • transitionTo(view: string, ...args: any[]): void
  • Transition to the given ember view.

    Parameters

    • view: string
    • Rest ...args: any[]

    Returns void

Generated using TypeDoc