diff --git a/.gitignore b/.gitignore index 789754b..3565a84 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,7 @@ crashlytics.properties crashlytics-build.properties .pytest_cache/ +.mypy_cache/ .python-version venv/ diff --git a/.travis.yml b/.travis.yml index a4e1c89..87c4597 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,24 @@ language: python sudo: false -python: -- pypy -- 2.7 -- 3.4 -- 3.5 -- 3.6 +jobs: + includes: + - python: pypy + env: RUN_MYPY=false + - python: 2.7 + env: RUN_MYPY=false + - python: 3.4 + env: RUN_MYPY=false + - python: 3.5 + env: RUN_MYPY=true + - python: 3.6 + env: RUN_MYPY=true install: - pip install tox-travis flake8 collective.checkdocs Pygments +- $RUN_MYPY && pip install mypy || true script: - flake8 . - python setup.py checkdocs - tox +- $RUN_MYPY && mypy iamport || true after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/iamport/client.pyi b/iamport/client.pyi new file mode 100644 index 0000000..995f248 --- /dev/null +++ b/iamport/client.pyi @@ -0,0 +1,66 @@ +from typing import Any, Dict, Optional, Union + +import requests + +IAMPORT_API_URL: str = ... +Amount = Union[int, float] + +class Iamport(object): + requests_session: requests.Session + + def __init__(self, imp_key: str, imp_secret: str, imp_url: str = ...) -> None: ... + + class ResponseError(Exception): + code: Any + message: Any + def __init__(self, code: Optional[Any] = ..., message: Optional[Any] = ...) -> None: ... + + class HttpError(Exception): + code: Any + message: Any + def __init__(self, code: Optional[Any] = ..., message: Optional[Any] = ...) -> None: ... + + @staticmethod + def get_response(response: requests.Response) -> Dict: ... + + def _get_token(self) -> str: ... + + def get_headers(self) -> Dict[str, str]: ... + + def _get(self, url: str, payload: Optional[Dict[str, Any]] = ...) -> Dict: ... + + def _post(self, url: str, payload: Optional[Dict[str, Any]] = ...) -> Dict: ... + + def find_by_merchant_uid(self, merchant_uid: str) -> Dict: ... + + def find_by_imp_uid(self, imp_uid: str) -> Dict: ... + + def find(self, **kwargs) -> Dict: ... + + def _cancel(self, payload: Dict[str, Any]) -> Dict: ... + + def pay_onetime(self, **kwargs) -> Dict: ... + + def pay_again(self, **kwargs) -> Dict: ... + + def customer_create(self, **kwargs) -> Dict: ... + + def customer_get(self, customer_uid: str) -> Dict: ... + + def pay_foreign(self, **kwargs) -> Dict: ... + + def pay_schedule(self, **kwargs) -> Dict: ... + + def pay_unschedule(self, **kwargs) -> Dict: ... + + def cancel_by_merchant_uid(self, merchant_uid: str, reason: str, **kwargs) -> Dict: ... + + def cancel_by_imp_uid(self, imp_uid: str, reason: str, **kwargs) -> Dict: ... + + def cancel(self, reason: str, **kwargs) -> Dict: ... + + def is_paid(self, amount: Amount, **kwargs) -> bool: ... + + def prepare(self, merchant_uid: str, amount: Amount) -> Dict: ... + + def prepare_validate(self, merchant_uid: str, amount: Amount) -> Dict: ... diff --git a/setup.py b/setup.py index d31c939..09a5eca 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,28 @@ def readme(): long_description=readme(), license='MIT', zip_safe=False, + data_files=[ + ( + 'shared/typehints/python2.7', + ['iamport/client.pyi'], + ), + ( + 'shared/typehints/python3.5', + ['iamport/client.pyi'], + ), + ( + 'shared/typehints/python3.6', + ['iamport/client.pyi'], + ), + ( + 'shared/typehints/python3.7', + ['iamport/client.pyi'], + ), + ( + 'shared/typehints/python3.8', + ['iamport/client.pyi'], + ), + ], classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Environment :: Web Environment',