From a01edb73e9d043ebdf9073dd04e615e6c91236a5 Mon Sep 17 00:00:00 2001 From: Gerwin Brunner Date: Thu, 22 Mar 2018 11:43:10 +0100 Subject: [PATCH 1/5] added retrieveOrder functionality --- lib/Internetmarke.js | 23 ++++++++++++++-- lib/Service/Soap/OneClickForApp.js | 42 ++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/lib/Internetmarke.js b/lib/Internetmarke.js index 92e15dc..710ab4d 100644 --- a/lib/Internetmarke.js +++ b/lib/Internetmarke.js @@ -92,7 +92,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()) { @@ -102,7 +102,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], }); } @@ -125,6 +142,8 @@ class Internetmarke { }); } + + /** * Update galleries (public and private) and save results locally. * diff --git a/lib/Service/Soap/OneClickForApp.js b/lib/Service/Soap/OneClickForApp.js index 5e5c6bc..4b04d2c 100644 --- a/lib/Service/Soap/OneClickForApp.js +++ b/lib/Service/Soap/OneClickForApp.js @@ -92,14 +92,18 @@ class OneClickForAppService extends SoapService { return this._getSoapClient() .then(client => { const method = `checkoutShoppingCart${outputFormat}Async`; - + console.log( 'checkout ', order); order = Object.assign({ - userToken: this._user.getToken() + userToken: this._user.getToken(), + pageFormatId: 1, }, order); return client[method](order); }) .then(response => { + // console.log(' *** '); + // console.log(' response', JSON.stringify(response)); + // console.log(' *** '); this._user.setBalance(response.walletBallance || response.walletBalance); const result = { @@ -120,6 +124,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. * From 12a7f383db819a42c0d18139250b2233a07fad04 Mon Sep 17 00:00:00 2001 From: Gerwin Brunner Date: Thu, 22 Mar 2018 11:47:05 +0100 Subject: [PATCH 2/5] removed changes of PDF generation fix --- lib/Internetmarke.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Internetmarke.js b/lib/Internetmarke.js index 710ab4d..ff317b0 100644 --- a/lib/Internetmarke.js +++ b/lib/Internetmarke.js @@ -92,7 +92,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, outputFormat = null } = {}) { + checkout({ orderId = null } = {}) { let order = this._order.getCheckout({ orderId }); if (order.total > this[_USER].getBalance()) { @@ -102,7 +102,7 @@ class Internetmarke { return this._1C4AService.checkout({ order, user: this[_USER], - outputFormat: outputFormat || this._config.outputFormat, + outputFormat: this._config.outputFormat, }); } From 07862db67cc5fc95c531578706c0aad3972e9328 Mon Sep 17 00:00:00 2001 From: Gerwin Brunner Date: Thu, 22 Mar 2018 11:52:47 +0100 Subject: [PATCH 3/5] another rollback --- lib/Internetmarke.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Internetmarke.js b/lib/Internetmarke.js index ff317b0..710ab4d 100644 --- a/lib/Internetmarke.js +++ b/lib/Internetmarke.js @@ -92,7 +92,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()) { @@ -102,7 +102,7 @@ class Internetmarke { return this._1C4AService.checkout({ order, user: this[_USER], - outputFormat: this._config.outputFormat, + outputFormat: outputFormat || this._config.outputFormat, }); } From 37d081f92ff005caba0a102b7b6fba96ae67225e Mon Sep 17 00:00:00 2001 From: Gerwin Brunner Date: Thu, 22 Mar 2018 11:55:01 +0100 Subject: [PATCH 4/5] more removeal... --- lib/Service/Soap/OneClickForApp.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/Service/Soap/OneClickForApp.js b/lib/Service/Soap/OneClickForApp.js index 4b04d2c..ffd3d96 100644 --- a/lib/Service/Soap/OneClickForApp.js +++ b/lib/Service/Soap/OneClickForApp.js @@ -92,18 +92,13 @@ class OneClickForAppService extends SoapService { return this._getSoapClient() .then(client => { const method = `checkoutShoppingCart${outputFormat}Async`; - console.log( 'checkout ', order); order = Object.assign({ - userToken: this._user.getToken(), - pageFormatId: 1, + userToken: this._user.getToken() }, order); return client[method](order); }) .then(response => { - // console.log(' *** '); - // console.log(' response', JSON.stringify(response)); - // console.log(' *** '); this._user.setBalance(response.walletBallance || response.walletBalance); const result = { From e1922bed6e5d49d42e61be6d1143f24cd5848f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Sch=C3=A4chinger?= Date: Sat, 24 Mar 2018 18:23:48 +0100 Subject: [PATCH 5/5] added templates for issues and pull requests --- .github/ISSUES_TEMPLATE.md | 25 ++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 46 ++++++++++++++++++++++++++++++ lib/Service/Soap/OneClickForApp.js | 2 +- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUES_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md 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/Service/Soap/OneClickForApp.js b/lib/Service/Soap/OneClickForApp.js index ffd3d96..6d6b816 100644 --- a/lib/Service/Soap/OneClickForApp.js +++ b/lib/Service/Soap/OneClickForApp.js @@ -119,7 +119,7 @@ class OneClickForAppService extends SoapService { }); } - /** + /** * Performs a checkout and retrieves the ordered vouchers. * * @param {Object} data