-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: restructure API and remove deprecated send functionality
- Loading branch information
Showing
11 changed files
with
57 additions
and
110 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
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,58 +1,12 @@ | ||
from typing import NotRequired, Sequence, TypedDict | ||
from typing import TypedDict | ||
from appier import API as BaseAPI | ||
|
||
BASE_URL: str = ... | ||
|
||
class Attachment(TypedDict): | ||
name: str | ||
data: str | ||
mime: str | ||
hash: str | ||
etag: str | ||
guid: str | ||
engine: str | ||
from .node import NodeAPI | ||
|
||
class AttachmentPayload(TypedDict): | ||
name: str | ||
data: str | ||
mime: NotRequired[str] | ||
hash: NotRequired[str] | ||
etag: NotRequired[str] | ||
guid: NotRequired[str] | ||
engine: NotRequired[str] | ||
|
||
class Message(TypedDict): | ||
sender: str | None | ||
receivers: Sequence[str] | ||
cc: Sequence[str] | ||
bcc: Sequence[str] | ||
reply_to: Sequence[str] | ||
subject: str | ||
title: str | ||
subtitle: str | None | ||
contents: str | ||
html: str | ||
plain: str | ||
copyright: str | ||
logo_url: str | None | ||
attachments: Sequence[Attachment] | ||
id: str | None | ||
inline: bool | ||
style: str | ||
mode: str | ||
BASE_URL: str = ... | ||
|
||
class MessagePayload(TypedDict): | ||
receivers: Sequence[str] | ||
subject: NotRequired[str] | ||
title: NotRequired[str] | ||
contents: NotRequired[str] | ||
html: NotRequired[str] | ||
plain: NotRequired[str] | ||
copyright: NotRequired[str] | ||
attachments: NotRequired[Sequence[AttachmentPayload]] | ||
inline: NotRequired[bool] | ||
style: NotRequired[str] | ||
mode: NotRequired[str] | ||
class Ping(TypedDict): | ||
time: float | ||
|
||
class API(BaseAPI): | ||
def send(self, payload: MessagePayload) -> Message: ... | ||
class API(BaseAPI, NodeAPI): | ||
def ping(self) -> Ping: ... |
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,14 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
class NodeAPI(object): | ||
|
||
def list_nodes(self, *args, **kwargs): | ||
url = self.base_url + "nodes" | ||
contents = self.get(url, **kwargs) | ||
return contents | ||
|
||
|
||
class Node(dict): | ||
pass |
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,14 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
from typing import NotRequired, Sequence, TypedDict | ||
|
||
class Node(TypedDict): | ||
name: str | ||
mode: str | ||
location: NotRequired[str] | ||
node_printer: NotRequired[str] | ||
engines: Sequence[str] | ||
|
||
class NodeAPI: | ||
def list_nodes(self) -> Sequence[Node]: ... |
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,6 +1,6 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import sender | ||
from . import printer | ||
|
||
from .sender import send | ||
from .printer import print |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
import colony_print | ||
|
||
def get_api() -> colony_print.API: ... |