Giter Club home page Giter Club logo

duolingo-dart / duolingo4d Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 1.0 996 KB

A most easily usable Duolingo API wrapper in Dart. Duolingo4D is an open-sourced Dart library. With Duolingo4D, you can easily integrate your application with the Duolingo API. Duolingo4D is an unofficial library.

Home Page: https://pub.dev/packages/duolingo4d

License: BSD 3-Clause "New" or "Revised" License

Dart 100.00%
dart duolingo duolingo-api duolingo4d flutter library pubdev wrapper

duolingo4d's People

Contributors

myconsciousness avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nghialmt

duolingo4d's Issues

ディスカッションをフォロー / アンフォローする機能の追加

以下のURLを使用してディスカッションをフォロー / アンフォローすることができる機能を追加する。
どちらもPOST送信で正常に処理される。

https://forum-api.duolingo.com/comments/{commentId (like 54867020)}/watch
https://forum-api.duolingo.com/comments/{commentId (like 54867020)}/unwatch

ユーザーIDの型を文字列で標準化

Duolingo APIから返却されるユーザーIDは文字列と数値で型が混在しているが、
Duolingo4DではユーザーIDを文字列として扱うように標準化する。

Forum / Forum Comment APIを参照する機能の追加

以下のURLを参照する機能を追加する。

https://forum-api.duolingo.com/comments?sort_by=new&topic_id=null

topic_id が null の場合はForumのコメントリストが返却され、
特定の topic_id が指定された場合はそのトピックのコメントリストを返却する。

sort_by は hot, new, 'followed' がある。

Stories APIに参照できる機能を追加

以下のURLに参照することができる機能を追加する。

https://stories.duolingo.com/api2/stories?fromLanguage=en&learningLanguage=ja&illustrationFormat=png

illustrationFormat はsvg, png, pdfに対応している。

認証されたDuolingoユーザーのセッション情報を取得

アプリによっては単純にDuolingo APIを使うだけではなく、
認証されたユーザーのセッションを引き継いだまま他の処理を行う場面も考えられるため、
Duolingo から認証されたDuolingoユーザーのセッション情報を返却する機能を追加する。

また、この返却されたセッション情報はDuolingo4Dの内部処理で使用するセッションオブジェクトとは別オブジェクトとし、
呼び出し側のユーザーの意志でこの新しいオブジェクトに格納されたデータは編集できない仕様とする。

fromLanguageやlearningLanguageはキャッシュして再利用する

fromLanguageやlearningLangugeといった認証されたユーザーに紐づく情報は
キャッシュして再利用するように全体的に修正を行う。

この修正で一部のメソッドに関してrequired指定されていた引数をオプションとして定義できるように修正する。

友達の情報を取得する機能を追加

Duolingoでフォローしている友達の情報を取得する機能を追加する。
フォローしている友達のIDは leaderboard_activity APIから取得できる。

キャッシュ機能を追加してから実装したほうがいいかもしれない。

整形済みのWord Hintを返却する機能

現状Word Hint APIのレスポンスはオリジナルのJSONをそのままラッピングして返却しているが、
このオリジナルのデータは構造がわかりにくく扱いにくい。

そのためある程度すぐに使える形式に整形したオブジェクトを返却する機能を追加する。
既存の機能はそのまま残すこととする。

Type string is not a subtype of type bool

In json_impl.dart is this code:
@override bool getBool({ required String key, bool defaultValue = false, }) => _resource[key] ?? defaultValue;
but if _resource[key] is not type bool, it shows error

Leaderboard APIを参照する機能の追加

以下のURLを参照する機能を追加する。

https://duolingo-leaderboards-prod.duolingo.com/leaderboards/7d9f5dd1-8423-491a-91f2-2532052038ce/users/557897808?client_unlocked=true

API通信で取得したレスポンスデータをキャッシュする機能

APIから返却されたレスポンスから特定の情報だけを抽出したい場合があり、
その際にはあらかじめAPI通信が行われ結果がキャッシュされていると毎回APIを呼び出す必要がなくなる。

そのためAPI通信で取得したレスポンスデータをキャッシュする機能を追加する。
レスポンスデータをキャッシュするかどうかは呼び出し元のオプション引数で制御する。

どのタイミングでキャッシュをクリアするかは要検討。

type 'Null' is not a subtype of type 'String'

Unhandled exception:
type 'Null' is not a subtype of type 'String'
#0      DuolingoImpl.user (package:duolingo4d/src/duolingo_impl.dart:107:13)
#1      DuolingoImpl.authenticate (package:duolingo4d/src/duolingo_impl.dart:82:34)
<asynchronous suspension>
#2      main (file:///home/******/Documents/duolingo/bin/duolingo.dart:12:37)
<asynchronous suspension>

Code:

import 'package:duolingo4d/duolingo4d.dart';


void main() async {
  final duolingo = Duolingo.instance;

  final AuthResponse authResponse = await duolingo.authenticate(
    username: '*************',
    password: '***********',
  );

  if (authResponse.status.isNotOk) {
    // Client or Server error or something.
    authResponse.status.reasonPhrase;
    authResponse.headers;
    return;
  }

  if (authResponse.hasError) {
    // When there is an error on authentication.
    final authError = authResponse.error!;
    print(authError.code);
    print(authError.reason);

    authError.isInvalidUser; // Returns true if user is invalid.
    authError.isInvalidPassword; // Returns true if password is invalid.
    return;
  }

  // Do something if user is authenticated.
}

Events APIを参照できる機能の追加

以下のURLを参照できる機能を追加する。

https://events-login.duolingo.com/api/2/events?available_only=true&end_range=2022-01-15T16:14:36.942Z&fields=hosts&is_featured_only=false&language_ids=ja&must_start_within_range=false&start_range=2021-12-16T16:14:36.942Z

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.