{"id":22415106,"url":"https://github.com/abertschi/postcard_creator_wrapper","last_synced_at":"2025-08-01T00:32:05.721Z","repository":{"id":48874826,"uuid":"93338209","full_name":"abertschi/postcard_creator_wrapper","owner":"abertschi","description":"A python wrapper around the Rest API of the Swiss Postcard creator :postbox:","archived":false,"fork":false,"pushed_at":"2023-11-29T14:19:21.000Z","size":1218,"stargazers_count":52,"open_issues_count":6,"forks_count":10,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-19T03:27:54.283Z","etag":null,"topics":["postcard","python","python-wrapper","rest-api"],"latest_commit_sha":null,"homepage":"https://abertschi.ch/blog/2022/receiving-postcards/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abertschi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-04T20:01:56.000Z","updated_at":"2024-04-23T11:04:09.000Z","dependencies_parsed_at":"2023-11-29T15:42:58.962Z","dependency_job_id":null,"html_url":"https://github.com/abertschi/postcard_creator_wrapper","commit_stats":{"total_commits":181,"total_committers":9,"mean_commits":20.11111111111111,"dds":0.5469613259668509,"last_synced_commit":"f9bea24fc50920235e7fb85f3e9606414fdee34b"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abertschi%2Fpostcard_creator_wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abertschi%2Fpostcard_creator_wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abertschi%2Fpostcard_creator_wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abertschi%2Fpostcard_creator_wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abertschi","download_url":"https://codeload.github.com/abertschi/postcard_creator_wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228321331,"owners_count":17901604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postcard","python","python-wrapper","rest-api"],"created_at":"2024-12-05T15:11:11.442Z","updated_at":"2024-12-05T15:11:12.335Z","avatar_url":"https://github.com/abertschi.png","language":"Python","funding_links":[],"categories":["Dienstprogramme \u0026 Services"],"sub_categories":["Daten \u0026 Grenzen"],"readme":"# Postcard Creator \n\n[![PyPI version](https://img.shields.io/pypi/v/postcard_creator.svg)](https://badge.fury.io/py/postcard_creator) [![codecov](https://codecov.io/gh/abertschi/postcard_creator_wrapper/branch/master/graph/badge.svg)](https://codecov.io/gh/abertschi/postcard_creator_wrapper) [![PyPI version](https://img.shields.io/pypi/pyversions/postcard_creator.svg)](https://pypi.python.org/pypi/postcard_creator) [![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)\n\nA python wrapper around the Rest API of the Swiss Postcard creator.\n\n## Installation\n```sh\n# requires python 3.6 or later\n$ pip install postcard-creator\n```\n\n## Setup / API Usage\n\n```python\nfrom postcard_creator.postcard_creator import PostcardCreator\n\nw = PostcardCreator(token)\nw.get_quota()\nw.get_user_info()\nw.get_billing_saldo()\nw.has_free_postcard()\nw.send_free_card(postcard=)\n```\n\n## Usage\nLog in with your [SwissID](https://www.swissid.ch/) credentials. Note that 2-factor authentication is not supported (See https://github.com/abertschi/postcard_creator_wrapper/issues/40#issuecomment-1485362680).\n\n```python\nfrom postcard_creator.postcard_creator import PostcardCreator, Postcard, Token, Recipient, Sender\n\ntoken = Token()\ntoken.fetch_token(username='', password='')\ntoken.has_valid_credentials(username='', password='')\nrecipient = Recipient(prename='', lastname='', street='', place='', zip_code=0000)\nsender = Sender(prename='', lastname='', street='', place='', zip_code=0000)\ncard = Postcard(message='', recipient=recipient, sender=sender, picture_stream=open('./my-photo.jpg', 'rb'))\n\nw = PostcardCreator(token)\nw.send_free_card(postcard=card, mock_send=False, image_export=False)\n```\n\n### Advanced configuration\nThe following keyword arguments are available for advanced configuration.\n\n**PostcardCreator#send_free_card()**:\n- `image_export=False`: Export postcard image to current directory (os.getcwd)\n- `mock_send=False`: Do not submit order (testing)\n- `fallback_color_fill=False`: On False: If image is too small, force upscale to\n   match postcard aspect ration (background-size: contain), on True: fallback to\n   color fill mode where image is centered and border is filled with most\n   dominant color found in image.\n\n### Logging\n```python\nimport logging\n\nlogger = logging.getLogger('postcard_creator')\n\n# log levels\n# 5: trace\n# 10: debug\n# 20: info\n# 30: warning\n```\n\n## Example\n- [Postcards](https://github.com/abertschi/postcards) is a commandline interface built around this library.\n- See [postcard-love](https://github.com/abertschi/postcard-love) for more usage examples.\n\n## Test\n```sh\npip install -r requirements.txt\npip install -r requirements-dev.txt\npip install -e .\npytest\n```\n\n## Related\n- [postcards](https://github.com/abertschi/postcards) - A CLI for the Swiss Postcard Creator\n- [postcardcreator](https://github.com/gido/postcardcreator) - node.js API for the Swiss Post Postcard Creator\n\n## Release notes\n### 2.4, 2023-08-12\n- add fallback_color_fill parameter in send_free_card() \n### v2.3, 2022-09-30\n- changes in internals of swissid token authentication due to introduction of anomaly-detection #41\n\n### v2.2, 2021-07-07\n- drop support for postcard_creator_legacy\n- update legacy (username/ password) token authentication due to changed endpoints\n  - note: legacy method now uses postcard_creator_swissid endpoints instead of postcard_creator_legacy, postcard_creator_legacy is out of life\n  \n### v2.1, 2021-05-16\n- update requests to v2.25.1 to fix \"AttributeError: 'NoneType' object has no attribute 'group'\" in authentication. #27\n\n### v2.0, 2021-02\n- support of new swissid authentication (access_token with code/ code_verifier)\n- support of new endpoints at https://pccweb.api.post.ch/secure/api/mobile/v1\n- class PostcardCreator is a proxy which instantiates an endpoint wrapper compatible with authentication method of token, underlying wrappers are: PostcardCreatorSwissId, PostcardCreatorLegacy \n- migration to v2.0\n  + with authentication method swissid: if you rely on get_billing_saldo(), get_user_info(): these endpoints return data in different format\n  + customizations image_target_width, image_target_height, image_quality_factor no longer compatible with authentication method swissid\n- require python 3.6 or later\n\n### v1.1, 2020-01-30\n- support for swissid authentication\n- Method `Token#has_valid_credentials` and `Token#fetch_token` introduce a parameter `method` \n  which can be set to one of these vals: `['mixed', 'legacy', 'swissid']`. `'mixed'` is default and tries both\n  authentication procedures \n\n### v0.0.8, 2018-03-28\n- Migrate to postcardcreator API 2.2\n\n### v0.0.7, 2017-12-28\n- Fix issues with PNG images [#6](https://github.com/abertschi/postcard_creator_wrapper/pull/6)\n\n### v0.0.6, 2017-11-22\n- internal changes\n- do not use requirements.txt in setup.py anymore. set all requirements in \ninstall_requires without explicit version numbers\n\n## Troubleshooting\n\n#### “The headers or library files could not be found for jpeg”\n`pip install` fails with the above error. Install libjpeg as discussed here\nhttps://stackoverflow.com/questions/44043906/the-headers-or-library-files-could-not-be-found-for-jpeg-installing-pillow-on\n\n#### \"AttributeError: 'FreeTypeFont' object has no attribute 'getsize'\"\npip install Pillow==9.5.0\n\n## Author\n\nAndrin Bertschi  \n[https://twitter.com/andrinbertschi](https://twitter.com/andrinbertschi)\n\n## License\n\n[Apache License 2.0](LICENSE.md)\n\n\u003c3\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabertschi%2Fpostcard_creator_wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabertschi%2Fpostcard_creator_wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabertschi%2Fpostcard_creator_wrapper/lists"}