Skip to content

AnnoFab WebAPIのエンドポイントを設定可能にする #110

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 22, 2020

Conversation

yuji38kwmt
Copy link
Collaborator

@yuji38kwmt yuji38kwmt commented Jan 21, 2020

close #110

self.session = requests.Session()

#: アクセスするURL
URL_PREFIX = "https://annofab.com/api/v1"
URL_PREFIX = f"{DEFAULT_ENDPOINT_URL}/v1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここにあるクラス変数の URL_PREFIX は不要じゃないでしょうか

Copy link
Collaborator Author

@yuji38kwmt yuji38kwmt Jan 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_request_wrapperメソッドと、loginメソッドの2か所で使っているので、必要だと思いました。

def _request_wrapper(self, http_method: str, url_path: str, query_params: Optional[Dict[str, Any]] = None,

def login(self) -> Tuple[Dict[str, Any], requests.Response]:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???
あれ、必要といいつつ、結局消しちゃいました?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

すみません、クラス変数とインスタンス変数を勘違いしていました…

  • クラス変数のurl_prefixは不要です。
  • インスタンス変数のself.url_prefixは、他のメソッドで使用しているので必要です。


if not login_user_id or not login_password:
raise ValueError("login_user_id or login_password is empty.")

self.login_user_id = login_user_id
self.login_password = login_password

self.endpoint_url = endpoint_url
self.URL_PREFIX = f"{endpoint_url}/v1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここだけ大文字なのはなぜ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

もともと定数として扱っていたので、大文字にしていました。
今回の対応で定数ではなくなったので、小文字に変更します。

@yuji38kwmt yuji38kwmt merged commit e90e98f into master Jan 22, 2020
@yuji38kwmt yuji38kwmt deleted the 109-set-endpoint branch January 24, 2020 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants