├── test ├── __init__.py ├── test_difficulty.py ├── test_id.py ├── test_stat.py ├── test_one_ofid.py ├── test_problems.py ├── test_graphql_request_user.py ├── test_submission.py ├── test_graphql_query.py ├── test_submission_id.py ├── test_interpretation.py ├── test_test_submission.py ├── test_stat_status_pair.py ├── test_graphql_data.py ├── test_graphql_response.py ├── test_graphql_user.py ├── test_submission_result.py ├── test_inline_response200.py ├── test_base_submission_result.py ├── test_test_submission_result.py ├── test_graphql_query_variables.py ├── test_graphql_question_detail.py ├── test_one_ofinline_response200.py ├── test_graphql_question_solution.py ├── test_graphql_question_topic_tag.py ├── test_graphql_question_code_snippet.py ├── test_graphql_question_contributor.py ├── test_any_of_graphql_query_variables.py ├── test_graphql_problemset_question_list.py ├── test_any_of_graphql_question_detail_solution.py ├── test_graphql_query_get_question_detail_variables.py ├── test_graphql_query_problemset_question_list_variables.py ├── test_graphql_query_problemset_question_list_variables_filter_input.py ├── base.py ├── test_default_api.py ├── test_graphql_request_get_question_detail.py └── test_graphql_request_problemset_question_list.py ├── .swagger-codegen └── VERSION ├── .pyre_configuration ├── test-requirements.txt ├── requirements.txt ├── leetcode ├── api │ └── __init__.py ├── models │ ├── id.py │ ├── __init__.py │ ├── one_ofid.py │ ├── inline_response200.py │ ├── graphql_query_variables.py │ ├── one_ofinline_response200.py │ ├── any_of_graphql_query_variables.py │ ├── any_of_graphql_question_detail_solution.py │ ├── difficulty.py │ ├── graphql_response.py │ ├── submission_id.py │ ├── graphql_query_get_question_detail_variables.py │ ├── interpretation.py │ ├── graphql_problemset_question_list.py │ ├── graphql_user.py │ ├── graphql_query.py │ ├── graphql_data.py │ ├── graphql_question_solution.py │ ├── graphql_question_topic_tag.py │ ├── graphql_question_code_snippet.py │ ├── graphql_query_problemset_question_list_variables.py │ ├── graphql_question_contributor.py │ ├── test_submission.py │ ├── submission.py │ └── graphql_query_problemset_question_list_variables_filter_input.py └── __init__.py ├── .isort.cfg ├── tox.ini ├── docs ├── Id.md ├── OneOfid.md ├── InlineResponse200.md ├── GraphqlQueryVariables.md ├── OneOfinlineResponse200.md ├── AnyOfGraphqlQueryVariables.md ├── Difficulty.md ├── AnyOfGraphqlQuestionDetailSolution.md ├── SubmissionId.md ├── GraphqlResponse.md ├── Interpretation.md ├── GraphqlQueryGetQuestionDetailVariables.md ├── GraphqlUser.md ├── GraphqlQuestionSolution.md ├── GraphqlQuestionCodeSnippet.md ├── GraphqlQuery.md ├── Submission.md ├── GraphqlProblemsetQuestionList.md ├── GraphqlQuestionContributor.md ├── GraphqlQuestionTopicTag.md ├── TestSubmission.md ├── SubmissionResult.md ├── GraphqlData.md ├── StatStatusPair.md ├── GraphqlQueryProblemsetQuestionListVariablesFilterInput.md ├── GraphqlQueryProblemsetQuestionListVariables.md ├── Problems.md ├── Stat.md ├── TestSubmissionResult.md ├── BaseSubmissionResult.md └── GraphqlQuestionDetail.md ├── .travis.generated.yml ├── Dockerfile ├── .github └── workflows │ ├── pytest.yml │ └── publish-to-pypi.yml ├── setup.generated.py ├── .gitignore ├── .swagger-codegen-ignore ├── LICENSE ├── git_push.sh ├── setup.py └── README.md /test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.swagger-codegen/VERSION: -------------------------------------------------------------------------------- 1 | 3.0.27 -------------------------------------------------------------------------------- /.pyre_configuration: -------------------------------------------------------------------------------- 1 | { 2 | "source_directories": [ 3 | "." 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /test-requirements.txt: -------------------------------------------------------------------------------- 1 | coverage>=4.0.3 2 | nose>=1.3.7 3 | pluggy>=0.3.1 4 | py>=1.4.31 5 | randomize>=0.13 6 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | certifi >= 14.05.14 2 | six >= 1.10 3 | python_dateutil >= 2.5.3 4 | setuptools >= 21.0.0 5 | urllib3 >= 1.15.1 6 | requests 7 | -------------------------------------------------------------------------------- /leetcode/api/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | # import apis into api package 4 | from leetcode.api.default_api import DefaultApi 5 | 6 | # flake8: noqa 7 | -------------------------------------------------------------------------------- /.isort.cfg: -------------------------------------------------------------------------------- 1 | [settings] 2 | force_grid_wrap=0 3 | include_trailing_comma=True 4 | line_length=88 5 | multi_line_output=3 6 | use_parentheses=True 7 | ensure_newline_before_comments=True 8 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py3 3 | 4 | [testenv] 5 | deps=-r{toxinidir}/requirements.txt 6 | -r{toxinidir}/test-requirements.txt 7 | 8 | commands= 9 | nosetests \ 10 | [] 11 | -------------------------------------------------------------------------------- /docs/Id.md: -------------------------------------------------------------------------------- 1 | # Id 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/OneOfid.md: -------------------------------------------------------------------------------- 1 | # OneOfid 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/InlineResponse200.md: -------------------------------------------------------------------------------- 1 | # InlineResponse200 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/GraphqlQueryVariables.md: -------------------------------------------------------------------------------- 1 | # GraphqlQueryVariables 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/OneOfinlineResponse200.md: -------------------------------------------------------------------------------- 1 | # OneOfinlineResponse200 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/AnyOfGraphqlQueryVariables.md: -------------------------------------------------------------------------------- 1 | # AnyOfGraphqlQueryVariables 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/Difficulty.md: -------------------------------------------------------------------------------- 1 | # Difficulty 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **level** | **int** | | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /docs/AnyOfGraphqlQuestionDetailSolution.md: -------------------------------------------------------------------------------- 1 | # AnyOfGraphqlQuestionDetailSolution 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/SubmissionId.md: -------------------------------------------------------------------------------- 1 | # SubmissionId 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **submission_id** | **int** | | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /docs/GraphqlResponse.md: -------------------------------------------------------------------------------- 1 | # GraphqlResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **data** | [**GraphqlData**](GraphqlData.md) | | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /docs/Interpretation.md: -------------------------------------------------------------------------------- 1 | # Interpretation 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **interpret_id** | **str** | | 7 | **test_case** | **str** | | 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /.travis.generated.yml: -------------------------------------------------------------------------------- 1 | # ref: https://docs.travis-ci.com/user/languages/python 2 | language: python 3 | python: 4 | - "3.2" 5 | - "3.3" 6 | - "3.4" 7 | - "3.5" 8 | #- "3.5-dev" # 3.5 development branch 9 | #- "nightly" # points to the latest development branch e.g. 3.6-dev 10 | # command to install dependencies 11 | install: "pip install -r requirements.txt" 12 | # command to run tests 13 | script: nosetests 14 | -------------------------------------------------------------------------------- /docs/GraphqlQueryGetQuestionDetailVariables.md: -------------------------------------------------------------------------------- 1 | # GraphqlQueryGetQuestionDetailVariables 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **title_slug** | **str** | | [optional] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /docs/GraphqlUser.md: -------------------------------------------------------------------------------- 1 | # GraphqlUser 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **username** | **str** | | [optional] 7 | **is_current_user_premium** | **bool** | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /docs/GraphqlQuestionSolution.md: -------------------------------------------------------------------------------- 1 | # GraphqlQuestionSolution 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **id** | **str** | | 7 | **can_see_detail** | **bool** | | 8 | **typename** | **str** | | 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /docs/GraphqlQuestionCodeSnippet.md: -------------------------------------------------------------------------------- 1 | # GraphqlQuestionCodeSnippet 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **lang** | **str** | | 7 | **lang_slug** | **str** | | 8 | **code** | **str** | | 9 | **typename** | **str** | | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | -------------------------------------------------------------------------------- /docs/GraphqlQuery.md: -------------------------------------------------------------------------------- 1 | # GraphqlQuery 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **query** | **str** | | 7 | **variables** | [**AnyOfGraphqlQueryVariables**](AnyOfGraphqlQueryVariables.md) | | 8 | **operation_name** | **str** | | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /docs/Submission.md: -------------------------------------------------------------------------------- 1 | # Submission 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **judge_type** | **str** | | 7 | **lang** | **str** | | 8 | **question_id** | **int** | | 9 | **test_mode** | **bool** | | 10 | **typed_code** | **str** | | 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | -------------------------------------------------------------------------------- /docs/GraphqlProblemsetQuestionList.md: -------------------------------------------------------------------------------- 1 | # GraphqlProblemsetQuestionList 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **total_num** | **int** | | [optional] 7 | **questions** | [**list[GraphqlQuestionDetail]**](GraphqlQuestionDetail.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /docs/GraphqlQuestionContributor.md: -------------------------------------------------------------------------------- 1 | # GraphqlQuestionContributor 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **username** | **str** | | 7 | **profile_url** | **str** | | 8 | **avatar_url** | **str** | | 9 | **typename** | **str** | | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | -------------------------------------------------------------------------------- /docs/GraphqlQuestionTopicTag.md: -------------------------------------------------------------------------------- 1 | # GraphqlQuestionTopicTag 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **name** | **str** | | 7 | **slug** | **str** | | 8 | **translated_name** | **str** | | [optional] 9 | **typename** | **str** | | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | -------------------------------------------------------------------------------- /docs/TestSubmission.md: -------------------------------------------------------------------------------- 1 | # TestSubmission 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **data_input** | **str** | | 7 | **lang** | **str** | | 8 | **question_id** | **int** | | 9 | **test_mode** | **bool** | | 10 | **typed_code** | **str** | | 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | -------------------------------------------------------------------------------- /docs/SubmissionResult.md: -------------------------------------------------------------------------------- 1 | # SubmissionResult 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **compare_result** | **str** | | 7 | **std_output** | **str** | | 8 | **last_testcase** | **str** | | 9 | **expected_output** | **str** | | 10 | **input_formatted** | **str** | | 11 | **input** | **str** | | 12 | 13 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 14 | 15 | -------------------------------------------------------------------------------- /docs/GraphqlData.md: -------------------------------------------------------------------------------- 1 | # GraphqlData 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **question** | [**GraphqlQuestionDetail**](GraphqlQuestionDetail.md) | | [optional] 7 | **user** | [**GraphqlUser**](GraphqlUser.md) | | [optional] 8 | **problemset_question_list** | [**GraphqlProblemsetQuestionList**](GraphqlProblemsetQuestionList.md) | | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /docs/StatStatusPair.md: -------------------------------------------------------------------------------- 1 | # StatStatusPair 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **stat** | [**Stat**](Stat.md) | | 7 | **status** | **str** | | [optional] 8 | **difficulty** | [**Difficulty**](Difficulty.md) | | 9 | **paid_only** | **bool** | | 10 | **is_favor** | **bool** | | 11 | **frequency** | **float** | | 12 | **progress** | **float** | | 13 | 14 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 15 | 16 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Test docker file 2 | # `docker build .` verifies that the project builds and runs pytest 3 | FROM python:3.12-slim 4 | 5 | # Verify wheel can be built 6 | RUN pip install setuptools twine wheel 7 | 8 | WORKDIR /app 9 | 10 | COPY . /app/ 11 | 12 | RUN pip install --no-cache-dir . 13 | 14 | RUN python setup.py sdist bdist_wheel 15 | 16 | RUN python -c "import sys, leetcode; print(f'Package installed successfully in Python {sys.version}'); leetcode.DefaultApi(leetcode.ApiClient(leetcode.Configuration())); print('leetcode package is installed and functional')" 17 | 18 | RUN pip install pytest 19 | RUN pytest -vvvv -s 20 | -------------------------------------------------------------------------------- /docs/GraphqlQueryProblemsetQuestionListVariablesFilterInput.md: -------------------------------------------------------------------------------- 1 | # GraphqlQueryProblemsetQuestionListVariablesFilterInput 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **tags** | **list[str]** | | [optional] 7 | **difficulty** | **str** | | [optional] 8 | **status** | **str** | | [optional] 9 | **list_id** | **str** | | [optional] 10 | **premium_only** | **bool** | | [optional] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | -------------------------------------------------------------------------------- /docs/GraphqlQueryProblemsetQuestionListVariables.md: -------------------------------------------------------------------------------- 1 | # GraphqlQueryProblemsetQuestionListVariables 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **category_slug** | **str** | | [optional] 7 | **limit** | **int** | | [optional] 8 | **skip** | **int** | | [optional] 9 | **filters** | [**GraphqlQueryProblemsetQuestionListVariablesFilterInput**](GraphqlQueryProblemsetQuestionListVariablesFilterInput.md) | | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | -------------------------------------------------------------------------------- /docs/Problems.md: -------------------------------------------------------------------------------- 1 | # Problems 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **user_name** | **str** | | 7 | **num_solved** | **int** | | 8 | **num_total** | **int** | | 9 | **ac_easy** | **int** | | 10 | **ac_medium** | **int** | | 11 | **ac_hard** | **int** | | 12 | **stat_status_pairs** | [**list[StatStatusPair]**](StatStatusPair.md) | | 13 | **frequency_high** | **int** | | 14 | **frequency_mid** | **int** | | 15 | **category_slug** | **str** | | 16 | 17 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 18 | 19 | -------------------------------------------------------------------------------- /docs/Stat.md: -------------------------------------------------------------------------------- 1 | # Stat 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **question_id** | **int** | | 7 | **question__article__live** | **bool** | | [optional] 8 | **question__article__slug** | **str** | | [optional] 9 | **question__article__has_video_solution** | **bool** | | [optional] 10 | **question__title** | **str** | | 11 | **question__title_slug** | **str** | | 12 | **question__hide** | **bool** | | 13 | **total_acs** | **int** | | 14 | **total_submitted** | **int** | | 15 | **frontend_question_id** | **int** | | 16 | **is_new_question** | **bool** | | 17 | 18 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 19 | 20 | -------------------------------------------------------------------------------- /test/test_difficulty.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | import test.base 17 | 18 | import leetcode 19 | from leetcode.models.difficulty import Difficulty # noqa: E501 20 | from leetcode.rest import ApiException 21 | 22 | 23 | class TestDifficulty(test.base.BaseTest): 24 | """Difficulty unit test stubs""" 25 | 26 | def setUp(self): 27 | pass 28 | 29 | def tearDown(self): 30 | pass 31 | 32 | def testDifficulty(self): 33 | pass 34 | 35 | 36 | if __name__ == "__main__": 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /.github/workflows/pytest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Tests 3 | on: push 4 | jobs: 5 | pytest: 6 | name: Tests 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@master 10 | - name: Set up Python 11 | uses: actions/setup-python@v1 12 | with: 13 | python-version: 3.12 14 | - name: Install requirements 15 | run: pip install -r requirements.txt 16 | - name: Install test requirements 17 | run: pip install -r test-requirements.txt 18 | - name: Install pytest 19 | run: pip install pytest 20 | - name: pip freeze (for debug purposes) 21 | run: pip freeze 22 | - name: Run tests 23 | run: pytest -vvvv -s 24 | env: 25 | LEETCODE_SESSION_ID: ${{ secrets.LEETCODE_SESSION }} 26 | LEETCODE_CSRF_TOKEN: ${{ secrets.LEETCODE_CSRF_TOKEN}} 27 | -------------------------------------------------------------------------------- /test/test_id.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.id import Id # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestId(unittest.TestCase): 23 | """Id unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testId(self): 32 | """Test Id""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.id.Id() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /docs/TestSubmissionResult.md: -------------------------------------------------------------------------------- 1 | # TestSubmissionResult 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **code_answer** | **list[str]** | | 7 | **correct_answer** | **bool** | | [optional] 8 | **expected_status_code** | **int** | | [optional] 9 | **expected_lang** | **str** | | [optional] 10 | **expected_run_success** | **bool** | | [optional] 11 | **expected_status_runtime** | **str** | | [optional] 12 | **expected_memory** | **int** | | [optional] 13 | **expected_code_answer** | **list[str]** | | [optional] 14 | **expected_code_output** | **list[str]** | | [optional] 15 | **expected_elapsed_time** | **int** | | [optional] 16 | **expected_task_finish_time** | **int** | | [optional] 17 | 18 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 19 | 20 | -------------------------------------------------------------------------------- /test/test_stat.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.stat import Stat # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestStat(unittest.TestCase): 23 | """Stat unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testStat(self): 32 | """Test Stat""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.stat.Stat() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_one_ofid.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.one_ofid import OneOfid # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestOneOfid(unittest.TestCase): 23 | """OneOfid unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testOneOfid(self): 32 | """Test OneOfid""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.one_ofid.OneOfid() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_problems.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.problems import Problems # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestProblems(unittest.TestCase): 23 | """Problems unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testProblems(self): 32 | """Test Problems""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.problems.Problems() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_graphql_request_user.py: -------------------------------------------------------------------------------- 1 | import json 2 | import test.base 3 | 4 | import leetcode.models.graphql_query_variables 5 | 6 | 7 | class TestGraphqlGetUser(test.base.BaseTest): 8 | def test_request(self) -> None: 9 | graphql_request = leetcode.GraphqlQuery( 10 | query=""" 11 | { 12 | user { 13 | username 14 | isCurrentUserPremium 15 | } 16 | } 17 | """, 18 | variables=leetcode.models.graphql_query_variables.GraphqlQueryVariables(), 19 | operation_name="", 20 | ) 21 | 22 | response = self._api_instance.graphql_post(body=graphql_request) 23 | 24 | data = response.data 25 | 26 | assert data 27 | 28 | question = data.question 29 | 30 | assert question is None 31 | 32 | user = data.user 33 | 34 | assert user.username 35 | assert user.is_current_user_premium in (True, False) 36 | -------------------------------------------------------------------------------- /test/test_submission.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.submission import Submission # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestSubmission(unittest.TestCase): 23 | """Submission unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testSubmission(self): 32 | """Test Submission""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.submission.Submission() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_graphql_query.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_query import GraphqlQuery # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestGraphqlQuery(unittest.TestCase): 23 | """GraphqlQuery unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testGraphqlQuery(self): 32 | """Test GraphqlQuery""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.graphql_query.GraphqlQuery() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_submission_id.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.submission_id import SubmissionId # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestSubmissionId(unittest.TestCase): 23 | """SubmissionId unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testSubmissionId(self): 32 | """Test SubmissionId""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.submission_id.SubmissionId() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_interpretation.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.interpretation import Interpretation # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestInterpretation(unittest.TestCase): 23 | """Interpretation unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testInterpretation(self): 32 | """Test Interpretation""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.interpretation.Interpretation() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_test_submission.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.test_submission import TestSubmission # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestTestSubmission(unittest.TestCase): 23 | """TestSubmission unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testTestSubmission(self): 32 | """Test TestSubmission""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.test_submission.TestSubmission() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_stat_status_pair.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.stat_status_pair import StatStatusPair # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestStatStatusPair(unittest.TestCase): 23 | """StatStatusPair unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testStatStatusPair(self): 32 | """Test StatStatusPair""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.stat_status_pair.StatStatusPair() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_graphql_data.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_data import GraphqlData # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestGraphqlData(unittest.TestCase): 23 | """GraphqlData unit test stubs""" 24 | 25 | def setUp(self) -> None: 26 | pass 27 | 28 | def tearDown(self) -> None: 29 | pass 30 | 31 | def testGraphqlData(self) -> None: 32 | """Test GraphqlData""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.graphql_data.GraphqlData() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_graphql_response.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_response import GraphqlResponse # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestGraphqlResponse(unittest.TestCase): 23 | """GraphqlResponse unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testGraphqlResponse(self): 32 | """Test GraphqlResponse""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.graphql_response.GraphqlResponse() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_graphql_user.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_user import GraphqlUser # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestGraphqlUser(unittest.TestCase): 23 | """GraphqlUser unit test stubs""" 24 | 25 | def setUp(self) -> None: 26 | pass 27 | 28 | def tearDown(self) -> None: 29 | pass 30 | 31 | def testGraphqlUser(self) -> None: 32 | """Test GraphqlUser""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.graphql_user.GraphqlUser() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /setup.generated.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from setuptools import find_packages, setup # noqa: H301 14 | 15 | NAME = "leetcode" 16 | VERSION = "1.0.0" 17 | # To install the library, run the following 18 | # 19 | # python setup.py install 20 | # 21 | # prerequisite: setuptools 22 | # http://pypi.python.org/pypi/setuptools 23 | 24 | REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] 25 | 26 | setup( 27 | name=NAME, 28 | version=VERSION, 29 | description="Leetcode API", 30 | author_email="pv.safronov@gmail.com", 31 | url="", 32 | keywords=["Swagger", "Leetcode API"], 33 | install_requires=REQUIRES, 34 | packages=find_packages(), 35 | include_package_data=True, 36 | long_description="""\ 37 | Leetcode API implementation. # noqa: E501 38 | """, 39 | ) 40 | -------------------------------------------------------------------------------- /test/test_submission_result.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.submission_result import SubmissionResult # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestSubmissionResult(unittest.TestCase): 23 | """SubmissionResult unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testSubmissionResult(self): 32 | """Test SubmissionResult""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.submission_result.SubmissionResult() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_inline_response200.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.inline_response200 import InlineResponse200 # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestInlineResponse200(unittest.TestCase): 23 | """InlineResponse200 unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testInlineResponse200(self): 32 | """Test InlineResponse200""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.inline_response200.InlineResponse200() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_base_submission_result.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.base_submission_result import BaseSubmissionResult # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestBaseSubmissionResult(unittest.TestCase): 23 | """BaseSubmissionResult unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testBaseSubmissionResult(self): 32 | """Test BaseSubmissionResult""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.base_submission_result.BaseSubmissionResult() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_test_submission_result.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.test_submission_result import TestSubmissionResult # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestTestSubmissionResult(unittest.TestCase): 23 | """TestSubmissionResult unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testTestSubmissionResult(self): 32 | """Test TestSubmissionResult""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.test_submission_result.TestSubmissionResult() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | venv/ 48 | .python-version 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | 57 | # Sphinx documentation 58 | docs/_build/ 59 | 60 | # PyBuilder 61 | target/ 62 | 63 | #Ipython Notebook 64 | .ipynb_checkpoints 65 | 66 | # Manual 67 | .mypy_cache 68 | -------------------------------------------------------------------------------- /test/test_graphql_query_variables.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_query_variables import GraphqlQueryVariables # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestGraphqlQueryVariables(unittest.TestCase): 23 | """GraphqlQueryVariables unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testGraphqlQueryVariables(self): 32 | """Test GraphqlQueryVariables""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.graphql_query_variables.GraphqlQueryVariables() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /test/test_graphql_question_detail.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_question_detail import GraphqlQuestionDetail # noqa: E501 19 | from leetcode.rest import ApiException 20 | 21 | 22 | class TestGraphqlQuestionDetail(unittest.TestCase): 23 | """GraphqlQuestionDetail unit test stubs""" 24 | 25 | def setUp(self): 26 | pass 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def testGraphqlQuestionDetail(self): 32 | """Test GraphqlQuestionDetail""" 33 | # FIXME: construct object with mandatory attributes with example values 34 | # model = leetcode.models.graphql_question_detail.GraphqlQuestionDetail() # noqa: E501 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /.github/workflows/publish-to-pypi.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: PyPI - Build and publish 3 | on: push 4 | jobs: 5 | build-n-publish: 6 | name: PyPI - Build and publish 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@master 10 | - name: Set up Python 11 | uses: actions/setup-python@v1 12 | with: 13 | python-version: 3.12 14 | - name: Install requirements 15 | run: pip install -r requirements.txt 16 | - name: Build a binary wheel and a source tarball 17 | run: python setup.py sdist bdist_wheel 18 | - name: Publish distribution package to Test PyPI 19 | uses: pypa/gh-action-pypi-publish@master 20 | with: 21 | password: ${{ secrets.TEST_PYPI_API_TOKEN }} 22 | repository_url: https://test.pypi.org/legacy/ 23 | skip_existing: true 24 | - name: Publish distribution package to PyPI 25 | if: startsWith(github.ref, 'refs/tags') 26 | uses: pypa/gh-action-pypi-publish@master 27 | with: 28 | password: ${{ secrets.PYPI_API_TOKEN }} 29 | skip_existing: true 30 | -------------------------------------------------------------------------------- /.swagger-codegen-ignore: -------------------------------------------------------------------------------- 1 | # Swagger Codegen Ignore 2 | # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/test_one_ofinline_response200.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.one_ofinline_response200 import ( # noqa: E501 19 | OneOfinlineResponse200, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestOneOfinlineResponse200(unittest.TestCase): 25 | """OneOfinlineResponse200 unit test stubs""" 26 | 27 | def setUp(self): 28 | pass 29 | 30 | def tearDown(self): 31 | pass 32 | 33 | def testOneOfinlineResponse200(self): 34 | """Test OneOfinlineResponse200""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.one_ofinline_response200.OneOfinlineResponse200() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/test_graphql_question_solution.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_question_solution import ( # noqa: E501 19 | GraphqlQuestionSolution, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestGraphqlQuestionSolution(unittest.TestCase): 25 | """GraphqlQuestionSolution unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testGraphqlQuestionSolution(self) -> None: 34 | """Test GraphqlQuestionSolution""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.graphql_question_solution.GraphqlQuestionSolution() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /docs/BaseSubmissionResult.md: -------------------------------------------------------------------------------- 1 | # BaseSubmissionResult 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **code_output** | **list[str]** | | [optional] 7 | **elapsed_time** | **int** | | 8 | **full_runtime_error** | **str** | | [optional] 9 | **lang** | **str** | | 10 | **memory** | **int** | | 11 | **memory_percentile** | **float** | | [optional] 12 | **pretty_lang** | **str** | | 13 | **run_success** | **bool** | | 14 | **runtime_error** | **str** | | [optional] 15 | **runtime_percentile** | **float** | | [optional] 16 | **state** | **str** | | 17 | **status_code** | **int** | | 18 | **status_memory** | **str** | | [optional] 19 | **status_msg** | **str** | | 20 | **status_runtime** | **str** | | 21 | **submission_id** | **str** | | 22 | **task_finish_time** | **int** | | 23 | **total_correct** | **int** | | [optional] 24 | **total_testcases** | **int** | | [optional] 25 | **question_id** | **int** | | [optional] 26 | 27 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 28 | 29 | -------------------------------------------------------------------------------- /test/test_graphql_question_topic_tag.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_question_topic_tag import ( # noqa: E501 19 | GraphqlQuestionTopicTag, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestGraphqlQuestionTopicTag(unittest.TestCase): 25 | """GraphqlQuestionTopicTag unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testGraphqlQuestionTopicTag(self) -> None: 34 | """Test GraphqlQuestionTopicTag""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.graphql_question_topic_tag.GraphqlQuestionTopicTag() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/test_graphql_question_code_snippet.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_question_code_snippet import ( # noqa: E501 19 | GraphqlQuestionCodeSnippet, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestGraphqlQuestionCodeSnippet(unittest.TestCase): 25 | """GraphqlQuestionCodeSnippet unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testGraphqlQuestionCodeSnippet(self) -> None: 34 | """Test GraphqlQuestionCodeSnippet""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.graphql_question_code_snippet.GraphqlQuestionCodeSnippet() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/test_graphql_question_contributor.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_question_contributor import ( # noqa: E501 19 | GraphqlQuestionContributor, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestGraphqlQuestionContributor(unittest.TestCase): 25 | """GraphqlQuestionContributor unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testGraphqlQuestionContributor(self) -> None: 34 | """Test GraphqlQuestionContributor""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.graphql_question_contributor.GraphqlQuestionContributor() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/test_any_of_graphql_query_variables.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.any_of_graphql_query_variables import ( # noqa: E501 19 | AnyOfGraphqlQueryVariables, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestAnyOfGraphqlQueryVariables(unittest.TestCase): 25 | """AnyOfGraphqlQueryVariables unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testAnyOfGraphqlQueryVariables(self) -> None: 34 | """Test AnyOfGraphqlQueryVariables""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.any_of_graphql_query_variables.AnyOfGraphqlQueryVariables() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/test_graphql_problemset_question_list.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_problemset_question_list import ( # noqa: E501 19 | GraphqlProblemsetQuestionList, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestGraphqlProblemsetQuestionList(unittest.TestCase): 25 | """GraphqlProblemsetQuestionList unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testGraphqlProblemsetQuestionList(self) -> None: 34 | """Test GraphqlProblemsetQuestionList""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.graphql_problemset_question_list.GraphqlProblemsetQuestionList() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/test_any_of_graphql_question_detail_solution.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.any_of_graphql_question_detail_solution import ( # noqa: E501 19 | AnyOfGraphqlQuestionDetailSolution, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestAnyOfGraphqlQuestionDetailSolution(unittest.TestCase): 25 | """AnyOfGraphqlQuestionDetailSolution unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testAnyOfGraphqlQuestionDetailSolution(self) -> None: 34 | """Test AnyOfGraphqlQuestionDetailSolution""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.any_of_graphql_question_detail_solution.AnyOfGraphqlQuestionDetailSolution() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/test_graphql_query_get_question_detail_variables.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_query_get_question_detail_variables import ( # noqa: E501 19 | GraphqlQueryGetQuestionDetailVariables, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestGraphqlQueryGetQuestionDetailVariables(unittest.TestCase): 25 | """GraphqlQueryGetQuestionDetailVariables unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testGraphqlQueryGetQuestionDetailVariables(self) -> None: 34 | """Test GraphqlQueryGetQuestionDetailVariables""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.graphql_query_get_question_detail_variables.GraphqlQueryGetQuestionDetailVariables() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/test_graphql_query_problemset_question_list_variables.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_query_problemset_question_list_variables import ( # noqa: E501 19 | GraphqlQueryProblemsetQuestionListVariables, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestGraphqlQueryProblemsetQuestionListVariables(unittest.TestCase): 25 | """GraphqlQueryProblemsetQuestionListVariables unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testGraphqlQueryProblemsetQuestionListVariables(self) -> None: 34 | """Test GraphqlQueryProblemsetQuestionListVariables""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.graphql_query_problemset_question_list_variables.GraphqlQueryProblemsetQuestionListVariables() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /test/test_graphql_query_problemset_question_list_variables_filter_input.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import, annotations 14 | 15 | import unittest 16 | 17 | import leetcode 18 | from leetcode.models.graphql_query_problemset_question_list_variables_filter_input import ( # noqa: E501 19 | GraphqlQueryProblemsetQuestionListVariablesFilterInput, 20 | ) 21 | from leetcode.rest import ApiException 22 | 23 | 24 | class TestGraphqlQueryProblemsetQuestionListVariablesFilterInput(unittest.TestCase): 25 | """GraphqlQueryProblemsetQuestionListVariablesFilterInput unit test stubs""" 26 | 27 | def setUp(self) -> None: 28 | pass 29 | 30 | def tearDown(self) -> None: 31 | pass 32 | 33 | def testGraphqlQueryProblemsetQuestionListVariablesFilterInput(self) -> None: 34 | """Test GraphqlQueryProblemsetQuestionListVariablesFilterInput""" 35 | # FIXME: construct object with mandatory attributes with example values 36 | # model = leetcode.models.graphql_query_problemset_question_list_variables_filter_input.GraphqlQueryProblemsetQuestionListVariablesFilterInput() # noqa: E501 37 | pass 38 | 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /git_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ 3 | # 4 | # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" 5 | 6 | git_user_id=$1 7 | git_repo_id=$2 8 | release_note=$3 9 | 10 | if [ "$git_user_id" = "" ]; then 11 | git_user_id="fspv" 12 | echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" 13 | fi 14 | 15 | if [ "$git_repo_id" = "" ]; then 16 | git_repo_id="python-leetcode" 17 | echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" 18 | fi 19 | 20 | if [ "$release_note" = "" ]; then 21 | release_note="Minor update" 22 | echo "[INFO] No command line input provided. Set \$release_note to $release_note" 23 | fi 24 | 25 | # Initialize the local directory as a Git repository 26 | git init 27 | 28 | # Adds the files in the local repository and stages them for commit. 29 | git add . 30 | 31 | # Commits the tracked changes and prepares them to be pushed to a remote repository. 32 | git commit -m "$release_note" 33 | 34 | # Sets the new remote 35 | git_remote=`git remote` 36 | if [ "$git_remote" = "" ]; then # git remote not defined 37 | 38 | if [ "$GIT_TOKEN" = "" ]; then 39 | echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." 40 | git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git 41 | else 42 | git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git 43 | fi 44 | 45 | fi 46 | 47 | git pull origin master 48 | 49 | # Pushes (Forces) the changes in the local repository up to the remote repository 50 | echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" 51 | git push origin master 2>&1 | grep -v 'To https' 52 | 53 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | from setuptools import find_packages, setup # noqa: H301 15 | 16 | NAME = "python-leetcode" 17 | VERSION = "1.2.5" 18 | 19 | with open("README.md") as readme: 20 | DESCRIPTION: str = readme.read() 21 | 22 | # To install the library, run the following 23 | # 24 | # python setup.py install 25 | # 26 | # prerequisite: setuptools 27 | # http://pypi.python.org/pypi/setuptools 28 | 29 | setup( 30 | name=NAME, 31 | version=VERSION, 32 | description="Leetcode API", 33 | author="Pavel Safronov", 34 | author_email="pv.safronov@gmail.com", 35 | url="https://github.com/fspv/python-leetcode", 36 | keywords=["leetcode", "faang", "interview", "api"], 37 | install_requires=[ 38 | "certifi >= 14.05.14", 39 | "six >= 1.10", 40 | "python_dateutil >= 2.5.3", 41 | "setuptools >= 21.0.0", 42 | "urllib3 >= 1.15.1", 43 | "requests", 44 | ], 45 | packages=find_packages(), 46 | include_package_data=True, 47 | long_description=DESCRIPTION, 48 | long_description_content_type="text/markdown", 49 | classifiers=[ 50 | "Development Status :: 4 - Beta", 51 | "Intended Audience :: Developers", 52 | "Topic :: Software Development :: Libraries :: Python Modules", 53 | "License :: OSI Approved :: MIT License", 54 | "Programming Language :: Python :: 3", 55 | "Programming Language :: Python :: 3.8", 56 | "Programming Language :: Python :: 3.9", 57 | "Programming Language :: Python :: 3.10", 58 | "Programming Language :: Python :: 3.11", 59 | "Programming Language :: Python :: 3.12", 60 | ], 61 | python_requires=">=3.8", 62 | ) 63 | -------------------------------------------------------------------------------- /docs/GraphqlQuestionDetail.md: -------------------------------------------------------------------------------- 1 | # GraphqlQuestionDetail 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **question_id** | **str** | | [optional] 7 | **question_frontend_id** | **str** | | [optional] 8 | **bound_topic_id** | **str** | | [optional] 9 | **title** | **str** | | [optional] 10 | **title_slug** | **str** | | [optional] 11 | **category_title** | **str** | | [optional] 12 | **frequency** | **float** | | [optional] 13 | **freq_bar** | **float** | | [optional] 14 | **content** | **str** | | [optional] 15 | **translated_title** | **str** | | [optional] 16 | **translated_content** | **str** | | [optional] 17 | **is_paid_only** | **bool** | | [optional] 18 | **difficulty** | **str** | | [optional] 19 | **likes** | **int** | | [optional] 20 | **dislikes** | **int** | | [optional] 21 | **is_liked** | **bool** | | [optional] 22 | **is_favor** | **bool** | | [optional] 23 | **similar_questions** | **str** | | [optional] 24 | **contributors** | [**list[GraphqlQuestionContributor]**](GraphqlQuestionContributor.md) | | [optional] 25 | **lang_to_valid_playground** | **str** | | [optional] 26 | **topic_tags** | [**list[GraphqlQuestionTopicTag]**](GraphqlQuestionTopicTag.md) | | [optional] 27 | **company_tag_stats** | **str** | | [optional] 28 | **code_snippets** | [**list[GraphqlQuestionCodeSnippet]**](GraphqlQuestionCodeSnippet.md) | | [optional] 29 | **stats** | **str** | | [optional] 30 | **ac_rate** | **float** | | [optional] 31 | **hints** | **list[str]** | | [optional] 32 | **solution** | [**AnyOfGraphqlQuestionDetailSolution**](AnyOfGraphqlQuestionDetailSolution.md) | | [optional] 33 | **has_solution** | **bool** | | [optional] 34 | **has_video_solution** | **bool** | | [optional] 35 | **status** | **str** | | [optional] 36 | **sample_test_case** | **str** | | [optional] 37 | **judger_available** | **bool** | | [optional] 38 | **judge_type** | **str** | | [optional] 39 | **mysql_schemas** | **list[str]** | | [optional] 40 | **enable_run_code** | **bool** | | [optional] 41 | **enable_test_mode** | **bool** | | [optional] 42 | **env_info** | **str** | | [optional] 43 | **meta_data** | **str** | | [optional] 44 | **code_definition** | **str** | | [optional] 45 | 46 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 47 | 48 | -------------------------------------------------------------------------------- /leetcode/models/id.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class Id(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = {} 33 | 34 | attribute_map = {} 35 | 36 | def __init__(self): # noqa: E501 37 | """Id - a model defined in Swagger""" # noqa: E501 38 | self.discriminator = None 39 | 40 | def to_dict(self): 41 | """Returns the model properties as a dict""" 42 | result = {} 43 | 44 | for attr, _ in six.iteritems(self.swagger_types): 45 | value = getattr(self, attr) 46 | if isinstance(value, list): 47 | result[attr] = list( 48 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 49 | ) 50 | elif hasattr(value, "to_dict"): 51 | result[attr] = value.to_dict() 52 | elif isinstance(value, dict): 53 | result[attr] = dict( 54 | map( 55 | lambda item: (item[0], item[1].to_dict()) 56 | if hasattr(item[1], "to_dict") 57 | else item, 58 | value.items(), 59 | ) 60 | ) 61 | else: 62 | result[attr] = value 63 | if issubclass(Id, dict): 64 | for key, value in self.items(): 65 | result[key] = value 66 | 67 | return result 68 | 69 | def to_str(self): 70 | """Returns the string representation of the model""" 71 | return pprint.pformat(self.to_dict()) 72 | 73 | def __repr__(self): 74 | """For `print` and `pprint`""" 75 | return self.to_str() 76 | 77 | def __eq__(self, other): 78 | """Returns true if both objects are equal""" 79 | if not isinstance(other, Id): 80 | return False 81 | 82 | return self.__dict__ == other.__dict__ 83 | 84 | def __ne__(self, other): 85 | """Returns true if both objects are not equal""" 86 | return not self == other 87 | -------------------------------------------------------------------------------- /leetcode/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | """ 5 | Leetcode API 6 | 7 | Leetcode API implementation. # noqa: E501 8 | 9 | OpenAPI spec version: 1.0.1-1 10 | Contact: pv.safronov@gmail.com 11 | Generated by: https://github.com/swagger-api/swagger-codegen.git 12 | """ 13 | 14 | from __future__ import absolute_import 15 | 16 | # import models into model package 17 | from leetcode.models.any_of_graphql_query_variables import AnyOfGraphqlQueryVariables 18 | from leetcode.models.any_of_graphql_question_detail_solution import ( 19 | AnyOfGraphqlQuestionDetailSolution, 20 | ) 21 | from leetcode.models.base_submission_result import BaseSubmissionResult 22 | from leetcode.models.difficulty import Difficulty 23 | from leetcode.models.graphql_data import GraphqlData 24 | from leetcode.models.graphql_problemset_question_list import ( 25 | GraphqlProblemsetQuestionList, 26 | ) 27 | from leetcode.models.graphql_query import GraphqlQuery 28 | from leetcode.models.graphql_query_get_question_detail_variables import ( 29 | GraphqlQueryGetQuestionDetailVariables, 30 | ) 31 | from leetcode.models.graphql_query_problemset_question_list_variables import ( 32 | GraphqlQueryProblemsetQuestionListVariables, 33 | ) 34 | from leetcode.models.graphql_query_problemset_question_list_variables_filter_input import ( 35 | GraphqlQueryProblemsetQuestionListVariablesFilterInput, 36 | ) 37 | from leetcode.models.graphql_query_variables import GraphqlQueryVariables 38 | from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet 39 | from leetcode.models.graphql_question_contributor import GraphqlQuestionContributor 40 | from leetcode.models.graphql_question_detail import GraphqlQuestionDetail 41 | from leetcode.models.graphql_question_solution import GraphqlQuestionSolution 42 | from leetcode.models.graphql_question_topic_tag import GraphqlQuestionTopicTag 43 | from leetcode.models.graphql_response import GraphqlResponse 44 | from leetcode.models.graphql_user import GraphqlUser 45 | from leetcode.models.id import Id 46 | from leetcode.models.inline_response200 import InlineResponse200 47 | from leetcode.models.interpretation import Interpretation 48 | from leetcode.models.one_ofid import OneOfid 49 | from leetcode.models.one_ofinline_response200 import OneOfinlineResponse200 50 | from leetcode.models.problems import Problems 51 | from leetcode.models.stat import Stat 52 | from leetcode.models.stat_status_pair import StatStatusPair 53 | from leetcode.models.submission import Submission 54 | from leetcode.models.submission_id import SubmissionId 55 | from leetcode.models.submission_result import SubmissionResult 56 | from leetcode.models.test_submission import TestSubmission 57 | from leetcode.models.test_submission_result import TestSubmissionResult 58 | -------------------------------------------------------------------------------- /leetcode/models/one_ofid.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class OneOfid(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = {} 33 | 34 | attribute_map = {} 35 | 36 | def __init__(self): # noqa: E501 37 | """OneOfid - a model defined in Swagger""" # noqa: E501 38 | self.discriminator = None 39 | 40 | def to_dict(self): 41 | """Returns the model properties as a dict""" 42 | result = {} 43 | 44 | for attr, _ in six.iteritems(self.swagger_types): 45 | value = getattr(self, attr) 46 | if isinstance(value, list): 47 | result[attr] = list( 48 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 49 | ) 50 | elif hasattr(value, "to_dict"): 51 | result[attr] = value.to_dict() 52 | elif isinstance(value, dict): 53 | result[attr] = dict( 54 | map( 55 | lambda item: (item[0], item[1].to_dict()) 56 | if hasattr(item[1], "to_dict") 57 | else item, 58 | value.items(), 59 | ) 60 | ) 61 | else: 62 | result[attr] = value 63 | if issubclass(OneOfid, dict): 64 | for key, value in self.items(): 65 | result[key] = value 66 | 67 | return result 68 | 69 | def to_str(self): 70 | """Returns the string representation of the model""" 71 | return pprint.pformat(self.to_dict()) 72 | 73 | def __repr__(self): 74 | """For `print` and `pprint`""" 75 | return self.to_str() 76 | 77 | def __eq__(self, other): 78 | """Returns true if both objects are equal""" 79 | if not isinstance(other, OneOfid): 80 | return False 81 | 82 | return self.__dict__ == other.__dict__ 83 | 84 | def __ne__(self, other): 85 | """Returns true if both objects are not equal""" 86 | return not self == other 87 | -------------------------------------------------------------------------------- /leetcode/models/inline_response200.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class InlineResponse200(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = {} 33 | 34 | attribute_map = {} 35 | 36 | def __init__(self): # noqa: E501 37 | """InlineResponse200 - a model defined in Swagger""" # noqa: E501 38 | self.discriminator = None 39 | 40 | def to_dict(self): 41 | """Returns the model properties as a dict""" 42 | result = {} 43 | 44 | for attr, _ in six.iteritems(self.swagger_types): 45 | value = getattr(self, attr) 46 | if isinstance(value, list): 47 | result[attr] = list( 48 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 49 | ) 50 | elif hasattr(value, "to_dict"): 51 | result[attr] = value.to_dict() 52 | elif isinstance(value, dict): 53 | result[attr] = dict( 54 | map( 55 | lambda item: (item[0], item[1].to_dict()) 56 | if hasattr(item[1], "to_dict") 57 | else item, 58 | value.items(), 59 | ) 60 | ) 61 | else: 62 | result[attr] = value 63 | if issubclass(InlineResponse200, dict): 64 | for key, value in self.items(): 65 | result[key] = value 66 | 67 | return result 68 | 69 | def to_str(self): 70 | """Returns the string representation of the model""" 71 | return pprint.pformat(self.to_dict()) 72 | 73 | def __repr__(self): 74 | """For `print` and `pprint`""" 75 | return self.to_str() 76 | 77 | def __eq__(self, other): 78 | """Returns true if both objects are equal""" 79 | if not isinstance(other, InlineResponse200): 80 | return False 81 | 82 | return self.__dict__ == other.__dict__ 83 | 84 | def __ne__(self, other): 85 | """Returns true if both objects are not equal""" 86 | return not self == other 87 | -------------------------------------------------------------------------------- /leetcode/models/graphql_query_variables.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class GraphqlQueryVariables(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = {} 33 | 34 | attribute_map = {} 35 | 36 | def __init__(self): # noqa: E501 37 | """GraphqlQueryVariables - a model defined in Swagger""" # noqa: E501 38 | self.discriminator = None 39 | 40 | def to_dict(self): 41 | """Returns the model properties as a dict""" 42 | result = {} 43 | 44 | for attr, _ in six.iteritems(self.swagger_types): 45 | value = getattr(self, attr) 46 | if isinstance(value, list): 47 | result[attr] = list( 48 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 49 | ) 50 | elif hasattr(value, "to_dict"): 51 | result[attr] = value.to_dict() 52 | elif isinstance(value, dict): 53 | result[attr] = dict( 54 | map( 55 | lambda item: (item[0], item[1].to_dict()) 56 | if hasattr(item[1], "to_dict") 57 | else item, 58 | value.items(), 59 | ) 60 | ) 61 | else: 62 | result[attr] = value 63 | if issubclass(GraphqlQueryVariables, dict): 64 | for key, value in self.items(): 65 | result[key] = value 66 | 67 | return result 68 | 69 | def to_str(self): 70 | """Returns the string representation of the model""" 71 | return pprint.pformat(self.to_dict()) 72 | 73 | def __repr__(self): 74 | """For `print` and `pprint`""" 75 | return self.to_str() 76 | 77 | def __eq__(self, other): 78 | """Returns true if both objects are equal""" 79 | if not isinstance(other, GraphqlQueryVariables): 80 | return False 81 | 82 | return self.__dict__ == other.__dict__ 83 | 84 | def __ne__(self, other): 85 | """Returns true if both objects are not equal""" 86 | return not self == other 87 | -------------------------------------------------------------------------------- /leetcode/models/one_ofinline_response200.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class OneOfinlineResponse200(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = {} 33 | 34 | attribute_map = {} 35 | 36 | def __init__(self): # noqa: E501 37 | """OneOfinlineResponse200 - a model defined in Swagger""" # noqa: E501 38 | self.discriminator = None 39 | 40 | def to_dict(self): 41 | """Returns the model properties as a dict""" 42 | result = {} 43 | 44 | for attr, _ in six.iteritems(self.swagger_types): 45 | value = getattr(self, attr) 46 | if isinstance(value, list): 47 | result[attr] = list( 48 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 49 | ) 50 | elif hasattr(value, "to_dict"): 51 | result[attr] = value.to_dict() 52 | elif isinstance(value, dict): 53 | result[attr] = dict( 54 | map( 55 | lambda item: (item[0], item[1].to_dict()) 56 | if hasattr(item[1], "to_dict") 57 | else item, 58 | value.items(), 59 | ) 60 | ) 61 | else: 62 | result[attr] = value 63 | if issubclass(OneOfinlineResponse200, dict): 64 | for key, value in self.items(): 65 | result[key] = value 66 | 67 | return result 68 | 69 | def to_str(self): 70 | """Returns the string representation of the model""" 71 | return pprint.pformat(self.to_dict()) 72 | 73 | def __repr__(self): 74 | """For `print` and `pprint`""" 75 | return self.to_str() 76 | 77 | def __eq__(self, other): 78 | """Returns true if both objects are equal""" 79 | if not isinstance(other, OneOfinlineResponse200): 80 | return False 81 | 82 | return self.__dict__ == other.__dict__ 83 | 84 | def __ne__(self, other): 85 | """Returns true if both objects are not equal""" 86 | return not self == other 87 | -------------------------------------------------------------------------------- /leetcode/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | 5 | """ 6 | Leetcode API 7 | 8 | Leetcode API implementation. # noqa: E501 9 | 10 | OpenAPI spec version: 1.0.1-1 11 | Contact: pv.safronov@gmail.com 12 | Generated by: https://github.com/swagger-api/swagger-codegen.git 13 | """ 14 | 15 | from __future__ import absolute_import 16 | 17 | # import apis into sdk package 18 | from leetcode.api.default_api import DefaultApi 19 | 20 | # import ApiClient 21 | from leetcode.api_client import ApiClient 22 | from leetcode.configuration import Configuration 23 | 24 | # import models into sdk package 25 | from leetcode.models.any_of_graphql_query_variables import AnyOfGraphqlQueryVariables 26 | from leetcode.models.any_of_graphql_question_detail_solution import ( 27 | AnyOfGraphqlQuestionDetailSolution, 28 | ) 29 | from leetcode.models.base_submission_result import BaseSubmissionResult 30 | from leetcode.models.difficulty import Difficulty 31 | from leetcode.models.graphql_data import GraphqlData 32 | from leetcode.models.graphql_problemset_question_list import ( 33 | GraphqlProblemsetQuestionList, 34 | ) 35 | from leetcode.models.graphql_query import GraphqlQuery 36 | from leetcode.models.graphql_query_get_question_detail_variables import ( 37 | GraphqlQueryGetQuestionDetailVariables, 38 | ) 39 | from leetcode.models.graphql_query_problemset_question_list_variables import ( 40 | GraphqlQueryProblemsetQuestionListVariables, 41 | ) 42 | from leetcode.models.graphql_query_problemset_question_list_variables_filter_input import ( 43 | GraphqlQueryProblemsetQuestionListVariablesFilterInput, 44 | ) 45 | from leetcode.models.graphql_query_variables import GraphqlQueryVariables 46 | from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet 47 | from leetcode.models.graphql_question_contributor import GraphqlQuestionContributor 48 | from leetcode.models.graphql_question_detail import GraphqlQuestionDetail 49 | from leetcode.models.graphql_question_solution import GraphqlQuestionSolution 50 | from leetcode.models.graphql_question_topic_tag import GraphqlQuestionTopicTag 51 | from leetcode.models.graphql_response import GraphqlResponse 52 | from leetcode.models.graphql_user import GraphqlUser 53 | from leetcode.models.id import Id 54 | from leetcode.models.inline_response200 import InlineResponse200 55 | from leetcode.models.interpretation import Interpretation 56 | from leetcode.models.one_ofid import OneOfid 57 | from leetcode.models.one_ofinline_response200 import OneOfinlineResponse200 58 | from leetcode.models.problems import Problems 59 | from leetcode.models.stat import Stat 60 | from leetcode.models.stat_status_pair import StatStatusPair 61 | from leetcode.models.submission import Submission 62 | from leetcode.models.submission_id import SubmissionId 63 | from leetcode.models.submission_result import SubmissionResult 64 | from leetcode.models.test_submission import TestSubmission 65 | from leetcode.models.test_submission_result import TestSubmissionResult 66 | -------------------------------------------------------------------------------- /leetcode/models/any_of_graphql_query_variables.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class AnyOfGraphqlQueryVariables(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = {} 34 | 35 | attribute_map = {} 36 | 37 | def __init__(self) -> None: # noqa: E501 38 | """AnyOfGraphqlQueryVariables - a model defined in Swagger""" # noqa: E501 39 | self.discriminator = None 40 | 41 | def to_dict(self): 42 | """Returns the model properties as a dict""" 43 | result = {} 44 | 45 | for attr, _ in six.iteritems(self.swagger_types): 46 | value = getattr(self, attr) 47 | if isinstance(value, list): 48 | result[attr] = list( 49 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 50 | ) 51 | elif hasattr(value, "to_dict"): 52 | result[attr] = value.to_dict() 53 | elif isinstance(value, dict): 54 | result[attr] = dict( 55 | map( 56 | lambda item: (item[0], item[1].to_dict()) 57 | if hasattr(item[1], "to_dict") 58 | else item, 59 | value.items(), 60 | ) 61 | ) 62 | else: 63 | result[attr] = value 64 | if issubclass(AnyOfGraphqlQueryVariables, dict): 65 | for key, value in self.items(): 66 | result[key] = value 67 | 68 | return result 69 | 70 | def to_str(self) -> str: 71 | """Returns the string representation of the model""" 72 | return pprint.pformat(self.to_dict()) 73 | 74 | def __repr__(self) -> str: 75 | """For `print` and `pprint`""" 76 | return self.to_str() 77 | 78 | def __eq__(self, other: AnyOfGraphqlQueryVariables) -> bool: 79 | """Returns true if both objects are equal""" 80 | if not isinstance(other, AnyOfGraphqlQueryVariables): 81 | return False 82 | 83 | return self.__dict__ == other.__dict__ 84 | 85 | def __ne__(self, other) -> bool: 86 | """Returns true if both objects are not equal""" 87 | return not self == other 88 | -------------------------------------------------------------------------------- /leetcode/models/any_of_graphql_question_detail_solution.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class AnyOfGraphqlQuestionDetailSolution(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = {} 34 | 35 | attribute_map = {} 36 | 37 | def __init__(self) -> None: # noqa: E501 38 | """AnyOfGraphqlQuestionDetailSolution - a model defined in Swagger""" # noqa: E501 39 | self.discriminator = None 40 | 41 | def to_dict(self): 42 | """Returns the model properties as a dict""" 43 | result = {} 44 | 45 | for attr, _ in six.iteritems(self.swagger_types): 46 | value = getattr(self, attr) 47 | if isinstance(value, list): 48 | result[attr] = list( 49 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 50 | ) 51 | elif hasattr(value, "to_dict"): 52 | result[attr] = value.to_dict() 53 | elif isinstance(value, dict): 54 | result[attr] = dict( 55 | map( 56 | lambda item: (item[0], item[1].to_dict()) 57 | if hasattr(item[1], "to_dict") 58 | else item, 59 | value.items(), 60 | ) 61 | ) 62 | else: 63 | result[attr] = value 64 | if issubclass(AnyOfGraphqlQuestionDetailSolution, dict): 65 | for key, value in self.items(): 66 | result[key] = value 67 | 68 | return result 69 | 70 | def to_str(self) -> str: 71 | """Returns the string representation of the model""" 72 | return pprint.pformat(self.to_dict()) 73 | 74 | def __repr__(self) -> str: 75 | """For `print` and `pprint`""" 76 | return self.to_str() 77 | 78 | def __eq__(self, other: AnyOfGraphqlQuestionDetailSolution) -> bool: 79 | """Returns true if both objects are equal""" 80 | if not isinstance(other, AnyOfGraphqlQuestionDetailSolution): 81 | return False 82 | 83 | return self.__dict__ == other.__dict__ 84 | 85 | def __ne__(self, other) -> bool: 86 | """Returns true if both objects are not equal""" 87 | return not self == other 88 | -------------------------------------------------------------------------------- /leetcode/models/difficulty.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class Difficulty(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = {"level": "int"} 33 | 34 | attribute_map = {"level": "level"} 35 | 36 | def __init__(self, level=None): # noqa: E501 37 | """Difficulty - a model defined in Swagger""" # noqa: E501 38 | self._level = None 39 | self.discriminator = None 40 | self.level = level 41 | 42 | @property 43 | def level(self): 44 | """Gets the level of this Difficulty. # noqa: E501 45 | 46 | 47 | :return: The level of this Difficulty. # noqa: E501 48 | :rtype: int 49 | """ 50 | return self._level 51 | 52 | @level.setter 53 | def level(self, level): 54 | """Sets the level of this Difficulty. 55 | 56 | 57 | :param level: The level of this Difficulty. # noqa: E501 58 | :type: int 59 | """ 60 | if level is None: 61 | raise ValueError( 62 | "Invalid value for `level`, must not be `None`" 63 | ) # noqa: E501 64 | 65 | self._level = level 66 | 67 | def to_dict(self): 68 | """Returns the model properties as a dict""" 69 | result = {} 70 | 71 | for attr, _ in six.iteritems(self.swagger_types): 72 | value = getattr(self, attr) 73 | if isinstance(value, list): 74 | result[attr] = list( 75 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 76 | ) 77 | elif hasattr(value, "to_dict"): 78 | result[attr] = value.to_dict() 79 | elif isinstance(value, dict): 80 | result[attr] = dict( 81 | map( 82 | lambda item: (item[0], item[1].to_dict()) 83 | if hasattr(item[1], "to_dict") 84 | else item, 85 | value.items(), 86 | ) 87 | ) 88 | else: 89 | result[attr] = value 90 | if issubclass(Difficulty, dict): 91 | for key, value in self.items(): 92 | result[key] = value 93 | 94 | return result 95 | 96 | def to_str(self): 97 | """Returns the string representation of the model""" 98 | return pprint.pformat(self.to_dict()) 99 | 100 | def __repr__(self): 101 | """For `print` and `pprint`""" 102 | return self.to_str() 103 | 104 | def __eq__(self, other): 105 | """Returns true if both objects are equal""" 106 | if not isinstance(other, Difficulty): 107 | return False 108 | 109 | return self.__dict__ == other.__dict__ 110 | 111 | def __ne__(self, other): 112 | """Returns true if both objects are not equal""" 113 | return not self == other 114 | -------------------------------------------------------------------------------- /test/base.py: -------------------------------------------------------------------------------- 1 | import os 2 | from typing import Any, Optional 3 | 4 | import leetcode.api.default_api 5 | import leetcode.api_client 6 | import leetcode.configuration 7 | 8 | def validate_stat_status_pair(stat_status_pair: Any) -> None: 9 | assert isinstance(stat_status_pair, leetcode.StatStatusPair) 10 | assert isinstance(stat_status_pair.difficulty, leetcode.Difficulty) 11 | assert isinstance(stat_status_pair.difficulty.level, int) 12 | assert isinstance(stat_status_pair.frequency, float) 13 | assert isinstance(stat_status_pair.is_favor, bool) 14 | assert isinstance(stat_status_pair.paid_only, bool) 15 | assert isinstance(stat_status_pair.stat, leetcode.Stat) 16 | if stat_status_pair.status is not None: 17 | assert isinstance(stat_status_pair.status, str) 18 | 19 | assert isinstance(stat_status_pair.stat.frontend_question_id, int) 20 | assert isinstance(stat_status_pair.stat.is_new_question, bool) 21 | if stat_status_pair.stat.question__article__live is not None: 22 | assert isinstance(stat_status_pair.stat.question__article__live, bool) 23 | if stat_status_pair.stat.question__article__slug is not None: 24 | assert isinstance(stat_status_pair.stat.question__article__slug, str) 25 | assert isinstance(stat_status_pair.stat.question__hide, bool) 26 | assert isinstance(stat_status_pair.stat.question__title, str) 27 | assert isinstance(stat_status_pair.stat.question__title_slug, str) 28 | assert isinstance(stat_status_pair.stat.question_id, int) 29 | assert isinstance(stat_status_pair.stat.total_acs, int) 30 | assert isinstance(stat_status_pair.stat.total_submitted, int) 31 | 32 | def validate_problems(problems: Any, category_slug: str) -> None: 33 | assert isinstance(problems, leetcode.Problems) 34 | assert isinstance(problems.ac_easy, int) 35 | assert isinstance(problems.ac_hard, int) 36 | assert isinstance(problems.ac_medium, int) 37 | assert problems.category_slug == category_slug 38 | assert isinstance(problems.num_solved, int) 39 | assert isinstance(problems.num_total, int) 40 | assert isinstance(problems.stat_status_pairs, list) 41 | 42 | for stat_status_pair in problems.stat_status_pairs: 43 | validate_stat_status_pair(stat_status_pair) 44 | 45 | 46 | class BaseTest: 47 | _api_instance_containter: Optional[leetcode.api.default_api.DefaultApi] = None 48 | 49 | @property 50 | def _api_instance(self) -> leetcode.api.default_api.DefaultApi: 51 | api_instance = self._api_instance_containter 52 | 53 | if api_instance is None: 54 | raise RuntimeError("Api instance is not initialized") 55 | 56 | return api_instance 57 | 58 | @_api_instance.setter 59 | def _api_instance( 60 | self, value: Optional[leetcode.api.default_api.DefaultApi] 61 | ) -> None: 62 | self._api_instance_containter = value 63 | 64 | def setup_method(self) -> None: 65 | session_id = os.environ["LEETCODE_SESSION_ID"] 66 | csrftoken = os.environ["LEETCODE_CSRF_TOKEN"] 67 | 68 | configuration = leetcode.configuration.Configuration() 69 | 70 | configuration.api_key["x-csrftoken"] = csrftoken 71 | configuration.api_key["csrftoken"] = csrftoken 72 | configuration.api_key["LEETCODE_SESSION"] = session_id 73 | configuration.api_key["Referer"] = "https://leetcode.com" 74 | 75 | configuration.debug = False 76 | 77 | self._api_instance = leetcode.api.default_api.DefaultApi( 78 | leetcode.api_client.ApiClient(configuration) 79 | ) 80 | 81 | def teardown(self) -> None: 82 | api_instance = self._api_instance 83 | 84 | del api_instance 85 | 86 | self._api_instance = None 87 | -------------------------------------------------------------------------------- /leetcode/models/graphql_response.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class GraphqlResponse(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = {"data": "GraphqlData"} 33 | 34 | attribute_map = {"data": "data"} 35 | 36 | def __init__(self, data=None): # noqa: E501 37 | """GraphqlResponse - a model defined in Swagger""" # noqa: E501 38 | self._data = None 39 | self.discriminator = None 40 | self.data = data 41 | 42 | @property 43 | def data(self): 44 | """Gets the data of this GraphqlResponse. # noqa: E501 45 | 46 | 47 | :return: The data of this GraphqlResponse. # noqa: E501 48 | :rtype: GraphqlData 49 | """ 50 | return self._data 51 | 52 | @data.setter 53 | def data(self, data): 54 | """Sets the data of this GraphqlResponse. 55 | 56 | 57 | :param data: The data of this GraphqlResponse. # noqa: E501 58 | :type: GraphqlData 59 | """ 60 | if data is None: 61 | raise ValueError( 62 | "Invalid value for `data`, must not be `None`" 63 | ) # noqa: E501 64 | 65 | self._data = data 66 | 67 | def to_dict(self): 68 | """Returns the model properties as a dict""" 69 | result = {} 70 | 71 | for attr, _ in six.iteritems(self.swagger_types): 72 | value = getattr(self, attr) 73 | if isinstance(value, list): 74 | result[attr] = list( 75 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 76 | ) 77 | elif hasattr(value, "to_dict"): 78 | result[attr] = value.to_dict() 79 | elif isinstance(value, dict): 80 | result[attr] = dict( 81 | map( 82 | lambda item: (item[0], item[1].to_dict()) 83 | if hasattr(item[1], "to_dict") 84 | else item, 85 | value.items(), 86 | ) 87 | ) 88 | else: 89 | result[attr] = value 90 | if issubclass(GraphqlResponse, dict): 91 | for key, value in self.items(): 92 | result[key] = value 93 | 94 | return result 95 | 96 | def to_str(self): 97 | """Returns the string representation of the model""" 98 | return pprint.pformat(self.to_dict()) 99 | 100 | def __repr__(self): 101 | """For `print` and `pprint`""" 102 | return self.to_str() 103 | 104 | def __eq__(self, other): 105 | """Returns true if both objects are equal""" 106 | if not isinstance(other, GraphqlResponse): 107 | return False 108 | 109 | return self.__dict__ == other.__dict__ 110 | 111 | def __ne__(self, other): 112 | """Returns true if both objects are not equal""" 113 | return not self == other 114 | -------------------------------------------------------------------------------- /leetcode/models/submission_id.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class SubmissionId(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = {"submission_id": "int"} 33 | 34 | attribute_map = {"submission_id": "submission_id"} 35 | 36 | def __init__(self, submission_id=None): # noqa: E501 37 | """SubmissionId - a model defined in Swagger""" # noqa: E501 38 | self._submission_id = None 39 | self.discriminator = None 40 | self.submission_id = submission_id 41 | 42 | @property 43 | def submission_id(self): 44 | """Gets the submission_id of this SubmissionId. # noqa: E501 45 | 46 | 47 | :return: The submission_id of this SubmissionId. # noqa: E501 48 | :rtype: int 49 | """ 50 | return self._submission_id 51 | 52 | @submission_id.setter 53 | def submission_id(self, submission_id): 54 | """Sets the submission_id of this SubmissionId. 55 | 56 | 57 | :param submission_id: The submission_id of this SubmissionId. # noqa: E501 58 | :type: int 59 | """ 60 | if submission_id is None: 61 | raise ValueError( 62 | "Invalid value for `submission_id`, must not be `None`" 63 | ) # noqa: E501 64 | 65 | self._submission_id = submission_id 66 | 67 | def to_dict(self): 68 | """Returns the model properties as a dict""" 69 | result = {} 70 | 71 | for attr, _ in six.iteritems(self.swagger_types): 72 | value = getattr(self, attr) 73 | if isinstance(value, list): 74 | result[attr] = list( 75 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 76 | ) 77 | elif hasattr(value, "to_dict"): 78 | result[attr] = value.to_dict() 79 | elif isinstance(value, dict): 80 | result[attr] = dict( 81 | map( 82 | lambda item: (item[0], item[1].to_dict()) 83 | if hasattr(item[1], "to_dict") 84 | else item, 85 | value.items(), 86 | ) 87 | ) 88 | else: 89 | result[attr] = value 90 | if issubclass(SubmissionId, dict): 91 | for key, value in self.items(): 92 | result[key] = value 93 | 94 | return result 95 | 96 | def to_str(self): 97 | """Returns the string representation of the model""" 98 | return pprint.pformat(self.to_dict()) 99 | 100 | def __repr__(self): 101 | """For `print` and `pprint`""" 102 | return self.to_str() 103 | 104 | def __eq__(self, other): 105 | """Returns true if both objects are equal""" 106 | if not isinstance(other, SubmissionId): 107 | return False 108 | 109 | return self.__dict__ == other.__dict__ 110 | 111 | def __ne__(self, other): 112 | """Returns true if both objects are not equal""" 113 | return not self == other 114 | -------------------------------------------------------------------------------- /leetcode/models/graphql_query_get_question_detail_variables.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlQueryGetQuestionDetailVariables(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = {"title_slug": "str"} 34 | 35 | attribute_map = {"title_slug": "titleSlug"} 36 | 37 | def __init__(self, title_slug=None) -> None: # noqa: E501 38 | """GraphqlQueryGetQuestionDetailVariables - a model defined in Swagger""" # noqa: E501 39 | self._title_slug = None 40 | self.discriminator = None 41 | if title_slug is not None: 42 | self.title_slug = title_slug 43 | 44 | @property 45 | def title_slug(self): 46 | """Gets the title_slug of this GraphqlQueryGetQuestionDetailVariables. # noqa: E501 47 | 48 | 49 | :return: The title_slug of this GraphqlQueryGetQuestionDetailVariables. # noqa: E501 50 | :rtype: str 51 | """ 52 | return self._title_slug 53 | 54 | @title_slug.setter 55 | def title_slug(self, title_slug): 56 | """Sets the title_slug of this GraphqlQueryGetQuestionDetailVariables. 57 | 58 | 59 | :param title_slug: The title_slug of this GraphqlQueryGetQuestionDetailVariables. # noqa: E501 60 | :type: str 61 | """ 62 | 63 | self._title_slug = title_slug 64 | 65 | def to_dict(self): 66 | """Returns the model properties as a dict""" 67 | result = {} 68 | 69 | for attr, _ in six.iteritems(self.swagger_types): 70 | value = getattr(self, attr) 71 | if isinstance(value, list): 72 | result[attr] = list( 73 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 74 | ) 75 | elif hasattr(value, "to_dict"): 76 | result[attr] = value.to_dict() 77 | elif isinstance(value, dict): 78 | result[attr] = dict( 79 | map( 80 | lambda item: (item[0], item[1].to_dict()) 81 | if hasattr(item[1], "to_dict") 82 | else item, 83 | value.items(), 84 | ) 85 | ) 86 | else: 87 | result[attr] = value 88 | if issubclass(GraphqlQueryGetQuestionDetailVariables, dict): 89 | for key, value in self.items(): 90 | result[key] = value 91 | 92 | return result 93 | 94 | def to_str(self) -> str: 95 | """Returns the string representation of the model""" 96 | return pprint.pformat(self.to_dict()) 97 | 98 | def __repr__(self) -> str: 99 | """For `print` and `pprint`""" 100 | return self.to_str() 101 | 102 | def __eq__(self, other: GraphqlQueryGetQuestionDetailVariables) -> bool: 103 | """Returns true if both objects are equal""" 104 | if not isinstance(other, GraphqlQueryGetQuestionDetailVariables): 105 | return False 106 | 107 | return self.__dict__ == other.__dict__ 108 | 109 | def __ne__(self, other) -> bool: 110 | """Returns true if both objects are not equal""" 111 | return not self == other 112 | -------------------------------------------------------------------------------- /leetcode/models/interpretation.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class Interpretation(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = {"interpret_id": "str", "test_case": "str"} 33 | 34 | attribute_map = {"interpret_id": "interpret_id", "test_case": "test_case"} 35 | 36 | def __init__(self, interpret_id=None, test_case=None): # noqa: E501 37 | """Interpretation - a model defined in Swagger""" # noqa: E501 38 | self._interpret_id = None 39 | self._test_case = None 40 | self.discriminator = None 41 | self.interpret_id = interpret_id 42 | self.test_case = test_case 43 | 44 | @property 45 | def interpret_id(self): 46 | """Gets the interpret_id of this Interpretation. # noqa: E501 47 | 48 | 49 | :return: The interpret_id of this Interpretation. # noqa: E501 50 | :rtype: str 51 | """ 52 | return self._interpret_id 53 | 54 | @interpret_id.setter 55 | def interpret_id(self, interpret_id): 56 | """Sets the interpret_id of this Interpretation. 57 | 58 | 59 | :param interpret_id: The interpret_id of this Interpretation. # noqa: E501 60 | :type: str 61 | """ 62 | if interpret_id is None: 63 | raise ValueError( 64 | "Invalid value for `interpret_id`, must not be `None`" 65 | ) # noqa: E501 66 | 67 | self._interpret_id = interpret_id 68 | 69 | @property 70 | def test_case(self): 71 | """Gets the test_case of this Interpretation. # noqa: E501 72 | 73 | 74 | :return: The test_case of this Interpretation. # noqa: E501 75 | :rtype: str 76 | """ 77 | return self._test_case 78 | 79 | @test_case.setter 80 | def test_case(self, test_case): 81 | """Sets the test_case of this Interpretation. 82 | 83 | 84 | :param test_case: The test_case of this Interpretation. # noqa: E501 85 | :type: str 86 | """ 87 | if test_case is None: 88 | raise ValueError( 89 | "Invalid value for `test_case`, must not be `None`" 90 | ) # noqa: E501 91 | 92 | self._test_case = test_case 93 | 94 | def to_dict(self): 95 | """Returns the model properties as a dict""" 96 | result = {} 97 | 98 | for attr, _ in six.iteritems(self.swagger_types): 99 | value = getattr(self, attr) 100 | if isinstance(value, list): 101 | result[attr] = list( 102 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 103 | ) 104 | elif hasattr(value, "to_dict"): 105 | result[attr] = value.to_dict() 106 | elif isinstance(value, dict): 107 | result[attr] = dict( 108 | map( 109 | lambda item: (item[0], item[1].to_dict()) 110 | if hasattr(item[1], "to_dict") 111 | else item, 112 | value.items(), 113 | ) 114 | ) 115 | else: 116 | result[attr] = value 117 | if issubclass(Interpretation, dict): 118 | for key, value in self.items(): 119 | result[key] = value 120 | 121 | return result 122 | 123 | def to_str(self): 124 | """Returns the string representation of the model""" 125 | return pprint.pformat(self.to_dict()) 126 | 127 | def __repr__(self): 128 | """For `print` and `pprint`""" 129 | return self.to_str() 130 | 131 | def __eq__(self, other): 132 | """Returns true if both objects are equal""" 133 | if not isinstance(other, Interpretation): 134 | return False 135 | 136 | return self.__dict__ == other.__dict__ 137 | 138 | def __ne__(self, other): 139 | """Returns true if both objects are not equal""" 140 | return not self == other 141 | -------------------------------------------------------------------------------- /leetcode/models/graphql_problemset_question_list.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlProblemsetQuestionList(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = {"total_num": "int", "questions": "list[GraphqlQuestionDetail]"} 34 | 35 | attribute_map = {"total_num": "totalNum", "questions": "questions"} 36 | 37 | def __init__(self, total_num=None, questions=None) -> None: # noqa: E501 38 | """GraphqlProblemsetQuestionList - a model defined in Swagger""" # noqa: E501 39 | self._total_num = None 40 | self._questions = None 41 | self.discriminator = None 42 | if total_num is not None: 43 | self.total_num = total_num 44 | if questions is not None: 45 | self.questions = questions 46 | 47 | @property 48 | def total_num(self): 49 | """Gets the total_num of this GraphqlProblemsetQuestionList. # noqa: E501 50 | 51 | 52 | :return: The total_num of this GraphqlProblemsetQuestionList. # noqa: E501 53 | :rtype: int 54 | """ 55 | return self._total_num 56 | 57 | @total_num.setter 58 | def total_num(self, total_num): 59 | """Sets the total_num of this GraphqlProblemsetQuestionList. 60 | 61 | 62 | :param total_num: The total_num of this GraphqlProblemsetQuestionList. # noqa: E501 63 | :type: int 64 | """ 65 | 66 | self._total_num = total_num 67 | 68 | @property 69 | def questions(self): 70 | """Gets the questions of this GraphqlProblemsetQuestionList. # noqa: E501 71 | 72 | 73 | :return: The questions of this GraphqlProblemsetQuestionList. # noqa: E501 74 | :rtype: list[GraphqlQuestionDetail] 75 | """ 76 | return self._questions 77 | 78 | @questions.setter 79 | def questions(self, questions): 80 | """Sets the questions of this GraphqlProblemsetQuestionList. 81 | 82 | 83 | :param questions: The questions of this GraphqlProblemsetQuestionList. # noqa: E501 84 | :type: list[GraphqlQuestionDetail] 85 | """ 86 | 87 | self._questions = questions 88 | 89 | def to_dict(self): 90 | """Returns the model properties as a dict""" 91 | result = {} 92 | 93 | for attr, _ in six.iteritems(self.swagger_types): 94 | value = getattr(self, attr) 95 | if isinstance(value, list): 96 | result[attr] = list( 97 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 98 | ) 99 | elif hasattr(value, "to_dict"): 100 | result[attr] = value.to_dict() 101 | elif isinstance(value, dict): 102 | result[attr] = dict( 103 | map( 104 | lambda item: (item[0], item[1].to_dict()) 105 | if hasattr(item[1], "to_dict") 106 | else item, 107 | value.items(), 108 | ) 109 | ) 110 | else: 111 | result[attr] = value 112 | if issubclass(GraphqlProblemsetQuestionList, dict): 113 | for key, value in self.items(): 114 | result[key] = value 115 | 116 | return result 117 | 118 | def to_str(self) -> str: 119 | """Returns the string representation of the model""" 120 | return pprint.pformat(self.to_dict()) 121 | 122 | def __repr__(self) -> str: 123 | """For `print` and `pprint`""" 124 | return self.to_str() 125 | 126 | def __eq__(self, other: GraphqlProblemsetQuestionList) -> bool: 127 | """Returns true if both objects are equal""" 128 | if not isinstance(other, GraphqlProblemsetQuestionList): 129 | return False 130 | 131 | return self.__dict__ == other.__dict__ 132 | 133 | def __ne__(self, other) -> bool: 134 | """Returns true if both objects are not equal""" 135 | return not self == other 136 | -------------------------------------------------------------------------------- /leetcode/models/graphql_user.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlUser(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = {"username": "str", "is_current_user_premium": "bool"} 34 | 35 | attribute_map = { 36 | "username": "username", 37 | "is_current_user_premium": "isCurrentUserPremium", 38 | } 39 | 40 | def __init__( 41 | self, username=None, is_current_user_premium=None 42 | ) -> None: # noqa: E501 43 | """GraphqlUser - a model defined in Swagger""" # noqa: E501 44 | self._username = None 45 | self._is_current_user_premium = None 46 | self.discriminator = None 47 | if username is not None: 48 | self.username = username 49 | if is_current_user_premium is not None: 50 | self.is_current_user_premium = is_current_user_premium 51 | 52 | @property 53 | def username(self): 54 | """Gets the username of this GraphqlUser. # noqa: E501 55 | 56 | 57 | :return: The username of this GraphqlUser. # noqa: E501 58 | :rtype: str 59 | """ 60 | return self._username 61 | 62 | @username.setter 63 | def username(self, username): 64 | """Sets the username of this GraphqlUser. 65 | 66 | 67 | :param username: The username of this GraphqlUser. # noqa: E501 68 | :type: str 69 | """ 70 | 71 | self._username = username 72 | 73 | @property 74 | def is_current_user_premium(self): 75 | """Gets the is_current_user_premium of this GraphqlUser. # noqa: E501 76 | 77 | 78 | :return: The is_current_user_premium of this GraphqlUser. # noqa: E501 79 | :rtype: bool 80 | """ 81 | return self._is_current_user_premium 82 | 83 | @is_current_user_premium.setter 84 | def is_current_user_premium(self, is_current_user_premium): 85 | """Sets the is_current_user_premium of this GraphqlUser. 86 | 87 | 88 | :param is_current_user_premium: The is_current_user_premium of this GraphqlUser. # noqa: E501 89 | :type: bool 90 | """ 91 | 92 | self._is_current_user_premium = is_current_user_premium 93 | 94 | def to_dict(self): 95 | """Returns the model properties as a dict""" 96 | result = {} 97 | 98 | for attr, _ in six.iteritems(self.swagger_types): 99 | value = getattr(self, attr) 100 | if isinstance(value, list): 101 | result[attr] = list( 102 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 103 | ) 104 | elif hasattr(value, "to_dict"): 105 | result[attr] = value.to_dict() 106 | elif isinstance(value, dict): 107 | result[attr] = dict( 108 | map( 109 | lambda item: (item[0], item[1].to_dict()) 110 | if hasattr(item[1], "to_dict") 111 | else item, 112 | value.items(), 113 | ) 114 | ) 115 | else: 116 | result[attr] = value 117 | if issubclass(GraphqlUser, dict): 118 | for key, value in self.items(): 119 | result[key] = value 120 | 121 | return result 122 | 123 | def to_str(self) -> str: 124 | """Returns the string representation of the model""" 125 | return pprint.pformat(self.to_dict()) 126 | 127 | def __repr__(self) -> str: 128 | """For `print` and `pprint`""" 129 | return self.to_str() 130 | 131 | def __eq__(self, other: GraphqlUser) -> bool: 132 | """Returns true if both objects are equal""" 133 | if not isinstance(other, GraphqlUser): 134 | return False 135 | 136 | return self.__dict__ == other.__dict__ 137 | 138 | def __ne__(self, other) -> bool: 139 | """Returns true if both objects are not equal""" 140 | return not self == other 141 | -------------------------------------------------------------------------------- /test/test_default_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | from time import sleep 16 | import unittest 17 | from leetcode.models.interpretation import Interpretation 18 | from leetcode.models.submission_id import SubmissionId 19 | import test.base 20 | 21 | import leetcode 22 | from leetcode.api.default_api import DefaultApi # noqa: E501 23 | from leetcode.rest import ApiException 24 | 25 | 26 | class TestDefaultApi(test.base.BaseTest): 27 | def test_api_problems_topic_get(self): 28 | result = self._api_instance.api_problems_topic_get(topic="algorithms") 29 | test.base.validate_problems(result, "algorithms") 30 | 31 | result = self._api_instance.api_problems_topic_get(topic="nonexistent") 32 | test.base.validate_problems(result, "nonexistent") 33 | 34 | try: 35 | self._api_instance.api_problems_topic_get(topic="") 36 | assert False 37 | except ApiException as e: 38 | assert e.status == 404 39 | 40 | def test_graphql_post(self): 41 | pass 42 | 43 | def test_problems_problem_interpret_solution_post(self): 44 | code = """ 45 | class Solution: 46 | def twoSum(self, nums, target): 47 | print("stdout") 48 | return [1] 49 | """ 50 | test_submission = leetcode.TestSubmission( 51 | data_input="[2,7,11,15]\n9", 52 | typed_code=code, 53 | question_id=1, 54 | test_mode=False, 55 | lang="python", 56 | ) 57 | 58 | result = self._api_instance.problems_problem_interpret_solution_post( 59 | problem="two-sum", 60 | body=test_submission, 61 | ) 62 | 63 | assert isinstance(result, Interpretation) 64 | 65 | 66 | def test_problems_problem_submit_post(self): 67 | code = """ 68 | class Solution: 69 | def twoSum(self, nums, target): 70 | print("stdout") 71 | return [1] 72 | """ 73 | 74 | submission = leetcode.Submission( 75 | judge_type="large", 76 | typed_code=code, 77 | question_id=1, 78 | test_mode=False, 79 | lang="python", 80 | ) 81 | submission_id = self._api_instance.problems_problem_submit_post( 82 | problem="two-sum", body=submission 83 | ) 84 | assert isinstance(submission_id, SubmissionId) 85 | 86 | 87 | sleep(5) # FIXME: should probably be a busy-waiting loop 88 | 89 | submission_result = self._api_instance.submissions_detail_id_check_get( 90 | id=submission_id.submission_id 91 | ) 92 | # assert isinstance( 93 | # submission_result, 94 | # leetcode.SubmissionResult, 95 | # ) or isinstance( 96 | # submission_result, 97 | # leetcode.TestSubmissionResult, 98 | # ) 99 | 100 | # if isinstance(submission_result, leetcode.SubmissionResult): 101 | # assert isinstance(submission_result.compare_result, str) 102 | # assert isinstance(submission_result.std_output, str) 103 | # assert isinstance(submission_result.last_testcase, str) 104 | # assert isinstance(submission_result.expected_output, str) 105 | # assert isinstance(submission_result.input_formatted, str) 106 | # assert isinstance(submission_result.input, str) 107 | # # Missing or incorrect fields 108 | # # task_name: str 109 | # # finished: bool 110 | # elif isinstance(submission_result, leetcode.TestSubmissionResult): 111 | # assert isinstance(submission_result.code_answer, list) 112 | # assert isinstance(submission_result.correct_answer, bool) 113 | # assert isinstance(submission_result.expected_status_code, int) 114 | # assert isinstance(submission_result.expected_lang, str) 115 | # assert isinstance(submission_result.expected_run_success, bool) 116 | # assert isinstance(submission_result.expected_status_runtime, str) 117 | # assert isinstance(submission_result.expected_memory, int) 118 | # assert isinstance(submission_result.expected_code_answer, list) 119 | # assert isinstance(submission_result.expected_code_output, list) 120 | # assert isinstance(submission_result.expected_elapsed_time, int) 121 | # assert isinstance(submission_result.expected_task_finish_time, int) 122 | 123 | # def test_submissions_detail_id_check_get(self): 124 | # try: 125 | # self._api_instance.submissions_detail_id_check_get(id="nonexistent") 126 | # assert False 127 | # except ApiException as e: 128 | # assert e.status == 404 129 | 130 | 131 | if __name__ == "__main__": 132 | unittest.main() 133 | -------------------------------------------------------------------------------- /leetcode/models/graphql_query.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class GraphqlQuery(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = { 33 | "query": "str", 34 | "variables": "AnyOfGraphqlQueryVariables", 35 | "operation_name": "str", 36 | } 37 | 38 | attribute_map = { 39 | "query": "query", 40 | "variables": "variables", 41 | "operation_name": "operationName", 42 | } 43 | 44 | def __init__(self, query=None, variables=None, operation_name=None): # noqa: E501 45 | """GraphqlQuery - a model defined in Swagger""" # noqa: E501 46 | self._query = None 47 | self._variables = None 48 | self._operation_name = None 49 | self.discriminator = None 50 | self.query = query 51 | self.variables = variables 52 | if operation_name is not None: 53 | self.operation_name = operation_name 54 | 55 | @property 56 | def query(self): 57 | """Gets the query of this GraphqlQuery. # noqa: E501 58 | 59 | 60 | :return: The query of this GraphqlQuery. # noqa: E501 61 | :rtype: str 62 | """ 63 | return self._query 64 | 65 | @query.setter 66 | def query(self, query): 67 | """Sets the query of this GraphqlQuery. 68 | 69 | 70 | :param query: The query of this GraphqlQuery. # noqa: E501 71 | :type: str 72 | """ 73 | if query is None: 74 | raise ValueError( 75 | "Invalid value for `query`, must not be `None`" 76 | ) # noqa: E501 77 | 78 | self._query = query 79 | 80 | @property 81 | def variables(self): 82 | """Gets the variables of this GraphqlQuery. # noqa: E501 83 | 84 | 85 | :return: The variables of this GraphqlQuery. # noqa: E501 86 | :rtype: AnyOfGraphqlQueryVariables 87 | """ 88 | return self._variables 89 | 90 | @variables.setter 91 | def variables(self, variables): 92 | """Sets the variables of this GraphqlQuery. 93 | 94 | 95 | :param variables: The variables of this GraphqlQuery. # noqa: E501 96 | :type: AnyOfGraphqlQueryVariables 97 | """ 98 | if variables is None: 99 | raise ValueError( 100 | "Invalid value for `variables`, must not be `None`" 101 | ) # noqa: E501 102 | 103 | self._variables = variables 104 | 105 | @property 106 | def operation_name(self): 107 | """Gets the operation_name of this GraphqlQuery. # noqa: E501 108 | 109 | 110 | :return: The operation_name of this GraphqlQuery. # noqa: E501 111 | :rtype: str 112 | """ 113 | return self._operation_name 114 | 115 | @operation_name.setter 116 | def operation_name(self, operation_name): 117 | """Sets the operation_name of this GraphqlQuery. 118 | 119 | 120 | :param operation_name: The operation_name of this GraphqlQuery. # noqa: E501 121 | :type: str 122 | """ 123 | 124 | self._operation_name = operation_name 125 | 126 | def to_dict(self): 127 | """Returns the model properties as a dict""" 128 | result = {} 129 | 130 | for attr, _ in six.iteritems(self.swagger_types): 131 | value = getattr(self, attr) 132 | if isinstance(value, list): 133 | result[attr] = list( 134 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 135 | ) 136 | elif hasattr(value, "to_dict"): 137 | result[attr] = value.to_dict() 138 | elif isinstance(value, dict): 139 | result[attr] = dict( 140 | map( 141 | lambda item: (item[0], item[1].to_dict()) 142 | if hasattr(item[1], "to_dict") 143 | else item, 144 | value.items(), 145 | ) 146 | ) 147 | else: 148 | result[attr] = value 149 | if issubclass(GraphqlQuery, dict): 150 | for key, value in self.items(): 151 | result[key] = value 152 | 153 | return result 154 | 155 | def to_str(self): 156 | """Returns the string representation of the model""" 157 | return pprint.pformat(self.to_dict()) 158 | 159 | def __repr__(self): 160 | """For `print` and `pprint`""" 161 | return self.to_str() 162 | 163 | def __eq__(self, other): 164 | """Returns true if both objects are equal""" 165 | if not isinstance(other, GraphqlQuery): 166 | return False 167 | 168 | return self.__dict__ == other.__dict__ 169 | 170 | def __ne__(self, other): 171 | """Returns true if both objects are not equal""" 172 | return not self == other 173 | -------------------------------------------------------------------------------- /leetcode/models/graphql_data.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlData(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = { 34 | "question": "GraphqlQuestionDetail", 35 | "user": "GraphqlUser", 36 | "problemset_question_list": "GraphqlProblemsetQuestionList", 37 | } 38 | 39 | attribute_map = { 40 | "question": "question", 41 | "user": "user", 42 | "problemset_question_list": "problemsetQuestionList", 43 | } 44 | 45 | def __init__( 46 | self, question=None, user=None, problemset_question_list=None 47 | ) -> None: # noqa: E501 48 | """GraphqlData - a model defined in Swagger""" # noqa: E501 49 | self._question = None 50 | self._user = None 51 | self._problemset_question_list = None 52 | self.discriminator = None 53 | if question is not None: 54 | self.question = question 55 | if user is not None: 56 | self.user = user 57 | if problemset_question_list is not None: 58 | self.problemset_question_list = problemset_question_list 59 | 60 | @property 61 | def question(self): 62 | """Gets the question of this GraphqlData. # noqa: E501 63 | 64 | 65 | :return: The question of this GraphqlData. # noqa: E501 66 | :rtype: GraphqlQuestionDetail 67 | """ 68 | return self._question 69 | 70 | @question.setter 71 | def question(self, question): 72 | """Sets the question of this GraphqlData. 73 | 74 | 75 | :param question: The question of this GraphqlData. # noqa: E501 76 | :type: GraphqlQuestionDetail 77 | """ 78 | 79 | self._question = question 80 | 81 | @property 82 | def user(self): 83 | """Gets the user of this GraphqlData. # noqa: E501 84 | 85 | 86 | :return: The user of this GraphqlData. # noqa: E501 87 | :rtype: GraphqlUser 88 | """ 89 | return self._user 90 | 91 | @user.setter 92 | def user(self, user): 93 | """Sets the user of this GraphqlData. 94 | 95 | 96 | :param user: The user of this GraphqlData. # noqa: E501 97 | :type: GraphqlUser 98 | """ 99 | 100 | self._user = user 101 | 102 | @property 103 | def problemset_question_list(self): 104 | """Gets the problemset_question_list of this GraphqlData. # noqa: E501 105 | 106 | 107 | :return: The problemset_question_list of this GraphqlData. # noqa: E501 108 | :rtype: GraphqlProblemsetQuestionList 109 | """ 110 | return self._problemset_question_list 111 | 112 | @problemset_question_list.setter 113 | def problemset_question_list(self, problemset_question_list): 114 | """Sets the problemset_question_list of this GraphqlData. 115 | 116 | 117 | :param problemset_question_list: The problemset_question_list of this GraphqlData. # noqa: E501 118 | :type: GraphqlProblemsetQuestionList 119 | """ 120 | 121 | self._problemset_question_list = problemset_question_list 122 | 123 | def to_dict(self): 124 | """Returns the model properties as a dict""" 125 | result = {} 126 | 127 | for attr, _ in six.iteritems(self.swagger_types): 128 | value = getattr(self, attr) 129 | if isinstance(value, list): 130 | result[attr] = list( 131 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 132 | ) 133 | elif hasattr(value, "to_dict"): 134 | result[attr] = value.to_dict() 135 | elif isinstance(value, dict): 136 | result[attr] = dict( 137 | map( 138 | lambda item: (item[0], item[1].to_dict()) 139 | if hasattr(item[1], "to_dict") 140 | else item, 141 | value.items(), 142 | ) 143 | ) 144 | else: 145 | result[attr] = value 146 | if issubclass(GraphqlData, dict): 147 | for key, value in self.items(): 148 | result[key] = value 149 | 150 | return result 151 | 152 | def to_str(self) -> str: 153 | """Returns the string representation of the model""" 154 | return pprint.pformat(self.to_dict()) 155 | 156 | def __repr__(self) -> str: 157 | """For `print` and `pprint`""" 158 | return self.to_str() 159 | 160 | def __eq__(self, other: GraphqlData) -> bool: 161 | """Returns true if both objects are equal""" 162 | if not isinstance(other, GraphqlData): 163 | return False 164 | 165 | return self.__dict__ == other.__dict__ 166 | 167 | def __ne__(self, other) -> bool: 168 | """Returns true if both objects are not equal""" 169 | return not self == other 170 | -------------------------------------------------------------------------------- /leetcode/models/graphql_question_solution.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlQuestionSolution(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = {"id": "str", "can_see_detail": "bool", "typename": "str"} 34 | 35 | attribute_map = { 36 | "id": "id", 37 | "can_see_detail": "canSeeDetail", 38 | "typename": "__typename", 39 | } 40 | 41 | def __init__( 42 | self, id=None, can_see_detail=None, typename=None 43 | ) -> None: # noqa: E501 44 | """GraphqlQuestionSolution - a model defined in Swagger""" # noqa: E501 45 | self._id = None 46 | self._can_see_detail = None 47 | self._typename = None 48 | self.discriminator = None 49 | self.id = id 50 | self.can_see_detail = can_see_detail 51 | self.typename = typename 52 | 53 | @property 54 | def id(self): 55 | """Gets the id of this GraphqlQuestionSolution. # noqa: E501 56 | 57 | 58 | :return: The id of this GraphqlQuestionSolution. # noqa: E501 59 | :rtype: str 60 | """ 61 | return self._id 62 | 63 | @id.setter 64 | def id(self, id): 65 | """Sets the id of this GraphqlQuestionSolution. 66 | 67 | 68 | :param id: The id of this GraphqlQuestionSolution. # noqa: E501 69 | :type: str 70 | """ 71 | if id is None: 72 | raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 73 | 74 | self._id = id 75 | 76 | @property 77 | def can_see_detail(self): 78 | """Gets the can_see_detail of this GraphqlQuestionSolution. # noqa: E501 79 | 80 | 81 | :return: The can_see_detail of this GraphqlQuestionSolution. # noqa: E501 82 | :rtype: bool 83 | """ 84 | return self._can_see_detail 85 | 86 | @can_see_detail.setter 87 | def can_see_detail(self, can_see_detail): 88 | """Sets the can_see_detail of this GraphqlQuestionSolution. 89 | 90 | 91 | :param can_see_detail: The can_see_detail of this GraphqlQuestionSolution. # noqa: E501 92 | :type: bool 93 | """ 94 | if can_see_detail is None: 95 | raise ValueError( 96 | "Invalid value for `can_see_detail`, must not be `None`" 97 | ) # noqa: E501 98 | 99 | self._can_see_detail = can_see_detail 100 | 101 | @property 102 | def typename(self): 103 | """Gets the typename of this GraphqlQuestionSolution. # noqa: E501 104 | 105 | 106 | :return: The typename of this GraphqlQuestionSolution. # noqa: E501 107 | :rtype: str 108 | """ 109 | return self._typename 110 | 111 | @typename.setter 112 | def typename(self, typename): 113 | """Sets the typename of this GraphqlQuestionSolution. 114 | 115 | 116 | :param typename: The typename of this GraphqlQuestionSolution. # noqa: E501 117 | :type: str 118 | """ 119 | if typename is None: 120 | raise ValueError( 121 | "Invalid value for `typename`, must not be `None`" 122 | ) # noqa: E501 123 | 124 | self._typename = typename 125 | 126 | def to_dict(self): 127 | """Returns the model properties as a dict""" 128 | result = {} 129 | 130 | for attr, _ in six.iteritems(self.swagger_types): 131 | value = getattr(self, attr) 132 | if isinstance(value, list): 133 | result[attr] = list( 134 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 135 | ) 136 | elif hasattr(value, "to_dict"): 137 | result[attr] = value.to_dict() 138 | elif isinstance(value, dict): 139 | result[attr] = dict( 140 | map( 141 | lambda item: (item[0], item[1].to_dict()) 142 | if hasattr(item[1], "to_dict") 143 | else item, 144 | value.items(), 145 | ) 146 | ) 147 | else: 148 | result[attr] = value 149 | if issubclass(GraphqlQuestionSolution, dict): 150 | for key, value in self.items(): 151 | result[key] = value 152 | 153 | return result 154 | 155 | def to_str(self) -> str: 156 | """Returns the string representation of the model""" 157 | return pprint.pformat(self.to_dict()) 158 | 159 | def __repr__(self) -> str: 160 | """For `print` and `pprint`""" 161 | return self.to_str() 162 | 163 | def __eq__(self, other: GraphqlQuestionSolution) -> bool: 164 | """Returns true if both objects are equal""" 165 | if not isinstance(other, GraphqlQuestionSolution): 166 | return False 167 | 168 | return self.__dict__ == other.__dict__ 169 | 170 | def __ne__(self, other) -> bool: 171 | """Returns true if both objects are not equal""" 172 | return not self == other 173 | -------------------------------------------------------------------------------- /leetcode/models/graphql_question_topic_tag.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlQuestionTopicTag(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = { 34 | "name": "str", 35 | "slug": "str", 36 | "translated_name": "str", 37 | "typename": "str", 38 | } 39 | 40 | attribute_map = { 41 | "name": "name", 42 | "slug": "slug", 43 | "translated_name": "translatedName", 44 | "typename": "__typename", 45 | } 46 | 47 | def __init__( 48 | self, name=None, slug=None, translated_name=None, typename=None 49 | ) -> None: # noqa: E501 50 | """GraphqlQuestionTopicTag - a model defined in Swagger""" # noqa: E501 51 | self._name = None 52 | self._slug = None 53 | self._translated_name = None 54 | self._typename = None 55 | self.discriminator = None 56 | self.name = name 57 | self.slug = slug 58 | if translated_name is not None: 59 | self.translated_name = translated_name 60 | if typename is not None: 61 | self.typename = typename 62 | 63 | @property 64 | def name(self): 65 | """Gets the name of this GraphqlQuestionTopicTag. # noqa: E501 66 | 67 | 68 | :return: The name of this GraphqlQuestionTopicTag. # noqa: E501 69 | :rtype: str 70 | """ 71 | return self._name 72 | 73 | @name.setter 74 | def name(self, name): 75 | """Sets the name of this GraphqlQuestionTopicTag. 76 | 77 | 78 | :param name: The name of this GraphqlQuestionTopicTag. # noqa: E501 79 | :type: str 80 | """ 81 | if name is None: 82 | raise ValueError( 83 | "Invalid value for `name`, must not be `None`" 84 | ) # noqa: E501 85 | 86 | self._name = name 87 | 88 | @property 89 | def slug(self): 90 | """Gets the slug of this GraphqlQuestionTopicTag. # noqa: E501 91 | 92 | 93 | :return: The slug of this GraphqlQuestionTopicTag. # noqa: E501 94 | :rtype: str 95 | """ 96 | return self._slug 97 | 98 | @slug.setter 99 | def slug(self, slug): 100 | """Sets the slug of this GraphqlQuestionTopicTag. 101 | 102 | 103 | :param slug: The slug of this GraphqlQuestionTopicTag. # noqa: E501 104 | :type: str 105 | """ 106 | if slug is None: 107 | raise ValueError( 108 | "Invalid value for `slug`, must not be `None`" 109 | ) # noqa: E501 110 | 111 | self._slug = slug 112 | 113 | @property 114 | def translated_name(self): 115 | """Gets the translated_name of this GraphqlQuestionTopicTag. # noqa: E501 116 | 117 | 118 | :return: The translated_name of this GraphqlQuestionTopicTag. # noqa: E501 119 | :rtype: str 120 | """ 121 | return self._translated_name 122 | 123 | @translated_name.setter 124 | def translated_name(self, translated_name): 125 | """Sets the translated_name of this GraphqlQuestionTopicTag. 126 | 127 | 128 | :param translated_name: The translated_name of this GraphqlQuestionTopicTag. # noqa: E501 129 | :type: str 130 | """ 131 | 132 | self._translated_name = translated_name 133 | 134 | @property 135 | def typename(self): 136 | """Gets the typename of this GraphqlQuestionTopicTag. # noqa: E501 137 | 138 | 139 | :return: The typename of this GraphqlQuestionTopicTag. # noqa: E501 140 | :rtype: str 141 | """ 142 | return self._typename 143 | 144 | @typename.setter 145 | def typename(self, typename): 146 | """Sets the typename of this GraphqlQuestionTopicTag. 147 | 148 | 149 | :param typename: The typename of this GraphqlQuestionTopicTag. # noqa: E501 150 | :type: str 151 | """ 152 | 153 | self._typename = typename 154 | 155 | def to_dict(self): 156 | """Returns the model properties as a dict""" 157 | result = {} 158 | 159 | for attr, _ in six.iteritems(self.swagger_types): 160 | value = getattr(self, attr) 161 | if isinstance(value, list): 162 | result[attr] = list( 163 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 164 | ) 165 | elif hasattr(value, "to_dict"): 166 | result[attr] = value.to_dict() 167 | elif isinstance(value, dict): 168 | result[attr] = dict( 169 | map( 170 | lambda item: (item[0], item[1].to_dict()) 171 | if hasattr(item[1], "to_dict") 172 | else item, 173 | value.items(), 174 | ) 175 | ) 176 | else: 177 | result[attr] = value 178 | if issubclass(GraphqlQuestionTopicTag, dict): 179 | for key, value in self.items(): 180 | result[key] = value 181 | 182 | return result 183 | 184 | def to_str(self) -> str: 185 | """Returns the string representation of the model""" 186 | return pprint.pformat(self.to_dict()) 187 | 188 | def __repr__(self) -> str: 189 | """For `print` and `pprint`""" 190 | return self.to_str() 191 | 192 | def __eq__(self, other: GraphqlQuestionTopicTag) -> bool: 193 | """Returns true if both objects are equal""" 194 | if not isinstance(other, GraphqlQuestionTopicTag): 195 | return False 196 | 197 | return self.__dict__ == other.__dict__ 198 | 199 | def __ne__(self, other) -> bool: 200 | """Returns true if both objects are not equal""" 201 | return not self == other 202 | -------------------------------------------------------------------------------- /leetcode/models/graphql_question_code_snippet.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlQuestionCodeSnippet(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = { 34 | "lang": "str", 35 | "lang_slug": "str", 36 | "code": "str", 37 | "typename": "str", 38 | } 39 | 40 | attribute_map = { 41 | "lang": "lang", 42 | "lang_slug": "langSlug", 43 | "code": "code", 44 | "typename": "__typename", 45 | } 46 | 47 | def __init__( 48 | self, lang=None, lang_slug=None, code=None, typename=None 49 | ) -> None: # noqa: E501 50 | """GraphqlQuestionCodeSnippet - a model defined in Swagger""" # noqa: E501 51 | self._lang = None 52 | self._lang_slug = None 53 | self._code = None 54 | self._typename = None 55 | self.discriminator = None 56 | self.lang = lang 57 | self.lang_slug = lang_slug 58 | self.code = code 59 | if typename is not None: 60 | self.typename = typename 61 | 62 | @property 63 | def lang(self): 64 | """Gets the lang of this GraphqlQuestionCodeSnippet. # noqa: E501 65 | 66 | 67 | :return: The lang of this GraphqlQuestionCodeSnippet. # noqa: E501 68 | :rtype: str 69 | """ 70 | return self._lang 71 | 72 | @lang.setter 73 | def lang(self, lang): 74 | """Sets the lang of this GraphqlQuestionCodeSnippet. 75 | 76 | 77 | :param lang: The lang of this GraphqlQuestionCodeSnippet. # noqa: E501 78 | :type: str 79 | """ 80 | if lang is None: 81 | raise ValueError( 82 | "Invalid value for `lang`, must not be `None`" 83 | ) # noqa: E501 84 | 85 | self._lang = lang 86 | 87 | @property 88 | def lang_slug(self): 89 | """Gets the lang_slug of this GraphqlQuestionCodeSnippet. # noqa: E501 90 | 91 | 92 | :return: The lang_slug of this GraphqlQuestionCodeSnippet. # noqa: E501 93 | :rtype: str 94 | """ 95 | return self._lang_slug 96 | 97 | @lang_slug.setter 98 | def lang_slug(self, lang_slug): 99 | """Sets the lang_slug of this GraphqlQuestionCodeSnippet. 100 | 101 | 102 | :param lang_slug: The lang_slug of this GraphqlQuestionCodeSnippet. # noqa: E501 103 | :type: str 104 | """ 105 | if lang_slug is None: 106 | raise ValueError( 107 | "Invalid value for `lang_slug`, must not be `None`" 108 | ) # noqa: E501 109 | 110 | self._lang_slug = lang_slug 111 | 112 | @property 113 | def code(self): 114 | """Gets the code of this GraphqlQuestionCodeSnippet. # noqa: E501 115 | 116 | 117 | :return: The code of this GraphqlQuestionCodeSnippet. # noqa: E501 118 | :rtype: str 119 | """ 120 | return self._code 121 | 122 | @code.setter 123 | def code(self, code): 124 | """Sets the code of this GraphqlQuestionCodeSnippet. 125 | 126 | 127 | :param code: The code of this GraphqlQuestionCodeSnippet. # noqa: E501 128 | :type: str 129 | """ 130 | if code is None: 131 | raise ValueError( 132 | "Invalid value for `code`, must not be `None`" 133 | ) # noqa: E501 134 | 135 | self._code = code 136 | 137 | @property 138 | def typename(self): 139 | """Gets the typename of this GraphqlQuestionCodeSnippet. # noqa: E501 140 | 141 | 142 | :return: The typename of this GraphqlQuestionCodeSnippet. # noqa: E501 143 | :rtype: str 144 | """ 145 | return self._typename 146 | 147 | @typename.setter 148 | def typename(self, typename): 149 | """Sets the typename of this GraphqlQuestionCodeSnippet. 150 | 151 | 152 | :param typename: The typename of this GraphqlQuestionCodeSnippet. # noqa: E501 153 | :type: str 154 | """ 155 | 156 | self._typename = typename 157 | 158 | def to_dict(self): 159 | """Returns the model properties as a dict""" 160 | result = {} 161 | 162 | for attr, _ in six.iteritems(self.swagger_types): 163 | value = getattr(self, attr) 164 | if isinstance(value, list): 165 | result[attr] = list( 166 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 167 | ) 168 | elif hasattr(value, "to_dict"): 169 | result[attr] = value.to_dict() 170 | elif isinstance(value, dict): 171 | result[attr] = dict( 172 | map( 173 | lambda item: (item[0], item[1].to_dict()) 174 | if hasattr(item[1], "to_dict") 175 | else item, 176 | value.items(), 177 | ) 178 | ) 179 | else: 180 | result[attr] = value 181 | if issubclass(GraphqlQuestionCodeSnippet, dict): 182 | for key, value in self.items(): 183 | result[key] = value 184 | 185 | return result 186 | 187 | def to_str(self) -> str: 188 | """Returns the string representation of the model""" 189 | return pprint.pformat(self.to_dict()) 190 | 191 | def __repr__(self) -> str: 192 | """For `print` and `pprint`""" 193 | return self.to_str() 194 | 195 | def __eq__(self, other: GraphqlQuestionCodeSnippet) -> bool: 196 | """Returns true if both objects are equal""" 197 | if not isinstance(other, GraphqlQuestionCodeSnippet): 198 | return False 199 | 200 | return self.__dict__ == other.__dict__ 201 | 202 | def __ne__(self, other) -> bool: 203 | """Returns true if both objects are not equal""" 204 | return not self == other 205 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![build](https://github.com/fspv/python-leetcode/actions/workflows/publish-to-pypi.yml/badge.svg) 2 | ![tests](https://github.com/fspv/python-leetcode/actions/workflows/pytest.yml/badge.svg) 3 | ![pypi](https://badge.fury.io/py/python-leetcode.svg) 4 | ![pypi-downloads](https://img.shields.io/pypi/dm/python-leetcode) 5 | ![python-versions](https://img.shields.io/pypi/pyversions/python-leetcode) 6 | ![license](https://img.shields.io/pypi/l/python-leetcode) 7 | 8 | # Leetcode API implementation 9 | 10 | This repo contains a python client to access all known so far methods of Leetcode API. 11 | 12 | The code is autogenerated by swagger. Swagger reference can be found here: [https://github.com/fspv/leetcode-swagger](https://github.com/fspv/leetcode-swagger) 13 | 14 | PyPi package link: [https://pypi.org/project/python-leetcode/](https://pypi.org/project/python-leetcode/) 15 | 16 | ## Minimal working example 17 | 18 | First set up a virtualenv 19 | ```bash 20 | virtualenv -p python3 leetcode 21 | . leetcode/bin/activate 22 | pip3 install python-leetcode 23 | ``` 24 | 25 | Then in python shell initialize necessary environment variables. You can get it directly from your browser cookies (csrftoken and LEETCODE_SESSION) 26 | ```python 27 | import leetcode 28 | 29 | # Get the next two values from your browser cookies 30 | leetcode_session = "yyy" 31 | csrf_token = "xxx" 32 | 33 | configuration = leetcode.Configuration() 34 | 35 | configuration.api_key["x-csrftoken"] = csrf_token 36 | configuration.api_key["csrftoken"] = csrf_token 37 | configuration.api_key["LEETCODE_SESSION"] = leetcode_session 38 | configuration.api_key["Referer"] = "https://leetcode.com" 39 | configuration.debug = False 40 | 41 | api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration)) 42 | ``` 43 | 44 | Now once the client is initilized, you can start performing actual queries 45 | 46 | ```python 47 | graphql_request = leetcode.GraphqlQuery( 48 | query=""" 49 | { 50 | user { 51 | username 52 | isCurrentUserPremium 53 | } 54 | } 55 | """, 56 | variables=leetcode.GraphqlQueryVariables(), 57 | ) 58 | 59 | print(api_instance.graphql_post(body=graphql_request)) 60 | ``` 61 | 62 | You should get something like that in the response 63 | ```python 64 | {'data': {'question': None, 65 | 'user': {'is_current_user_premium': True, 'username': 'omgitspavel'}}} 66 | ``` 67 | 68 | This confirms you've set up auth correctly. 69 | 70 | ## Advanced example 71 | 72 | Now let's try to do something more complicated. For example calculate the percentage of the problems we've solved by topic. 73 | 74 | For that we have to acquire the list of all the problems we solved. 75 | 76 | ```python 77 | api_response = api_instance.api_problems_topic_get(topic="algorithms") 78 | 79 | slug_to_solved_status = { 80 | pair.stat.question__title_slug: True if pair.status == "ac" else False 81 | for pair in api_response.stat_status_pairs 82 | } 83 | ``` 84 | 85 | Now for each problem we want to get its tags 86 | 87 | ```python 88 | import time 89 | 90 | from collections import Counter 91 | 92 | 93 | topic_to_accepted = Counter() 94 | topic_to_total = Counter() 95 | 96 | 97 | # Take only the first 10 for test purposes 98 | for slug in list(slug_to_solved_status.keys())[:10]: 99 | time.sleep(1) # Leetcode has a rate limiter 100 | 101 | graphql_request = leetcode.GraphqlQuery( 102 | query=""" 103 | query getQuestionDetail($titleSlug: String!) { 104 | question(titleSlug: $titleSlug) { 105 | topicTags { 106 | name 107 | slug 108 | } 109 | } 110 | } 111 | """, 112 | variables=leetcode.GraphqlQueryVariables(title_slug=slug), 113 | operation_name="getQuestionDetail", 114 | ) 115 | 116 | api_response = api_instance.graphql_post(body=graphql_request) 117 | 118 | for topic in (tag.slug for tag in api_response.data.question.topic_tags): 119 | topic_to_accepted[topic] += int(slug_to_solved_status[slug]) 120 | topic_to_total[topic] += 1 121 | 122 | print( 123 | list( 124 | sorted( 125 | ((topic, accepted / topic_to_total[topic]) for topic, accepted in topic_to_accepted.items()), 126 | key=lambda x: x[1] 127 | ) 128 | ) 129 | ) 130 | ``` 131 | 132 | The output will look like this: 133 | 134 | ```python 135 | [('memoization', 0.0), 136 | ('number-theory', 0.0), 137 | ('binary-search-tree', 0.0), 138 | ('quickselect', 0.0), 139 | ('recursion', 0.0), 140 | ('suffix-array', 0.0), 141 | ('topological-sort', 0.0), 142 | ('shortest-path', 0.0), 143 | ('trie', 0.0), 144 | ('geometry', 0.0), 145 | ('brainteaser', 0.0), 146 | ('combinatorics', 0.0), 147 | ('line-sweep', 0.0), 148 | 149 | ... 150 | 151 | ('union-find', 0.3076923076923077), 152 | ('linked-list', 0.3333333333333333), 153 | ('string-matching', 0.3333333333333333), 154 | ('segment-tree', 0.4), 155 | ('data-stream', 0.5), 156 | ('strongly-connected-component', 0.5), 157 | ('minimum-spanning-tree', 0.6666666666666666), 158 | ('merge-sort', 1.0), 159 | ('doubly-linked-list', 1.0)] 160 | ``` 161 | 162 | So it is clearly visible which topics we should focus on in our preparation. 163 | In this case memoization topic is one of the targets for improvement, so I can go to https://leetcode.com/tag/memoization/ and choose a new memoization problem. Or use python to automate the process. 164 | 165 | ## Example services using this library 166 | 167 | * Anki cards generator [https://github.com/fspv/leetcode-anki](https://github.com/fspv/leetcode-anki) 168 | * Leetcode helper website [https://github.com/fspv/grind-helper](https://github.com/fspv/grind-helper) 169 | 170 | ## Additional info 171 | You can find other examples of usage in `example.py` 172 | 173 | Autogenerated by swagger documentation can be found [here](/README.generated.md). 174 | 175 | ## Development 176 | 177 | Build package locally and upload to test pypi 178 | ```sh 179 | virtualenv .venv 180 | . .venv/bin/activate 181 | pip install setuptools twine wheel 182 | rm -rf build/ dist/ *.egg-info/ *.egg 183 | python setup.py sdist bdist_wheel 184 | twine upload --repository-url https://test.pypi.org/legacy/ dist/*.whl 185 | ``` 186 | 187 | To run tests set up env variables and run this 188 | 189 | ```sh 190 | docker build --env LEETCODE_SESSION_ID=$LEETCODE_SESSION_ID --env LEETCODE_CSRF_TOKEN=$LEETCODE_CSRF_TOKEN . 191 | ``` 192 | 193 | Test new created package before publishing 194 | ```sh 195 | pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ python-leetcode==1.2.5 196 | ``` 197 | 198 | Publish package 199 | ```sh 200 | git tag 1.2.4 201 | git push --tags 202 | ``` 203 | -------------------------------------------------------------------------------- /leetcode/models/graphql_query_problemset_question_list_variables.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlQueryProblemsetQuestionListVariables(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = { 34 | "category_slug": "str", 35 | "limit": "int", 36 | "skip": "int", 37 | "filters": "GraphqlQueryProblemsetQuestionListVariablesFilterInput", 38 | } 39 | 40 | attribute_map = { 41 | "category_slug": "categorySlug", 42 | "limit": "limit", 43 | "skip": "skip", 44 | "filters": "filters", 45 | } 46 | 47 | def __init__( 48 | self, category_slug=None, limit=None, skip=None, filters=None 49 | ) -> None: # noqa: E501 50 | """GraphqlQueryProblemsetQuestionListVariables - a model defined in Swagger""" # noqa: E501 51 | self._category_slug = None 52 | self._limit = None 53 | self._skip = None 54 | self._filters = None 55 | self.discriminator = None 56 | if category_slug is not None: 57 | self.category_slug = category_slug 58 | if limit is not None: 59 | self.limit = limit 60 | if skip is not None: 61 | self.skip = skip 62 | if filters is not None: 63 | self.filters = filters 64 | 65 | @property 66 | def category_slug(self): 67 | """Gets the category_slug of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 68 | 69 | 70 | :return: The category_slug of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 71 | :rtype: str 72 | """ 73 | return self._category_slug 74 | 75 | @category_slug.setter 76 | def category_slug(self, category_slug): 77 | """Sets the category_slug of this GraphqlQueryProblemsetQuestionListVariables. 78 | 79 | 80 | :param category_slug: The category_slug of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 81 | :type: str 82 | """ 83 | 84 | self._category_slug = category_slug 85 | 86 | @property 87 | def limit(self): 88 | """Gets the limit of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 89 | 90 | 91 | :return: The limit of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 92 | :rtype: int 93 | """ 94 | return self._limit 95 | 96 | @limit.setter 97 | def limit(self, limit): 98 | """Sets the limit of this GraphqlQueryProblemsetQuestionListVariables. 99 | 100 | 101 | :param limit: The limit of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 102 | :type: int 103 | """ 104 | 105 | self._limit = limit 106 | 107 | @property 108 | def skip(self): 109 | """Gets the skip of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 110 | 111 | 112 | :return: The skip of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 113 | :rtype: int 114 | """ 115 | return self._skip 116 | 117 | @skip.setter 118 | def skip(self, skip): 119 | """Sets the skip of this GraphqlQueryProblemsetQuestionListVariables. 120 | 121 | 122 | :param skip: The skip of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 123 | :type: int 124 | """ 125 | 126 | self._skip = skip 127 | 128 | @property 129 | def filters(self): 130 | """Gets the filters of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 131 | 132 | 133 | :return: The filters of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 134 | :rtype: GraphqlQueryProblemsetQuestionListVariablesFilterInput 135 | """ 136 | return self._filters 137 | 138 | @filters.setter 139 | def filters(self, filters): 140 | """Sets the filters of this GraphqlQueryProblemsetQuestionListVariables. 141 | 142 | 143 | :param filters: The filters of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 144 | :type: GraphqlQueryProblemsetQuestionListVariablesFilterInput 145 | """ 146 | 147 | self._filters = filters 148 | 149 | def to_dict(self): 150 | """Returns the model properties as a dict""" 151 | result = {} 152 | 153 | for attr, _ in six.iteritems(self.swagger_types): 154 | value = getattr(self, attr) 155 | if isinstance(value, list): 156 | result[attr] = list( 157 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 158 | ) 159 | elif hasattr(value, "to_dict"): 160 | result[attr] = value.to_dict() 161 | elif isinstance(value, dict): 162 | result[attr] = dict( 163 | map( 164 | lambda item: (item[0], item[1].to_dict()) 165 | if hasattr(item[1], "to_dict") 166 | else item, 167 | value.items(), 168 | ) 169 | ) 170 | else: 171 | result[attr] = value 172 | if issubclass(GraphqlQueryProblemsetQuestionListVariables, dict): 173 | for key, value in self.items(): 174 | result[key] = value 175 | 176 | return result 177 | 178 | def to_str(self) -> str: 179 | """Returns the string representation of the model""" 180 | return pprint.pformat(self.to_dict()) 181 | 182 | def __repr__(self) -> str: 183 | """For `print` and `pprint`""" 184 | return self.to_str() 185 | 186 | def __eq__(self, other: GraphqlQueryProblemsetQuestionListVariables) -> bool: 187 | """Returns true if both objects are equal""" 188 | if not isinstance(other, GraphqlQueryProblemsetQuestionListVariables): 189 | return False 190 | 191 | return self.__dict__ == other.__dict__ 192 | 193 | def __ne__(self, other) -> bool: 194 | """Returns true if both objects are not equal""" 195 | return not self == other 196 | -------------------------------------------------------------------------------- /leetcode/models/graphql_question_contributor.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlQuestionContributor(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = { 34 | "username": "str", 35 | "profile_url": "str", 36 | "avatar_url": "str", 37 | "typename": "str", 38 | } 39 | 40 | attribute_map = { 41 | "username": "username", 42 | "profile_url": "profileUrl", 43 | "avatar_url": "avatarUrl", 44 | "typename": "__typename", 45 | } 46 | 47 | def __init__( 48 | self, username=None, profile_url=None, avatar_url=None, typename=None 49 | ) -> None: # noqa: E501 50 | """GraphqlQuestionContributor - a model defined in Swagger""" # noqa: E501 51 | self._username = None 52 | self._profile_url = None 53 | self._avatar_url = None 54 | self._typename = None 55 | self.discriminator = None 56 | self.username = username 57 | self.profile_url = profile_url 58 | self.avatar_url = avatar_url 59 | if typename is not None: 60 | self.typename = typename 61 | 62 | @property 63 | def username(self): 64 | """Gets the username of this GraphqlQuestionContributor. # noqa: E501 65 | 66 | 67 | :return: The username of this GraphqlQuestionContributor. # noqa: E501 68 | :rtype: str 69 | """ 70 | return self._username 71 | 72 | @username.setter 73 | def username(self, username): 74 | """Sets the username of this GraphqlQuestionContributor. 75 | 76 | 77 | :param username: The username of this GraphqlQuestionContributor. # noqa: E501 78 | :type: str 79 | """ 80 | if username is None: 81 | raise ValueError( 82 | "Invalid value for `username`, must not be `None`" 83 | ) # noqa: E501 84 | 85 | self._username = username 86 | 87 | @property 88 | def profile_url(self): 89 | """Gets the profile_url of this GraphqlQuestionContributor. # noqa: E501 90 | 91 | 92 | :return: The profile_url of this GraphqlQuestionContributor. # noqa: E501 93 | :rtype: str 94 | """ 95 | return self._profile_url 96 | 97 | @profile_url.setter 98 | def profile_url(self, profile_url): 99 | """Sets the profile_url of this GraphqlQuestionContributor. 100 | 101 | 102 | :param profile_url: The profile_url of this GraphqlQuestionContributor. # noqa: E501 103 | :type: str 104 | """ 105 | if profile_url is None: 106 | raise ValueError( 107 | "Invalid value for `profile_url`, must not be `None`" 108 | ) # noqa: E501 109 | 110 | self._profile_url = profile_url 111 | 112 | @property 113 | def avatar_url(self): 114 | """Gets the avatar_url of this GraphqlQuestionContributor. # noqa: E501 115 | 116 | 117 | :return: The avatar_url of this GraphqlQuestionContributor. # noqa: E501 118 | :rtype: str 119 | """ 120 | return self._avatar_url 121 | 122 | @avatar_url.setter 123 | def avatar_url(self, avatar_url): 124 | """Sets the avatar_url of this GraphqlQuestionContributor. 125 | 126 | 127 | :param avatar_url: The avatar_url of this GraphqlQuestionContributor. # noqa: E501 128 | :type: str 129 | """ 130 | if avatar_url is None: 131 | raise ValueError( 132 | "Invalid value for `avatar_url`, must not be `None`" 133 | ) # noqa: E501 134 | 135 | self._avatar_url = avatar_url 136 | 137 | @property 138 | def typename(self): 139 | """Gets the typename of this GraphqlQuestionContributor. # noqa: E501 140 | 141 | 142 | :return: The typename of this GraphqlQuestionContributor. # noqa: E501 143 | :rtype: str 144 | """ 145 | return self._typename 146 | 147 | @typename.setter 148 | def typename(self, typename): 149 | """Sets the typename of this GraphqlQuestionContributor. 150 | 151 | 152 | :param typename: The typename of this GraphqlQuestionContributor. # noqa: E501 153 | :type: str 154 | """ 155 | 156 | self._typename = typename 157 | 158 | def to_dict(self): 159 | """Returns the model properties as a dict""" 160 | result = {} 161 | 162 | for attr, _ in six.iteritems(self.swagger_types): 163 | value = getattr(self, attr) 164 | if isinstance(value, list): 165 | result[attr] = list( 166 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 167 | ) 168 | elif hasattr(value, "to_dict"): 169 | result[attr] = value.to_dict() 170 | elif isinstance(value, dict): 171 | result[attr] = dict( 172 | map( 173 | lambda item: (item[0], item[1].to_dict()) 174 | if hasattr(item[1], "to_dict") 175 | else item, 176 | value.items(), 177 | ) 178 | ) 179 | else: 180 | result[attr] = value 181 | if issubclass(GraphqlQuestionContributor, dict): 182 | for key, value in self.items(): 183 | result[key] = value 184 | 185 | return result 186 | 187 | def to_str(self) -> str: 188 | """Returns the string representation of the model""" 189 | return pprint.pformat(self.to_dict()) 190 | 191 | def __repr__(self) -> str: 192 | """For `print` and `pprint`""" 193 | return self.to_str() 194 | 195 | def __eq__(self, other: GraphqlQuestionContributor) -> bool: 196 | """Returns true if both objects are equal""" 197 | if not isinstance(other, GraphqlQuestionContributor): 198 | return False 199 | 200 | return self.__dict__ == other.__dict__ 201 | 202 | def __ne__(self, other) -> bool: 203 | """Returns true if both objects are not equal""" 204 | return not self == other 205 | -------------------------------------------------------------------------------- /leetcode/models/test_submission.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class TestSubmission(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = { 33 | "data_input": "str", 34 | "lang": "str", 35 | "question_id": "int", 36 | "test_mode": "bool", 37 | "typed_code": "str", 38 | } 39 | 40 | attribute_map = { 41 | "data_input": "data_input", 42 | "lang": "lang", 43 | "question_id": "question_id", 44 | "test_mode": "test_mode", 45 | "typed_code": "typed_code", 46 | } 47 | 48 | def __init__( 49 | self, 50 | data_input=None, 51 | lang=None, 52 | question_id=None, 53 | test_mode=None, 54 | typed_code=None, 55 | ): # noqa: E501 56 | """TestSubmission - a model defined in Swagger""" # noqa: E501 57 | self._data_input = None 58 | self._lang = None 59 | self._question_id = None 60 | self._test_mode = None 61 | self._typed_code = None 62 | self.discriminator = None 63 | self.data_input = data_input 64 | self.lang = lang 65 | self.question_id = question_id 66 | self.test_mode = test_mode 67 | self.typed_code = typed_code 68 | 69 | @property 70 | def data_input(self): 71 | """Gets the data_input of this TestSubmission. # noqa: E501 72 | 73 | 74 | :return: The data_input of this TestSubmission. # noqa: E501 75 | :rtype: str 76 | """ 77 | return self._data_input 78 | 79 | @data_input.setter 80 | def data_input(self, data_input): 81 | """Sets the data_input of this TestSubmission. 82 | 83 | 84 | :param data_input: The data_input of this TestSubmission. # noqa: E501 85 | :type: str 86 | """ 87 | if data_input is None: 88 | raise ValueError( 89 | "Invalid value for `data_input`, must not be `None`" 90 | ) # noqa: E501 91 | 92 | self._data_input = data_input 93 | 94 | @property 95 | def lang(self): 96 | """Gets the lang of this TestSubmission. # noqa: E501 97 | 98 | 99 | :return: The lang of this TestSubmission. # noqa: E501 100 | :rtype: str 101 | """ 102 | return self._lang 103 | 104 | @lang.setter 105 | def lang(self, lang): 106 | """Sets the lang of this TestSubmission. 107 | 108 | 109 | :param lang: The lang of this TestSubmission. # noqa: E501 110 | :type: str 111 | """ 112 | if lang is None: 113 | raise ValueError( 114 | "Invalid value for `lang`, must not be `None`" 115 | ) # noqa: E501 116 | 117 | self._lang = lang 118 | 119 | @property 120 | def question_id(self): 121 | """Gets the question_id of this TestSubmission. # noqa: E501 122 | 123 | 124 | :return: The question_id of this TestSubmission. # noqa: E501 125 | :rtype: int 126 | """ 127 | return self._question_id 128 | 129 | @question_id.setter 130 | def question_id(self, question_id): 131 | """Sets the question_id of this TestSubmission. 132 | 133 | 134 | :param question_id: The question_id of this TestSubmission. # noqa: E501 135 | :type: int 136 | """ 137 | if question_id is None: 138 | raise ValueError( 139 | "Invalid value for `question_id`, must not be `None`" 140 | ) # noqa: E501 141 | 142 | self._question_id = question_id 143 | 144 | @property 145 | def test_mode(self): 146 | """Gets the test_mode of this TestSubmission. # noqa: E501 147 | 148 | 149 | :return: The test_mode of this TestSubmission. # noqa: E501 150 | :rtype: bool 151 | """ 152 | return self._test_mode 153 | 154 | @test_mode.setter 155 | def test_mode(self, test_mode): 156 | """Sets the test_mode of this TestSubmission. 157 | 158 | 159 | :param test_mode: The test_mode of this TestSubmission. # noqa: E501 160 | :type: bool 161 | """ 162 | if test_mode is None: 163 | raise ValueError( 164 | "Invalid value for `test_mode`, must not be `None`" 165 | ) # noqa: E501 166 | 167 | self._test_mode = test_mode 168 | 169 | @property 170 | def typed_code(self): 171 | """Gets the typed_code of this TestSubmission. # noqa: E501 172 | 173 | 174 | :return: The typed_code of this TestSubmission. # noqa: E501 175 | :rtype: str 176 | """ 177 | return self._typed_code 178 | 179 | @typed_code.setter 180 | def typed_code(self, typed_code): 181 | """Sets the typed_code of this TestSubmission. 182 | 183 | 184 | :param typed_code: The typed_code of this TestSubmission. # noqa: E501 185 | :type: str 186 | """ 187 | if typed_code is None: 188 | raise ValueError( 189 | "Invalid value for `typed_code`, must not be `None`" 190 | ) # noqa: E501 191 | 192 | self._typed_code = typed_code 193 | 194 | def to_dict(self): 195 | """Returns the model properties as a dict""" 196 | result = {} 197 | 198 | for attr, _ in six.iteritems(self.swagger_types): 199 | value = getattr(self, attr) 200 | if isinstance(value, list): 201 | result[attr] = list( 202 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 203 | ) 204 | elif hasattr(value, "to_dict"): 205 | result[attr] = value.to_dict() 206 | elif isinstance(value, dict): 207 | result[attr] = dict( 208 | map( 209 | lambda item: (item[0], item[1].to_dict()) 210 | if hasattr(item[1], "to_dict") 211 | else item, 212 | value.items(), 213 | ) 214 | ) 215 | else: 216 | result[attr] = value 217 | if issubclass(TestSubmission, dict): 218 | for key, value in self.items(): 219 | result[key] = value 220 | 221 | return result 222 | 223 | def to_str(self): 224 | """Returns the string representation of the model""" 225 | return pprint.pformat(self.to_dict()) 226 | 227 | def __repr__(self): 228 | """For `print` and `pprint`""" 229 | return self.to_str() 230 | 231 | def __eq__(self, other): 232 | """Returns true if both objects are equal""" 233 | if not isinstance(other, TestSubmission): 234 | return False 235 | 236 | return self.__dict__ == other.__dict__ 237 | 238 | def __ne__(self, other): 239 | """Returns true if both objects are not equal""" 240 | return not self == other 241 | -------------------------------------------------------------------------------- /test/test_graphql_request_get_question_detail.py: -------------------------------------------------------------------------------- 1 | import json 2 | import test.base 3 | 4 | from leetcode.models.graphql_query import GraphqlQuery 5 | from leetcode.models.graphql_query_get_question_detail_variables import ( 6 | GraphqlQueryGetQuestionDetailVariables, 7 | ) 8 | from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet 9 | from leetcode.models.graphql_question_topic_tag import GraphqlQuestionTopicTag 10 | 11 | 12 | class TestGraphqlGetQuestionDetail(test.base.BaseTest): 13 | def test_request(self) -> None: 14 | graphql_request = GraphqlQuery( 15 | query=""" 16 | query getQuestionDetail($titleSlug: String!) { 17 | question(titleSlug: $titleSlug) { 18 | questionId 19 | questionFrontendId 20 | boundTopicId 21 | title 22 | titleSlug 23 | frequency 24 | freqBar 25 | content 26 | translatedTitle 27 | isPaidOnly 28 | difficulty 29 | likes 30 | dislikes 31 | isLiked 32 | isFavor 33 | similarQuestions 34 | contributors { 35 | username 36 | profileUrl 37 | avatarUrl 38 | __typename 39 | } 40 | langToValidPlayground 41 | topicTags { 42 | name 43 | slug 44 | translatedName 45 | __typename 46 | } 47 | companyTagStats 48 | codeSnippets { 49 | lang 50 | langSlug 51 | code 52 | __typename 53 | } 54 | stats 55 | acRate 56 | codeDefinition 57 | hints 58 | solution { 59 | id 60 | canSeeDetail 61 | __typename 62 | } 63 | hasSolution 64 | hasVideoSolution 65 | status 66 | sampleTestCase 67 | enableRunCode 68 | metaData 69 | translatedContent 70 | judgerAvailable 71 | judgeType 72 | mysqlSchemas 73 | enableTestMode 74 | envInfo 75 | __typename 76 | } 77 | } 78 | """, 79 | variables=GraphqlQueryGetQuestionDetailVariables(title_slug="two-sum"), 80 | operation_name="getQuestionDetail", 81 | ) 82 | 83 | response = self._api_instance.graphql_post(body=graphql_request) 84 | 85 | data = response.data 86 | 87 | assert data 88 | 89 | problemset_question_list = data.problemset_question_list 90 | 91 | assert problemset_question_list is None 92 | 93 | question = data.question 94 | user = data.user 95 | 96 | assert user is None 97 | 98 | assert question.question_id == "1" 99 | assert question.question_frontend_id == "1" 100 | assert question.bound_topic_id is None 101 | assert question.title == "Two Sum" 102 | assert question.title_slug == "two-sum" 103 | assert question.frequency == 0.0 104 | if question.freq_bar is not None: # only available for premium users 105 | assert question.freq_bar > 0 106 | assert len(question.content) > 10 107 | assert question.translated_title is None 108 | assert question.is_paid_only is False 109 | assert question.difficulty == "Easy" 110 | assert question.likes > 0 111 | assert question.dislikes > 0 112 | assert question.is_liked is None 113 | assert question.is_favor in (True, False) 114 | assert json.loads(question.similar_questions)[0]["difficulty"] in ( 115 | "Easy", 116 | "Medium", 117 | "Hard", 118 | ) 119 | assert len(question.contributors) == 0 120 | assert "python" in list(json.loads(question.lang_to_valid_playground).keys()) 121 | topic_tag = question.topic_tags[0] 122 | assert isinstance(topic_tag, GraphqlQuestionTopicTag) 123 | assert len(topic_tag.name) > 0 124 | assert len(topic_tag.slug) > 0 125 | assert question.topic_tags[0].translated_name is None 126 | assert len(topic_tag.typename) > 0 127 | 128 | if question.company_tag_stats is not None: # only available for premium users 129 | tag_stat = list(json.loads(question.company_tag_stats).values())[0][0] 130 | 131 | assert tag_stat["taggedByAdmin"] in (True, False) 132 | assert len(tag_stat["name"]) > 0 133 | assert len(tag_stat["slug"]) > 0 134 | assert tag_stat["timesEncountered"] > 0 135 | 136 | code_snippet = question.code_snippets[0] 137 | 138 | assert isinstance(code_snippet, GraphqlQuestionCodeSnippet) 139 | assert len(code_snippet.code) > 0 140 | assert len(code_snippet.lang) > 0 141 | assert len(code_snippet.lang_slug) > 0 142 | assert code_snippet.typename == "CodeSnippetNode" 143 | 144 | stats = json.loads(question.stats) 145 | 146 | assert len(stats["totalAccepted"]) > 0 147 | assert len(stats["totalSubmission"]) > 0 148 | assert int(stats["totalAcceptedRaw"]) > 0 149 | assert int(stats["totalSubmissionRaw"]) > 0 150 | 151 | assert question.ac_rate > 0 152 | 153 | code_definition = json.loads(question.code_definition)[0] 154 | 155 | assert len(code_definition["value"]) > 0 156 | assert len(code_definition["text"]) > 0 157 | assert len(code_definition["defaultCode"]) > 0 158 | 159 | assert [len(hint) > 0 for hint in question.hints] 160 | 161 | solution = question.solution 162 | 163 | # FIXME: this check doesn't work with swagger generated code 164 | # assert isinstance(solution, GraphqlQuestionSolution) 165 | 166 | # FIXME: swagger generates the code which returns dict 167 | assert solution["__typename"] == "ArticleNode" 168 | assert solution["canSeeDetail"] in (True, False) 169 | assert int(solution["id"]) > 0 170 | 171 | assert question.has_solution in (True, False) 172 | assert question.has_video_solution in (True, False) 173 | 174 | assert question.status in ("ac", "not_started", "tried", None) 175 | 176 | assert len(question.sample_test_case) > 0 177 | 178 | assert question.enable_run_code in (True, False) 179 | 180 | meta_data = json.loads(question.meta_data) 181 | 182 | assert meta_data["name"] == "twoSum" 183 | assert meta_data["params"][0]["name"] 184 | assert meta_data["params"][0]["type"] 185 | assert meta_data["return"]["type"] 186 | assert meta_data["return"]["size"] 187 | assert meta_data["manual"] in (True, False) 188 | 189 | assert question.translated_content is None 190 | 191 | assert question.judger_available is True 192 | assert question.judge_type in ("large", "small") 193 | 194 | assert question.mysql_schemas == [] 195 | 196 | assert question.enable_test_mode in (True, False) 197 | 198 | env_info = json.loads(question.env_info) 199 | 200 | assert env_info["cpp"][0] == "C++" 201 | -------------------------------------------------------------------------------- /leetcode/models/submission.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | 13 | import pprint 14 | import re # noqa: F401 15 | 16 | import six 17 | 18 | 19 | class Submission(object): 20 | """NOTE: This class is auto generated by the swagger code generator program. 21 | 22 | Do not edit the class manually. 23 | """ 24 | 25 | """ 26 | Attributes: 27 | swagger_types (dict): The key is attribute name 28 | and the value is attribute type. 29 | attribute_map (dict): The key is attribute name 30 | and the value is json key in definition. 31 | """ 32 | swagger_types = { 33 | "judge_type": "str", 34 | "lang": "str", 35 | "question_id": "int", 36 | "test_mode": "bool", 37 | "typed_code": "str", 38 | } 39 | 40 | attribute_map = { 41 | "judge_type": "judge_type", 42 | "lang": "lang", 43 | "question_id": "question_id", 44 | "test_mode": "test_mode", 45 | "typed_code": "typed_code", 46 | } 47 | 48 | def __init__( 49 | self, 50 | judge_type=None, 51 | lang=None, 52 | question_id=None, 53 | test_mode=None, 54 | typed_code=None, 55 | ): # noqa: E501 56 | """Submission - a model defined in Swagger""" # noqa: E501 57 | self._judge_type = None 58 | self._lang = None 59 | self._question_id = None 60 | self._test_mode = None 61 | self._typed_code = None 62 | self.discriminator = None 63 | self.judge_type = judge_type 64 | self.lang = lang 65 | self.question_id = question_id 66 | self.test_mode = test_mode 67 | self.typed_code = typed_code 68 | 69 | @property 70 | def judge_type(self): 71 | """Gets the judge_type of this Submission. # noqa: E501 72 | 73 | 74 | :return: The judge_type of this Submission. # noqa: E501 75 | :rtype: str 76 | """ 77 | return self._judge_type 78 | 79 | @judge_type.setter 80 | def judge_type(self, judge_type): 81 | """Sets the judge_type of this Submission. 82 | 83 | 84 | :param judge_type: The judge_type of this Submission. # noqa: E501 85 | :type: str 86 | """ 87 | if judge_type is None: 88 | raise ValueError( 89 | "Invalid value for `judge_type`, must not be `None`" 90 | ) # noqa: E501 91 | allowed_values = ["large"] # noqa: E501 92 | if judge_type not in allowed_values: 93 | raise ValueError( 94 | "Invalid value for `judge_type` ({0}), must be one of {1}".format( # noqa: E501 95 | judge_type, allowed_values 96 | ) 97 | ) 98 | 99 | self._judge_type = judge_type 100 | 101 | @property 102 | def lang(self): 103 | """Gets the lang of this Submission. # noqa: E501 104 | 105 | 106 | :return: The lang of this Submission. # noqa: E501 107 | :rtype: str 108 | """ 109 | return self._lang 110 | 111 | @lang.setter 112 | def lang(self, lang): 113 | """Sets the lang of this Submission. 114 | 115 | 116 | :param lang: The lang of this Submission. # noqa: E501 117 | :type: str 118 | """ 119 | if lang is None: 120 | raise ValueError( 121 | "Invalid value for `lang`, must not be `None`" 122 | ) # noqa: E501 123 | 124 | self._lang = lang 125 | 126 | @property 127 | def question_id(self): 128 | """Gets the question_id of this Submission. # noqa: E501 129 | 130 | 131 | :return: The question_id of this Submission. # noqa: E501 132 | :rtype: int 133 | """ 134 | return self._question_id 135 | 136 | @question_id.setter 137 | def question_id(self, question_id): 138 | """Sets the question_id of this Submission. 139 | 140 | 141 | :param question_id: The question_id of this Submission. # noqa: E501 142 | :type: int 143 | """ 144 | if question_id is None: 145 | raise ValueError( 146 | "Invalid value for `question_id`, must not be `None`" 147 | ) # noqa: E501 148 | 149 | self._question_id = question_id 150 | 151 | @property 152 | def test_mode(self): 153 | """Gets the test_mode of this Submission. # noqa: E501 154 | 155 | 156 | :return: The test_mode of this Submission. # noqa: E501 157 | :rtype: bool 158 | """ 159 | return self._test_mode 160 | 161 | @test_mode.setter 162 | def test_mode(self, test_mode): 163 | """Sets the test_mode of this Submission. 164 | 165 | 166 | :param test_mode: The test_mode of this Submission. # noqa: E501 167 | :type: bool 168 | """ 169 | if test_mode is None: 170 | raise ValueError( 171 | "Invalid value for `test_mode`, must not be `None`" 172 | ) # noqa: E501 173 | 174 | self._test_mode = test_mode 175 | 176 | @property 177 | def typed_code(self): 178 | """Gets the typed_code of this Submission. # noqa: E501 179 | 180 | 181 | :return: The typed_code of this Submission. # noqa: E501 182 | :rtype: str 183 | """ 184 | return self._typed_code 185 | 186 | @typed_code.setter 187 | def typed_code(self, typed_code): 188 | """Sets the typed_code of this Submission. 189 | 190 | 191 | :param typed_code: The typed_code of this Submission. # noqa: E501 192 | :type: str 193 | """ 194 | if typed_code is None: 195 | raise ValueError( 196 | "Invalid value for `typed_code`, must not be `None`" 197 | ) # noqa: E501 198 | 199 | self._typed_code = typed_code 200 | 201 | def to_dict(self): 202 | """Returns the model properties as a dict""" 203 | result = {} 204 | 205 | for attr, _ in six.iteritems(self.swagger_types): 206 | value = getattr(self, attr) 207 | if isinstance(value, list): 208 | result[attr] = list( 209 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 210 | ) 211 | elif hasattr(value, "to_dict"): 212 | result[attr] = value.to_dict() 213 | elif isinstance(value, dict): 214 | result[attr] = dict( 215 | map( 216 | lambda item: (item[0], item[1].to_dict()) 217 | if hasattr(item[1], "to_dict") 218 | else item, 219 | value.items(), 220 | ) 221 | ) 222 | else: 223 | result[attr] = value 224 | if issubclass(Submission, dict): 225 | for key, value in self.items(): 226 | result[key] = value 227 | 228 | return result 229 | 230 | def to_str(self): 231 | """Returns the string representation of the model""" 232 | return pprint.pformat(self.to_dict()) 233 | 234 | def __repr__(self): 235 | """For `print` and `pprint`""" 236 | return self.to_str() 237 | 238 | def __eq__(self, other): 239 | """Returns true if both objects are equal""" 240 | if not isinstance(other, Submission): 241 | return False 242 | 243 | return self.__dict__ == other.__dict__ 244 | 245 | def __ne__(self, other): 246 | """Returns true if both objects are not equal""" 247 | return not self == other 248 | -------------------------------------------------------------------------------- /leetcode/models/graphql_query_problemset_question_list_variables_filter_input.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Leetcode API 5 | 6 | Leetcode API implementation. # noqa: E501 7 | 8 | OpenAPI spec version: 1.0.1-1 9 | Contact: pv.safronov@gmail.com 10 | Generated by: https://github.com/swagger-api/swagger-codegen.git 11 | """ 12 | from __future__ import annotations 13 | 14 | import pprint 15 | import re # noqa: F401 16 | 17 | import six 18 | 19 | 20 | class GraphqlQueryProblemsetQuestionListVariablesFilterInput(object): 21 | """NOTE: This class is auto generated by the swagger code generator program. 22 | 23 | Do not edit the class manually. 24 | """ 25 | 26 | """ 27 | Attributes: 28 | swagger_types (dict): The key is attribute name 29 | and the value is attribute type. 30 | attribute_map (dict): The key is attribute name 31 | and the value is json key in definition. 32 | """ 33 | swagger_types = { 34 | "tags": "list[str]", 35 | "difficulty": "str", 36 | "status": "str", 37 | "list_id": "str", 38 | "premium_only": "bool", 39 | } 40 | 41 | attribute_map = { 42 | "tags": "tags", 43 | "difficulty": "difficulty", 44 | "status": "status", 45 | "list_id": "listId", 46 | "premium_only": "premiumOnly", 47 | } 48 | 49 | def __init__( 50 | self, tags=None, difficulty=None, status=None, list_id=None, premium_only=None 51 | ) -> None: # noqa: E501 52 | """GraphqlQueryProblemsetQuestionListVariablesFilterInput - a model defined in Swagger""" # noqa: E501 53 | self._tags = None 54 | self._difficulty = None 55 | self._status = None 56 | self._list_id = None 57 | self._premium_only = None 58 | self.discriminator = None 59 | if tags is not None: 60 | self.tags = tags 61 | if difficulty is not None: 62 | self.difficulty = difficulty 63 | if status is not None: 64 | self.status = status 65 | if list_id is not None: 66 | self.list_id = list_id 67 | if premium_only is not None: 68 | self.premium_only = premium_only 69 | 70 | @property 71 | def tags(self): 72 | """Gets the tags of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 73 | 74 | 75 | :return: The tags of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 76 | :rtype: list[str] 77 | """ 78 | return self._tags 79 | 80 | @tags.setter 81 | def tags(self, tags): 82 | """Sets the tags of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. 83 | 84 | 85 | :param tags: The tags of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 86 | :type: list[str] 87 | """ 88 | 89 | self._tags = tags 90 | 91 | @property 92 | def difficulty(self): 93 | """Gets the difficulty of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 94 | 95 | 96 | :return: The difficulty of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 97 | :rtype: str 98 | """ 99 | return self._difficulty 100 | 101 | @difficulty.setter 102 | def difficulty(self, difficulty): 103 | """Sets the difficulty of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. 104 | 105 | 106 | :param difficulty: The difficulty of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 107 | :type: str 108 | """ 109 | 110 | self._difficulty = difficulty 111 | 112 | @property 113 | def status(self): 114 | """Gets the status of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 115 | 116 | 117 | :return: The status of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 118 | :rtype: str 119 | """ 120 | return self._status 121 | 122 | @status.setter 123 | def status(self, status): 124 | """Sets the status of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. 125 | 126 | 127 | :param status: The status of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 128 | :type: str 129 | """ 130 | 131 | self._status = status 132 | 133 | @property 134 | def list_id(self): 135 | """Gets the list_id of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 136 | 137 | 138 | :return: The list_id of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 139 | :rtype: str 140 | """ 141 | return self._list_id 142 | 143 | @list_id.setter 144 | def list_id(self, list_id): 145 | """Sets the list_id of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. 146 | 147 | 148 | :param list_id: The list_id of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 149 | :type: str 150 | """ 151 | 152 | self._list_id = list_id 153 | 154 | @property 155 | def premium_only(self): 156 | """Gets the premium_only of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 157 | 158 | 159 | :return: The premium_only of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 160 | :rtype: bool 161 | """ 162 | return self._premium_only 163 | 164 | @premium_only.setter 165 | def premium_only(self, premium_only): 166 | """Sets the premium_only of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. 167 | 168 | 169 | :param premium_only: The premium_only of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 170 | :type: bool 171 | """ 172 | 173 | self._premium_only = premium_only 174 | 175 | def to_dict(self): 176 | """Returns the model properties as a dict""" 177 | result = {} 178 | 179 | for attr, _ in six.iteritems(self.swagger_types): 180 | value = getattr(self, attr) 181 | if isinstance(value, list): 182 | result[attr] = list( 183 | map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) 184 | ) 185 | elif hasattr(value, "to_dict"): 186 | result[attr] = value.to_dict() 187 | elif isinstance(value, dict): 188 | result[attr] = dict( 189 | map( 190 | lambda item: (item[0], item[1].to_dict()) 191 | if hasattr(item[1], "to_dict") 192 | else item, 193 | value.items(), 194 | ) 195 | ) 196 | else: 197 | result[attr] = value 198 | if issubclass(GraphqlQueryProblemsetQuestionListVariablesFilterInput, dict): 199 | for key, value in self.items(): 200 | result[key] = value 201 | 202 | return result 203 | 204 | def to_str(self) -> str: 205 | """Returns the string representation of the model""" 206 | return pprint.pformat(self.to_dict()) 207 | 208 | def __repr__(self) -> str: 209 | """For `print` and `pprint`""" 210 | return self.to_str() 211 | 212 | def __eq__( 213 | self, other: GraphqlQueryProblemsetQuestionListVariablesFilterInput 214 | ) -> bool: 215 | """Returns true if both objects are equal""" 216 | if not isinstance( 217 | other, GraphqlQueryProblemsetQuestionListVariablesFilterInput 218 | ): 219 | return False 220 | 221 | return self.__dict__ == other.__dict__ 222 | 223 | def __ne__(self, other) -> bool: 224 | """Returns true if both objects are not equal""" 225 | return not self == other 226 | -------------------------------------------------------------------------------- /test/test_graphql_request_problemset_question_list.py: -------------------------------------------------------------------------------- 1 | import json 2 | import test.base 3 | 4 | from leetcode.models.graphql_query import GraphqlQuery 5 | from leetcode.models.graphql_query_problemset_question_list_variables import ( 6 | GraphqlQueryProblemsetQuestionListVariables, 7 | ) 8 | from leetcode.models.graphql_query_problemset_question_list_variables_filter_input import ( 9 | GraphqlQueryProblemsetQuestionListVariablesFilterInput, 10 | ) 11 | from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet 12 | from leetcode.models.graphql_question_topic_tag import GraphqlQuestionTopicTag 13 | 14 | 15 | class TestGraphqlGetQuestionDetail(test.base.BaseTest): 16 | def test_request(self) -> None: 17 | graphql_request = GraphqlQuery( 18 | query=""" 19 | query problemsetQuestionList($categorySlug: String, $limit: Int, $skip: Int, $filters: QuestionListFilterInput) { 20 | problemsetQuestionList: questionList( 21 | categorySlug: $categorySlug 22 | limit: $limit 23 | skip: $skip 24 | filters: $filters 25 | ) { 26 | totalNum 27 | questions: data { 28 | questionId 29 | questionFrontendId 30 | boundTopicId 31 | title 32 | frequency 33 | freqBar 34 | content 35 | translatedTitle 36 | isPaidOnly 37 | difficulty 38 | likes 39 | dislikes 40 | isLiked 41 | isFavor 42 | similarQuestions 43 | contributors { 44 | username 45 | profileUrl 46 | avatarUrl 47 | __typename 48 | } 49 | langToValidPlayground 50 | topicTags { 51 | name 52 | slug 53 | translatedName 54 | __typename 55 | } 56 | companyTagStats 57 | codeSnippets { 58 | lang 59 | langSlug 60 | code 61 | __typename 62 | } 63 | stats 64 | acRate 65 | codeDefinition 66 | hints 67 | solution { 68 | id 69 | canSeeDetail 70 | __typename 71 | } 72 | hasSolution 73 | hasVideoSolution 74 | status 75 | sampleTestCase 76 | enableRunCode 77 | metaData 78 | translatedContent 79 | judgerAvailable 80 | judgeType 81 | mysqlSchemas 82 | enableTestMode 83 | envInfo 84 | __typename 85 | } 86 | } 87 | } 88 | """, 89 | variables=GraphqlQueryProblemsetQuestionListVariables( 90 | category_slug="algorithms", 91 | limit=1, 92 | skip=3, 93 | filters=GraphqlQueryProblemsetQuestionListVariablesFilterInput( 94 | tags=["array"], 95 | difficulty="MEDIUM", 96 | status="NOT_STARTED", 97 | list_id="7p5x763", # Top Amazon Questions 98 | premium_only=False, 99 | ), 100 | ), 101 | operation_name="problemsetQuestionList", 102 | ) 103 | 104 | response = self._api_instance.graphql_post(body=graphql_request) 105 | 106 | data = response.data 107 | 108 | question = data.question 109 | 110 | assert question is None 111 | 112 | assert data 113 | 114 | assert data.problemset_question_list.total_num > 0 115 | 116 | question_list = data.problemset_question_list.questions 117 | user = data.user 118 | 119 | question = question_list[0] 120 | 121 | assert user is None 122 | 123 | assert question.question_id is not None 124 | assert question.question_frontend_id is not None 125 | assert question.bound_topic_id is None 126 | assert question.title is not None 127 | assert question.frequency == 0.0 128 | if question.freq_bar is not None: # only available for premium users 129 | assert question.freq_bar > 0 130 | assert len(question.content) > 10 131 | assert question.translated_title is None 132 | assert question.is_paid_only in (True, False) 133 | assert question.difficulty == "Medium" 134 | assert question.likes > 0 135 | assert question.dislikes > 0 136 | assert question.is_liked is None 137 | assert question.is_favor in (True, False) 138 | 139 | json.loads(question.similar_questions) 140 | 141 | assert len(question.contributors) == 0 142 | assert "python" in list(json.loads(question.lang_to_valid_playground).keys()) 143 | topic_tag = question.topic_tags[0] 144 | assert isinstance(topic_tag, GraphqlQuestionTopicTag) 145 | assert len(topic_tag.name) > 0 146 | assert len(topic_tag.slug) > 0 147 | assert question.topic_tags[0].translated_name is None 148 | assert len(topic_tag.typename) > 0 149 | 150 | if question.company_tag_stats is not None: # only available for premium users 151 | tag_stat = list(json.loads(question.company_tag_stats).values())[0][0] 152 | 153 | assert tag_stat["taggedByAdmin"] in (True, False) 154 | assert len(tag_stat["name"]) > 0 155 | assert len(tag_stat["slug"]) > 0 156 | assert tag_stat["timesEncountered"] > 0 157 | 158 | code_snippet = question.code_snippets[0] 159 | 160 | assert isinstance(code_snippet, GraphqlQuestionCodeSnippet) 161 | assert len(code_snippet.code) > 0 162 | assert len(code_snippet.lang) > 0 163 | assert len(code_snippet.lang_slug) > 0 164 | assert code_snippet.typename == "CodeSnippetNode" 165 | 166 | stats = json.loads(question.stats) 167 | 168 | assert len(stats["totalAccepted"]) > 0 169 | assert len(stats["totalSubmission"]) > 0 170 | assert int(stats["totalAcceptedRaw"]) > 0 171 | assert int(stats["totalSubmissionRaw"]) > 0 172 | 173 | assert question.ac_rate > 0 174 | 175 | code_definition = json.loads(question.code_definition)[0] 176 | 177 | assert len(code_definition["value"]) > 0 178 | assert len(code_definition["text"]) > 0 179 | assert len(code_definition["defaultCode"]) > 0 180 | 181 | # TODO: check if the field has disappeared or if this is just a premium 182 | # feature 183 | # assert [len(hint) > 0 for hint in question.hints] 184 | 185 | question.solution 186 | 187 | assert question.has_solution in (True, False) 188 | assert question.has_video_solution in (True, False) 189 | 190 | assert question.status in ("ac", "not_started", "tried", None) 191 | 192 | assert len(question.sample_test_case) > 0 193 | 194 | assert question.enable_run_code in (True, False) 195 | 196 | meta_data = json.loads(question.meta_data) 197 | 198 | assert meta_data["name"] is not None 199 | assert meta_data["params"][0]["name"] 200 | assert meta_data["params"][0]["type"] 201 | assert meta_data["return"]["type"] 202 | 203 | assert question.translated_content is None 204 | 205 | assert question.judger_available is True 206 | assert question.judge_type in ("large", "small") 207 | 208 | assert question.mysql_schemas == [] 209 | 210 | assert question.enable_test_mode in (True, False) 211 | 212 | env_info = json.loads(question.env_info) 213 | 214 | assert env_info["cpp"][0] == "C++" 215 | --------------------------------------------------------------------------------