-
Notifications
You must be signed in to change notification settings - Fork 14
Add EmailOtp resource to cuenca module and update imports accordingly #445
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
Open
rcabrera-py
wants to merge
2
commits into
main
Choose a base branch
from
feat/email-otp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import datetime as dt | ||
| from typing import ClassVar, Optional | ||
|
|
||
| from pydantic import ConfigDict | ||
|
|
||
| from ..http import Session, session as global_session | ||
| from .base import Creatable | ||
|
|
||
|
|
||
| class EmailOtp(Creatable): | ||
| _resource: ClassVar = 'email_otps' | ||
| owner_id: Optional[str] = None | ||
| expires_at: Optional[dt.datetime] = None | ||
|
|
||
| model_config = ConfigDict( | ||
| json_schema_extra={ | ||
| 'example': { | ||
| 'id': 'EOxxxxxxxxxxxxxxxxxxxxxx', | ||
| 'owner_id': 'SSxxxxxxxxxxxxxxxxxxxxxx', | ||
| 'expires_at': '2026-09-09T18:00:00', | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| @classmethod | ||
| def create(cls, session: Session = global_session) -> 'EmailOtp': | ||
| """Request a one-shot email OTP for the current Session.""" | ||
| return cls._create(session=session) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| __version__ = '2.2.4' | ||
| __version__ = '2.2.5.dev0' | ||
| CLIENT_VERSION = __version__ | ||
| API_VERSION = '2020-03-19' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import datetime as dt | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest | ||
|
|
||
| from cuenca import EmailOtp | ||
| from cuenca.http.client import Session | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def session() -> Session: | ||
| s = Session() | ||
| s.configure('api_key', 'api_secret', sandbox=True) | ||
| return s | ||
|
|
||
|
|
||
| @patch('cuenca.http.client.requests.Session.request') | ||
| def test_email_otp_create(mock_request: MagicMock, session: Session): | ||
| mock_request.return_value.ok = True | ||
| mock_request.return_value.content = ( | ||
| b'{"id":"EOxxxxxxxxxxxxxxxxxxxxxx",' | ||
| b'"owner_id":"SSxxxxxxxxxxxxxxxxxxxxxx",' | ||
| b'"expires_at":"2026-09-09T18:00:00"}' | ||
| ) | ||
|
|
||
| email_otp = EmailOtp.create(session=session) | ||
|
|
||
| assert email_otp.id == 'EOxxxxxxxxxxxxxxxxxxxxxx' | ||
| assert email_otp.owner_id == 'SSxxxxxxxxxxxxxxxxxxxxxx' | ||
| assert email_otp.expires_at == dt.datetime(2026, 9, 9, 18, 0, 0) | ||
|
|
||
| mock_request.assert_called_once() | ||
| _, kwargs = mock_request.call_args | ||
| assert kwargs['method'] == 'post' | ||
| assert kwargs['url'] == 'https://sandbox.cuenca.com/email_otps' | ||
| assert kwargs['json'] == {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Sort the public
__all__lists.Ruff reports RUF022 for both lists. Sort each complete
__all__list so the new exports do not retain the lint finding.cuenca/resources/__init__.py#L28-L29: placeEmailOtpandOperatorLoginin the configured sorted order.cuenca/__init__.py#L28-L29: placeEmailOtpandOperatorLoginin the configured sorted order.🧰 Tools
🪛 Ruff (0.16.4)
[warning] 1-51:
__all__is not sortedApply an isort-style sorting to
__all__(RUF022)
📍 Affects 2 files
cuenca/resources/__init__.py#L28-L29(this comment)cuenca/__init__.py#L28-L29🤖 Prompt for AI Agents
Source: Linters/SAST tools