-
Notifications
You must be signed in to change notification settings - Fork 14
Add PostalCodes resource #421
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7a717d0
Add PostalCodes resource to exports
gmorales96 dd58df4
Add tests
gmorales96 9eb9372
Refactor postal code tests to use parameterized testing and remove ob…
gmorales96 500cb27
Update cuenca-validations to version 2.1.8.dev7 and bump internal ver…
gmorales96 bdc7240
Update version to 2.1.5 for stable release
gmorales96 0177a23
Update user profession and add verification IDs in tests
gmorales96 e72923c
Update cuenca-validations to version 2.1.8 in requirements.txt
gmorales96 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,21 @@ | ||
| import datetime as dt | ||
| from typing import ClassVar | ||
|
|
||
| from cuenca_validations.types import Country, PostalCodeQuery, State | ||
|
|
||
| from .base import Queryable, Retrievable | ||
|
|
||
|
|
||
| class PostalCodes(Retrievable, Queryable): | ||
| _resource: ClassVar = 'postal_codes' | ||
| _query_params: ClassVar = PostalCodeQuery | ||
|
|
||
| id: str | ||
| created_at: dt.datetime | ||
| postal_code: str | ||
| colonia: str | ||
| city: str | ||
| state: State | ||
| state_name: str | ||
| country: Country | ||
| country_name: str | ||
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.1.4' | ||
| __version__ = '2.1.5' | ||
| 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| requests==2.32.3 | ||
| cuenca-validations==2.1.5 | ||
| cuenca-validations==2.1.8 | ||
| pydantic-extra-types==2.10.2 |
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
40 changes: 40 additions & 0 deletions
40
tests/resources/cassettes/test_postal_codes_retrieve[00000-0].yaml
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,40 @@ | ||
| interactions: | ||
| - request: | ||
| body: null | ||
| headers: | ||
| User-Agent: | ||
| - cuenca-python/2.1.5 | ||
| X-Cuenca-Api-Version: | ||
| - '2020-03-19' | ||
| method: GET | ||
| uri: https://sandbox.cuenca.com/postal_codes?postal_code=00000 | ||
| response: | ||
| body: | ||
| string: '{"items":[],"next_page_uri":null}' | ||
| headers: | ||
| Connection: | ||
| - keep-alive | ||
| Content-Length: | ||
| - '33' | ||
| Content-Type: | ||
| - application/json | ||
| Date: | ||
| - Thu, 03 Jul 2025 18:44:22 GMT | ||
| X-Request-Time: | ||
| - 'value: 0.044' | ||
| x-amz-apigw-id: | ||
| - NJVdIFzWCYcEQnA= | ||
| x-amzn-Remapped-Connection: | ||
| - keep-alive | ||
| x-amzn-Remapped-Content-Length: | ||
| - '33' | ||
| x-amzn-Remapped-Date: | ||
| - Thu, 03 Jul 2025 18:44:22 GMT | ||
| x-amzn-Remapped-Server: | ||
| - nginx/1.28.0 | ||
| x-amzn-RequestId: | ||
| - 00d3f3a3-2fb5-4b74-8fbf-8ac6dc615ae7 | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
41 changes: 41 additions & 0 deletions
41
tests/resources/cassettes/test_postal_codes_retrieve[40100-1].yaml
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,41 @@ | ||
| interactions: | ||
| - request: | ||
| body: null | ||
| headers: | ||
| User-Agent: | ||
| - cuenca-python/2.1.5 | ||
| X-Cuenca-Api-Version: | ||
| - '2020-03-19' | ||
| method: GET | ||
| uri: https://sandbox.cuenca.com/postal_codes?postal_code=40100 | ||
| response: | ||
| body: | ||
| string: "{\"items\":[{\"id\":\"PCHOECy9u6QQeXPR6HdR5Bgw\",\"created_at\":\"2025-06-25T18:44:14.409000\",\"postal_code\":\"40100\",\"colonia\":\"Metlapa\",\"city\":\"Iguala | ||
| de la Independencia\",\"state\":\"GR\",\"state_name\":\"Guerrero\",\"country\":\"MX\",\"country_name\":\"M\xE9xico\"}],\"next_page_uri\":null}" | ||
| headers: | ||
| Connection: | ||
| - keep-alive | ||
| Content-Length: | ||
| - '263' | ||
| Content-Type: | ||
| - application/json | ||
| Date: | ||
| - Thu, 03 Jul 2025 18:42:12 GMT | ||
| X-Request-Time: | ||
| - 'value: 0.046' | ||
| x-amz-apigw-id: | ||
| - NJVIwHRyCYcEeIw= | ||
| x-amzn-Remapped-Connection: | ||
| - keep-alive | ||
| x-amzn-Remapped-Content-Length: | ||
| - '263' | ||
| x-amzn-Remapped-Date: | ||
| - Thu, 03 Jul 2025 18:42:12 GMT | ||
| x-amzn-Remapped-Server: | ||
| - nginx/1.28.0 | ||
| x-amzn-RequestId: | ||
| - 75a527b3-8a33-42ed-8633-23dd2b1ddeff | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
42 changes: 42 additions & 0 deletions
42
tests/resources/cassettes/test_postal_codes_retrieve[40106-2].yaml
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,42 @@ | ||
| interactions: | ||
| - request: | ||
| body: null | ||
| headers: | ||
| User-Agent: | ||
| - cuenca-python/2.1.5 | ||
| X-Cuenca-Api-Version: | ||
| - '2020-03-19' | ||
| method: GET | ||
| uri: https://sandbox.cuenca.com/postal_codes?postal_code=40106 | ||
| response: | ||
| body: | ||
| string: "{\"items\":[{\"id\":\"PCqpCtquNnTTWj4afusCWbXQ\",\"created_at\":\"2025-06-25T18:44:14.409000\",\"postal_code\":\"40106\",\"colonia\":\"El | ||
| Naranjo\",\"city\":\"Iguala de la Independencia\",\"state\":\"GR\",\"state_name\":\"Guerrero\",\"country\":\"MX\",\"country_name\":\"M\xE9xico\"},{\"id\":\"PCN2-h_t4ASn-yr46-5C352g\",\"created_at\":\"2025-06-25T18:44:14.409000\",\"postal_code\":\"40106\",\"colonia\":\"Ficus\",\"city\":\"Iguala | ||
| de la Independencia\",\"state\":\"GR\",\"state_name\":\"Guerrero\",\"country\":\"MX\",\"country_name\":\"M\xE9xico\"}],\"next_page_uri\":null}" | ||
| headers: | ||
| Connection: | ||
| - keep-alive | ||
| Content-Length: | ||
| - '495' | ||
| Content-Type: | ||
| - application/json | ||
| Date: | ||
| - Thu, 03 Jul 2025 18:44:22 GMT | ||
| X-Request-Time: | ||
| - 'value: 0.045' | ||
| x-amz-apigw-id: | ||
| - NJVdFHJXCYcEPzw= | ||
| x-amzn-Remapped-Connection: | ||
| - keep-alive | ||
| x-amzn-Remapped-Content-Length: | ||
| - '495' | ||
| x-amzn-Remapped-Date: | ||
| - Thu, 03 Jul 2025 18:44:22 GMT | ||
| x-amzn-Remapped-Server: | ||
| - nginx/1.28.0 | ||
| x-amzn-RequestId: | ||
| - 3ff50d45-d63b-4244-9bba-9f7dc776d4bb | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
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,17 @@ | ||
| import pytest | ||
|
|
||
| from cuenca.resources import PostalCodes | ||
|
|
||
|
|
||
| @pytest.mark.vcr | ||
| @pytest.mark.parametrize( | ||
| "postal_code,expected_count", | ||
| [ | ||
| ("40100", 1), | ||
| ("40106", 2), | ||
| ("00000", 0), | ||
| ], | ||
| ) | ||
| def test_postal_codes_retrieve(postal_code: str, expected_count: int) -> None: | ||
| postal_codes = list(PostalCodes.all(postal_code=postal_code)) | ||
| assert len(postal_codes) == expected_count |
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
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.
Uh oh!
There was an error while loading. Please reload this page.