forked from unit-finance/unit-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Adds applications/check-registered-agent-address resource
#53
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
avesk
merged 7 commits into
master
from
eng-2507-update-unit-sdk-to-support-request-to-verify-if-an-address
Oct 22, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
10ac731
applications/check-registered-agent-address
avesk 2298c92
remove unused code
avesk c286167
Remove blank space
avesk b7c1903
MR Feedback
avesk 3f02a89
Fix type
avesk 5b7d74f
Inherit request
avesk d010935
Fix attrs
avesk 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| from unit.api.base_resource import BaseResource | ||
| from unit.models import * | ||
| from unit.models.check_registered_address import CheckRegisteredAddressRequest, CheckRegisteredAddressResponse | ||
| from unit.models.codecs import DtoDecoder | ||
|
|
||
|
|
||
| class CheckRegisteredAddressResource(BaseResource): | ||
| def __init__(self, api_url, token): | ||
| super().__init__(api_url, token) | ||
| self.resource = "applications/check-registered-agent-address" | ||
samuelvasco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def create(self, request: CheckRegisteredAddressRequest) -> Union[UnitResponse[CheckRegisteredAddressResponse], UnitError]: | ||
| payload = request.to_json_api() | ||
| response = super().post(self.resource, payload) | ||
|
|
||
| if response.ok: | ||
| data = response.json().get("data") | ||
| return UnitResponse[CheckRegisteredAddressResponse](DtoDecoder.decode(data), None) | ||
| else: | ||
| return UnitError.from_json_api(response.json()) | ||
|
|
||
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,55 @@ | ||
| from unit.models import * | ||
avesk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
|
|
||
| class CheckRegisteredAddressRequest(UnitRequest): | ||
| def __init__( | ||
| self, | ||
| street: str, | ||
| city: str, | ||
| state: str, | ||
| postal_code: str, | ||
| country: str, | ||
| street2: Optional[str] = None, | ||
| ): | ||
| self.type = "checkRegisteredAgentAddress" | ||
|
|
||
| self.attributes = { | ||
| "address": { | ||
| "street": street, | ||
| "city": city, | ||
| "state": state, | ||
| "postalCode": postal_code, | ||
| "country": country, | ||
| } | ||
| } | ||
|
|
||
| if street2: | ||
| self.attributes["address"]["street2"] = street2 | ||
|
|
||
| def to_json_api(self) -> Dict: | ||
| payload = { | ||
| "data": { | ||
| "type": self.type, | ||
| "attributes": self.attributes, | ||
| } | ||
| } | ||
| return payload | ||
|
|
||
|
|
||
| class CheckRegisteredAddressResponse(UnitDTO): | ||
| def __init__( | ||
| self, | ||
| is_registered_agent_address: bool, | ||
| ): | ||
| self.type = "checkRegisteredAgentAddress" | ||
| self.is_registered_agent_address = is_registered_agent_address | ||
| self.attributes = { | ||
| "isRegisteredAgentAddress": is_registered_agent_address, | ||
| } | ||
|
|
||
| @staticmethod | ||
| def from_json_api(_id, _type, attributes, relationships): | ||
| return CheckRegisteredAddressResponse( | ||
| attributes.get("isRegisteredAgentAddress"), | ||
| ) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.