-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from EasyPost/payloads
feat: adds retrieve event payload and payloads functions
- Loading branch information
Showing
9 changed files
with
792 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,11 +1,37 @@ | ||
import json | ||
from typing import ( | ||
List, | ||
Optional, | ||
) | ||
|
||
import easypost | ||
from easypost.easypost_object import convert_to_easypost_object | ||
from easypost.requestor import ( | ||
RequestMethod, | ||
Requestor, | ||
) | ||
from easypost.resource import AllResource | ||
|
||
|
||
class Event(AllResource): | ||
@classmethod | ||
def receive(cls, values: str) -> "Event": | ||
return convert_to_easypost_object(response=json.loads(s=values), api_key=easypost.api_key) | ||
|
||
@classmethod | ||
def retrieve_all_payloads(cls, event_id: str, api_key: Optional[str] = None, **params) -> List["easypost.Payload"]: | ||
"""Retrieve a list of Payloads for an Event.""" | ||
requestor = Requestor(local_api_key=api_key) | ||
url = f"{cls.class_url()}/{event_id}/payloads" | ||
response, api_key = requestor.request(method=RequestMethod.GET, url=url, params=params) | ||
return convert_to_easypost_object(response=response, api_key=api_key) | ||
|
||
@classmethod | ||
def retrieve_payload( | ||
cls, event_id: str, payload_id: str, api_key: Optional[str] = None, **params | ||
) -> "easypost.Payload": | ||
"""Retrieve a Payload of an Event.""" | ||
requestor = Requestor(local_api_key=api_key) | ||
url = f"{cls.class_url()}/{event_id}/payloads/{payload_id}" | ||
response, api_key = requestor.request(method=RequestMethod.GET, url=url, params=params) | ||
return convert_to_easypost_object(response=response, api_key=api_key) |
This file contains 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,2 @@ | ||
class Payload: | ||
pass |
Oops, something went wrong.