Skip to content

Commit

Permalink
added product list support to the voucher preview, added preview to t…
Browse files Browse the repository at this point in the history
…he readme
  • Loading branch information
schaechinger committed Mar 25, 2018
1 parent 6c8f78e commit a8fa219
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To use the module you have to request a partner account from Deutsche Post for e

* **1C4A** (One Click For Application, required!) is used to order vouchers.

You can get the partner account from the german website of [Deutsche Post][post-1c4a] or via mail: pcf-1click@deutschepost.de
You can get the partner account from the website of [Deutsche Post][post-1c4a] or via mail: pcf-1click@deutschepost.de

* **Prod WS** (Product List Web Service) is used to retrieve the list of available products (the distinct types of stamps for different dimensions etc.). This is optional if you know the ids and prices of the vouchers you want to order.

Expand Down Expand Up @@ -133,6 +133,19 @@ internetmarke.orderVoucher({ product });

If you do not have a product from the product service you can use `productCode` and `price` instead to order a voucher.

#### Voucher preview

You can create a preview voucher before checkout.

```javascript
internetmarke.getVoucherPreview({ product })
.then({ link } => {
// link to the deutsche post service that contains the preview image for the product
});
```

Of course you can also use `productCode` instead of the `product` here.


### Checkout

Expand Down
8 changes: 5 additions & 3 deletions lib/Internetmarke.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ class Internetmarke {
* Generate a preview of a voucher.
*
* @param {Object} preview
* @param {number} preview.productCode - The product code as defined from
* the API.
* @param {Product} [preview.product] - The product that should be previewed.
* @param {number} [preview.productCode] - The product code as defined from
* the API if no product was given.
* @param {number} [preview.imageId] - The id of the image that should be
* printed next to the voucher.
* @returns {Promise.<Object>} - The url of the preview voucher.
*/
getVoucherPreview({ productCode, imageId = null }) {
getVoucherPreview({ product = null, productCode = 0, imageId = null }) {
return this._1C4AService.previewVoucher({
product,
productCode,
imageId,
voucherLayout: this._config.voucherLayout,
Expand Down
11 changes: 8 additions & 3 deletions lib/Service/Soap/OneClickForApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,20 @@ class OneClickForAppService extends SoapService {
* Generates a preview what the voucher will look like.
*
* @param {Object} config
* @param {number} config.productCode - The id of the product that should be
* previewed.
* @param {Product} config.product - The product that should be previewed.
* @param {number} [config.productCode] - The id of the product that should be
* previewed if no product was given.
* @param {string} config.voucherLayout - The layout of the voucher.
* @param {string} config.outputFormat - The format the voucher should have.
* @returns {Promise.<Object>}
*/
previewVoucher({ productCode, voucherLayout, outputFormat }) {
previewVoucher({ product, productCode = 0, voucherLayout, outputFormat }) {
const method = `retrievePreviewVoucher${outputFormat}Async`;

if (product) {
productCode = product.getId();
}

return this._getSoapClient()
.then(client => {
return client[method]({
Expand Down

0 comments on commit a8fa219

Please sign in to comment.