-
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.
- Loading branch information
Showing
22 changed files
with
492 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Deploy Workflow | ||
on: | ||
push: | ||
tags: | ||
- "*" | ||
jobs: | ||
build: | ||
name: Build | ||
strategy: | ||
matrix: | ||
python-version: [2.7] | ||
runs-on: ubuntu-latest | ||
container: python:${{ matrix.python-version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: python --version | ||
- run: pip install -r requirements.txt | ||
- run: | | ||
pip install black | ||
black . --check | ||
if: matrix.python-version == '3.12' | ||
- run: python setup.py test | ||
- run: pip install twine wheel | ||
- run: python setup.py sdist bdist_wheel | ||
- run: python -m twine upload -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} dist/* | ||
env: | ||
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
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,56 @@ | ||
name: Main Workflow | ||
on: [push] | ||
jobs: | ||
build: | ||
name: Build | ||
strategy: | ||
matrix: | ||
python-version: [ | ||
2.7, | ||
3.5, | ||
3.6, | ||
3.7, | ||
3.8, | ||
3.9, | ||
"3.10", | ||
"3.11", | ||
"3.12", | ||
latest, | ||
rc | ||
] | ||
runs-on: ubuntu-latest | ||
container: python:${{ matrix.python-version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: python --version | ||
- run: pip install -r requirements.txt | ||
- run: | | ||
pip install black | ||
black . --check | ||
if: matrix.python-version == '3.12' | ||
- run: | | ||
pip install pytest | ||
pytest | ||
- run: python setup.py test | ||
if: matrix.python-version != '3.12' && matrix.python-version != 'latest' | ||
|
||
build-pypy: | ||
name: Build PyPy | ||
strategy: | ||
matrix: | ||
python-version: [2.7, 3.6, 3.9, "3.10"] | ||
runs-on: ubuntu-latest | ||
container: pypy:${{ matrix.python-version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: pypy --version | ||
- run: pip install -r requirements.txt | ||
- run: | | ||
pip install black | ||
black . --check | ||
if: matrix.python-version == '3.12' | ||
- run: | | ||
pip install pytest | ||
pytest | ||
- run: pypy setup.py test | ||
if: matrix.python-version != '3.12' && matrix.python-version != 'latest' |
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,15 @@ | ||
*.pyc | ||
*.debug | ||
|
||
session.shelve* | ||
|
||
.DS_Store | ||
|
||
/.vscode/settings.json | ||
|
||
/.env | ||
/.venv | ||
|
||
/dist | ||
/build | ||
/src/colony_print_api.egg-info |
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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>colony-print-api</name> | ||
<comment></comment> | ||
<projects> | ||
<project>appier</project> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.python.pydev.PyDevBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.python.pydev.pythonNature</nature> | ||
</natures> | ||
</projectDescription> |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?eclipse-pydev version="1.0"?><pydev_project> | ||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | ||
<path>/${PROJECT_DIR_NAME}/src</path> | ||
</pydev_pathproperty> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.6</pydev_property> | ||
</pydev_project> |
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 @@ | ||
eclipse.preferences.version=1 | ||
encoding/<project>=utf-8 |
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,33 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
### Added | ||
|
||
* | ||
|
||
### Changed | ||
|
||
* | ||
|
||
### Fixed | ||
|
||
* | ||
|
||
## [0.2.1] - 2024-04-30 | ||
|
||
### Changed | ||
|
||
* Direct inclusion of pyi files in `setup.py` | ||
|
||
## [0.2.0] - 2024-04-20 | ||
|
||
### Changed | ||
|
||
* Sanitization of the code structure, making compliant with `black` | ||
* Improved support for type hints |
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,2 +1,3 @@ | ||
# colony-print-api | ||
Python API client for Colony Print | ||
# Colony Print API | ||
|
||
Python API client for Colony 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
python_files = *.py | ||
testpaths = src/colony_print/test |
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 @@ | ||
appier |
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 @@ | ||
[bdist_wheel] | ||
universal = 1 |
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,47 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import setuptools | ||
|
||
setuptools.setup( | ||
name="colony-print-api", | ||
version="0.1.0", | ||
author="Hive Solutions Lda.", | ||
author_email="development@hive.pt", | ||
description="Colony Print API Client", | ||
license="Apache License, Version 2.0", | ||
keywords="colony-print api", | ||
url="http://colony-print-api.hive.pt", | ||
zip_safe=False, | ||
packages=["colony_print"], | ||
test_suite="colony_print.test", | ||
package_dir={"": os.path.normpath("src")}, | ||
package_data={"colony_print": ["*.pyi"]}, | ||
install_requires=["appier"], | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", | ||
"Topic :: Utilities", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 2.6", | ||
"Programming Language :: Python :: 2.7", | ||
"Programming Language :: Python :: 3.0", | ||
"Programming Language :: Python :: 3.1", | ||
"Programming Language :: Python :: 3.2", | ||
"Programming Language :: Python :: 3.3", | ||
"Programming Language :: Python :: 3.4", | ||
"Programming Language :: Python :: 3.5", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
], | ||
long_description=open(os.path.join(os.path.dirname(__file__), "README.md"), "rb") | ||
.read() | ||
.decode("utf-8"), | ||
long_description_content_type="text/markdown", | ||
) |
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 -*- | ||
|
||
from . import base | ||
|
||
from .base import BASE_URL, API, Attachment, AttachmentPayload, Message, MessagePayload |
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,64 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
import appier | ||
|
||
BASE_URL = "https://print.bemisc.com/api/" | ||
""" The default base URL to be used when no other | ||
base URL value is provided to the constructor """ | ||
|
||
|
||
class API(appier.API): | ||
""" | ||
Implementation of the Colony Print API specification | ||
for a simplified python client usage. | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
appier.API.__init__(self, *args, **kwargs) | ||
self.base_url = appier.conf("PRINT_BASE_URL", BASE_URL) | ||
self.key = appier.conf("PRINT_KEY", None) | ||
self.base_url = kwargs.get("base_url", self.base_url) | ||
self.key = appier.conf("key", self.key) | ||
|
||
def build( | ||
self, | ||
method, | ||
url, | ||
data=None, | ||
data_j=None, | ||
data_m=None, | ||
headers=None, | ||
params=None, | ||
mime=None, | ||
kwargs=None, | ||
): | ||
auth = kwargs.pop("auth", True) | ||
if auth and self.key: | ||
headers["X-Secret-Key"] = self.key | ||
|
||
def ping(self): | ||
url = self.base_url + "ping" | ||
contents = self.get(url, auth=False) | ||
return contents | ||
|
||
def send(self, payload): | ||
url = self.base_url + "send" | ||
contents = self.post(url, data_j=payload) | ||
return contents | ||
|
||
|
||
class Attachment(dict): | ||
pass | ||
|
||
|
||
class AttachmentPayload(dict): | ||
pass | ||
|
||
|
||
class Message(dict): | ||
pass | ||
|
||
|
||
class MessagePayload(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,58 @@ | ||
from typing import NotRequired, Sequence, 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 | ||
|
||
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 | ||
|
||
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 API(BaseAPI): | ||
def send(self, payload: MessagePayload) -> Message: ... |
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 -*- | ||
|
||
from . import sender | ||
|
||
from .sender import send |
Oops, something went wrong.