All Projects → gido → postcardcreator

gido / postcardcreator

Licence: MIT license
A node.js API for the Swiss Post Postcard Creator

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to postcardcreator

matsim-sbb-extensions
matsim swiss rail
Stars: ✭ 23 (-41.03%)
Mutual labels:  swiss
obp-apis
OpenBankingProject.ch Community APIs
Stars: ✭ 18 (-53.85%)
Mutual labels:  swiss
ProtonClient
An unofficial desktop client for ProtonMail done with electron nativefier
Stars: ✭ 50 (+28.21%)
Mutual labels:  swiss
tourney-bot
an app to run the Houston Ultimate Indoor Tournament
Stars: ✭ 16 (-58.97%)
Mutual labels:  swiss
open-data-smn
An API to serve publicly available data from the SwissMetNet in 10min intervals
Stars: ✭ 23 (-41.03%)
Mutual labels:  swiss
SwissDataCube
Swiss Data Cube repository
Stars: ✭ 11 (-71.79%)
Mutual labels:  swiss

Postcard Creator API Build Status

A node.js API for the Swiss Post Postcard Creator.

Basic usage

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].