diff --git a/.github/ISSUES_TEMPLATE.md b/.github/ISSUES_TEMPLATE.md new file mode 100644 index 0000000..9b1ff08 --- /dev/null +++ b/.github/ISSUES_TEMPLATE.md @@ -0,0 +1,25 @@ +### Description + +[Description of the issue] + +### Steps to Reproduce + +1. [First Step] +2. [Second Step] +3. [and so on...] + +**Expected behavior:** [What you expect to happen] + +**Actual behavior:** [What actually happens] + +**Reproduces how often:** [What percentage of the time does it reproduce?] + +### Versions + +You can get this information from copy and pasting the output of the package.json in the root directory of the internetmarke package or on the command line from your project root with `npm list --pattern internetmarke` or `yarn list --pattern internetmarke`. + +Please also add the version of node you are using with `node --version`. + +### Additional Information + +Any additional information, configuration or data that might be necessary to reproduce the issue. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..da58ffa --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,46 @@ +### Requirements + +* Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. +* All new code requires tests to ensure against regressions + +### Description of the Change + + + +### Alternate Designs + + + +### Why Should This Be In Core? + + + +### Benefits + + + +### Possible Drawbacks + + + +### Verification Process + + + +### Applicable Issues + + diff --git a/lib/Internetmarke.js b/lib/Internetmarke.js index e83b306..e3a0d5c 100644 --- a/lib/Internetmarke.js +++ b/lib/Internetmarke.js @@ -98,7 +98,7 @@ class Internetmarke { * @returns {Promise.} - The shopping cart with the link to the zip * archive, the order id and the coucher ids. */ - checkout({ orderId = null } = {}) { + checkout({ orderId = null, outputFormat = null } = {}) { let order = this._order.getCheckout({ orderId }); if (order.total > this[_USER].getBalance()) { @@ -108,7 +108,24 @@ class Internetmarke { return this._1C4AService.checkout({ order, user: this[_USER], - outputFormat: this._config.outputFormat + outputFormat: outputFormat || this._config.outputFormat, + }); + } + + /** + * Retrieve an existing order. + * + * @param {Object} options + * @param {number} [options.orderId] - Shopping cart number of the INTERNETMARKE shop + * @returns {Promise.} - The shopping cart with the link to the zip + * archive, the order id and the voucher ids. + */ + retrieveOrder({ orderId = null } = {}) { + let order = { shopOrderId: orderId }; + + return this._1C4AService.retrieveOrder({ + order, + user: this[_USER], }); } @@ -131,6 +148,8 @@ class Internetmarke { }); } + + /** * Enables the product service to make use of the product database at checkout. * diff --git a/lib/Service/Soap/OneClickForApp.js b/lib/Service/Soap/OneClickForApp.js index 2e031f0..094a86c 100644 --- a/lib/Service/Soap/OneClickForApp.js +++ b/lib/Service/Soap/OneClickForApp.js @@ -92,7 +92,6 @@ class OneClickForAppService extends SoapService { return this._getSoapClient() .then(client => { const method = `checkoutShoppingCart${outputFormat}Async`; - order = Object.assign({ userToken: this._user.getToken() }, order); @@ -120,6 +119,40 @@ class OneClickForAppService extends SoapService { }); } + /** + * Performs a checkout and retrieves the ordered vouchers. + * + * @param {Object} data + * @param {Object} data.order - The order information that hold the data about + * the vouchers. + * @returns {Promise.} + */ + retrieveOrder({ order }) { + return this._getSoapClient() + .then(client => { + order = Object.assign({ + userToken: this._user.getToken(), + }, order); + return client.retrieveOrderAsync(order); + }) + .then(response => { + const result = { + orderId: response.shoppingCart.shopOrderId, + link: response.link, + vouchers: [] + }; + + response.shoppingCart.voucherList.voucher.forEach(voucher => { + const data = { id: voucher.voucherId }; + if (voucher.trackId) { + data.trackingCode = voucher.trackId; + } + result.vouchers.push(data); + }); + return result; + }); + } + /** * Create a globally unique order id from the api. *