A python wrapper around the Rest API of the Swiss Postcard creator.
$ pip install postcard-creatorfrom postcard_creator.postcard_creator import PostcardCreator
w = PostcardCreator(token)
w.get_user_info()
w.get_billing_saldo()
w.get_quota()
w.has_free_postcard()
w.send_free_card(postcard=)from postcard_creator.postcard_creator import PostcardCreator, Postcard, Token, Recipient, Sender
token = Token()
token.fetch_token(username='', password='')
token.has_valid_credentials(username='', password='')
recipient = Recipient(prename='', lastname='', street='', place='', zip_code=0000)
sender = Sender(prename='', lastname='', street='', place='', zip_code=0000)
card = Postcard(message='', recipient=recipient, sender=sender, picture_stream=open('./my-photo.jpg', 'rb'))
w = PostcardCreator(token)
w.send_free_card(postcard=card, mock_send=False)The following keyword arguments are available for advanced configuration (listed with corresponding defaults).
PostcardCreator#send_free_card():
image_export = False: Export postcard image to current directory (os.getcwd)image_rotate = True: Rotate image if image height > image widthimage_quality_factor = 20: Change picture quality, resulting image hasimage_quality_factor x (image_target_width x image_target_height)many pixelsimage_target_width = 154: Postcard image base widthimage_target_height = 111: Postcard image base height
Token#fetch_token():
method = 'mixed': Choose what authentication to use.['mixed', 'legacy', 'swissid'].'mixed'tries both.
import logging
logger = logging.getLogger('postcard_creator')
# log levels
# 5: trace
# 10: debug
# 20: info
# 30: warningpip install -r requirements-dev.txt
pip install -e .
pytest- postcards - A CLI for the Swiss Postcard Creator
- postcardcreator - node.js API for the Swiss Post Postcard Creator
- support for swissid authentication
- Method
Token#has_valid_credentialsandToken#fetch_tokenintroduce a parametermethodwhich can be set to one of these vals:['mixed', 'legacy', 'swissid'].'mixed'is default and tries both authentication procedures
- Migrate to postcardcreator API 2.2
- Fix issues with PNG images #6
- internal changes
- do not use requirements.txt in setup.py anymore. set all requirements in install_requires without explicit version numbers
Andrin Bertschi
https://twitter.com/andrinbertschi
<3