https://github.com/gido/postcardcreator
A node.js API for the Swiss Post Postcard Creator
https://github.com/gido/postcardcreator
javascript nodejs postcard swiss
Last synced: about 1 year ago
JSON representation
A node.js API for the Swiss Post Postcard Creator
- Host: GitHub
- URL: https://github.com/gido/postcardcreator
- Owner: gido
- License: mit
- Created: 2015-05-14T14:39:37.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-07-14T14:52:46.000Z (almost 8 years ago)
- Last Synced: 2025-06-04T11:36:39.982Z (about 1 year ago)
- Topics: javascript, nodejs, postcard, swiss
- Language: JavaScript
- Size: 44.9 KB
- Stars: 40
- Watchers: 4
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Postcard Creator API [](https://travis-ci.org/gido/postcardcreator)
A node.js API for the [Swiss Post Postcard Creator](http://postcardcreator.post.ch).
# Basic usage
```javascript
var path = require('path'),
Postcardcreator = require('postcardcreator'),
SSOHelper = require('postcardcreator/helper/SSOPostHelper')(),
Postcard = Postcardcreator.Postcard;
SSOHelper.getPostcardcreatorToken(postcard_user, postcard_pass, function(err, data) {
if (err) {
console.error(err);
return;
}
var client = new Postcardcreator(data.token);
var message = "Hello, here is a picture of me. Best!";
var assetStream = fs.createReadStream(path.join(__dirname, 'me_under_the_sun.jpg'));
// here is my real address you can use it to send me picture of your works ;-)
var recipient = {
salutation: "Monsieur",
givenName: "Gilles",
familyName: "Doge",
company: "Antistatique.net",
street: "Rue de Sébeillon 9b",
postCode: "1004",
place: "Lausanne"
};
var postcard = new Postcard(assetStream, message, recipient);
client.sendPostcard(postcard, function(err, result) {
if (err) {
console.log("Error when sending the postcard. ", err);
handleError(err);
return;
}
console.log("Postcard sent with success !");
console.log(result);
});
});
```
# License
MIT
# Related projects
- [abertschi/postcard_creator_wrapper](https://github.com/abertschi/postcard_creator_wrapper) - Python wrapper around the Rest API of the Swiss Postcard Creator