Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding import_pgn endpoints #71

Merged
merged 6 commits into from Jan 7, 2024
Merged

Conversation

dat-boris
Copy link
Contributor

@dat-boris dat-boris commented Jan 7, 2024

Hi there,

Thanks for the project! This small PR add the study/ImportPGN endpoint.

https://lichess.org/api#tag/Studies/operation/apiStudyImportPGN

Testing with:

  session = berserk.TokenSession(API_TOKEN)
  client = berserk.Client(session=session)
  resp = client.studies.import_pgn(
      study_id=STUDY_ID,
      chapter_name="test",
      pgn=PGN,
      orientation="white",
  )
  for chapter in resp:
      print(chapter)

Returning the imported chapters.

{'id': 'oavP10Ig', 'name': 'test'}
Checklist when adding a new endpoint
  • Added new endpoint to the README.md
  • Ensure that my endpoint name does not repeat the name of the client. Wrong: client.users.get_user(), Correct: client.users.get()
  • Typed the returned JSON using TypedDicts in berserk/types/, example
  • Tested GET endpoints not requiring authentification. Documentation, example
  • Added the endpoint and your name to CHANGELOG.md in the To be released section (to be created if necessary)

@dat-boris dat-boris marked this pull request as ready for review January 7, 2024 01:35
Document the PGN can contain multiple games and for each game one chapter is created.

Type function arguments, and do not return a generator but a list because the endpoint is not streaming.

Use TypedDict because we know the keys and values.
@kraktus
Copy link
Member

kraktus commented Jan 7, 2024

Thanks for the PR! I've added/changed some more types, otherwise great work!

@kraktus kraktus merged commit b479f3c into lichess-org:master Jan 7, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants