From 5ff314712443c4c8465f46292b010cfedfed8c2e Mon Sep 17 00:00:00 2001 From: anandsahil Date: Thu, 1 Aug 2019 14:00:07 +0200 Subject: [PATCH 1/2] add new order type XZ53 and removed repeated dateRange to consts --- lib/consts.js | 13 +++++++++++++ lib/predefinedOrders/HAC.js | 14 ++------------ lib/predefinedOrders/PTK.js | 14 ++------------ lib/predefinedOrders/STA.js | 14 ++------------ lib/predefinedOrders/VMK.js | 14 ++------------ lib/predefinedOrders/Z53.js | 13 +++++++++++++ lib/predefinedOrders/index.js | 2 ++ 7 files changed, 36 insertions(+), 48 deletions(-) create mode 100644 lib/predefinedOrders/Z53.js diff --git a/lib/consts.js b/lib/consts.js index 293287c..ebd1219 100644 --- a/lib/consts.js +++ b/lib/consts.js @@ -10,9 +10,22 @@ const orderOperations = { download: 'DOWNLOAD', }; +const dateRange = (start, end) => { + if (start && end) + return { + DateRange: { + Start: start, + End: end, + }, + }; + + return {}; +}; + module.exports = { name, version, orderOperations, productString: `${name} ${version}`, + dateRange, }; diff --git a/lib/predefinedOrders/HAC.js b/lib/predefinedOrders/HAC.js index 7700379..dcf86b5 100644 --- a/lib/predefinedOrders/HAC.js +++ b/lib/predefinedOrders/HAC.js @@ -1,23 +1,13 @@ 'use strict'; -const dateRange = (start, end) => { - if (start && end) - return { - DateRange: { - Start: start, - End: end, - }, - }; - - return {}; -}; +const utils = require('../consts'); module.exports = (start = null, end = null) => ({ version: 'h004', orderDetails: { OrderType: 'HAC', OrderAttribute: 'DZHNN', - StandardOrderParams: dateRange(start, end), + StandardOrderParams: utils.dateRange(start, end), }, operation: 'download', }); diff --git a/lib/predefinedOrders/PTK.js b/lib/predefinedOrders/PTK.js index 37d5667..38ad1c5 100644 --- a/lib/predefinedOrders/PTK.js +++ b/lib/predefinedOrders/PTK.js @@ -1,23 +1,13 @@ 'use strict'; -const dateRange = (start, end) => { - if (start && end) - return { - DateRange: { - Start: start, - End: end, - }, - }; - - return {}; -}; +const utils = require('../consts'); module.exports = (start = null, end = null) => ({ version: 'h004', orderDetails: { OrderType: 'PTK', OrderAttribute: 'DZHNN', - StandardOrderParams: dateRange(start, end), + StandardOrderParams: utils.dateRange(start, end), }, operation: 'download', }); diff --git a/lib/predefinedOrders/STA.js b/lib/predefinedOrders/STA.js index 1a0b39e..039353a 100644 --- a/lib/predefinedOrders/STA.js +++ b/lib/predefinedOrders/STA.js @@ -1,23 +1,13 @@ 'use strict'; -const dateRange = (start, end) => { - if (start && end) - return { - DateRange: { - Start: start, - End: end, - }, - }; - - return {}; -}; +const utils = require('../consts'); module.exports = (start = null, end = null) => ({ version: 'h004', orderDetails: { OrderType: 'STA', OrderAttribute: 'DZHNN', - StandardOrderParams: dateRange(start, end), + StandardOrderParams: utils.dateRange(start, end), }, operation: 'download', }); diff --git a/lib/predefinedOrders/VMK.js b/lib/predefinedOrders/VMK.js index e2bcc9b..e525e56 100644 --- a/lib/predefinedOrders/VMK.js +++ b/lib/predefinedOrders/VMK.js @@ -1,23 +1,13 @@ 'use strict'; -const dateRange = (start, end) => { - if (start && end) - return { - DateRange: { - Start: start, - End: end, - }, - }; - - return {}; -}; +const utils = require('../consts'); module.exports = (start = null, end = null) => ({ version: 'h004', orderDetails: { OrderType: 'VMK', OrderAttribute: 'DZHNN', - StandardOrderParams: dateRange(start, end), + StandardOrderParams: utils.dateRange(start, end), }, operation: 'download', }); diff --git a/lib/predefinedOrders/Z53.js b/lib/predefinedOrders/Z53.js new file mode 100644 index 0000000..9d877d1 --- /dev/null +++ b/lib/predefinedOrders/Z53.js @@ -0,0 +1,13 @@ +'use strict'; + +const utils = require('../consts'); + +module.exports = (start = null, end = null) => ({ + version: 'h004', + orderDetails: { + OrderType: 'Z53', + OrderAttribute: 'DZHNN', + StandardOrderParams: utils.dateRange(start, end), + }, + operation: 'download', +}); diff --git a/lib/predefinedOrders/index.js b/lib/predefinedOrders/index.js index 6109796..18e4f49 100644 --- a/lib/predefinedOrders/index.js +++ b/lib/predefinedOrders/index.js @@ -22,11 +22,13 @@ const HPD = require('./HPD'); const HKD = require('./HKD'); const PTK = require('./PTK'); const HAC = require('./HAC'); +const Z53 = require('./Z53'); module.exports = { INI, HIA, HPB, + Z53, AZV, CD1, From aa761cf7ad87a271d6e6d9eed40e04eb4376f6c5 Mon Sep 17 00:00:00 2001 From: anandsahil Date: Thu, 1 Aug 2019 14:14:30 +0200 Subject: [PATCH 2/2] move dateRange from constants to utils --- lib/consts.js | 13 ------------- lib/predefinedOrders/HAC.js | 2 +- lib/predefinedOrders/PTK.js | 2 +- lib/predefinedOrders/STA.js | 2 +- lib/predefinedOrders/VMK.js | 2 +- lib/predefinedOrders/Z53.js | 2 +- lib/utils.js | 18 ++++++++++++++++++ 7 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 lib/utils.js diff --git a/lib/consts.js b/lib/consts.js index ebd1219..293287c 100644 --- a/lib/consts.js +++ b/lib/consts.js @@ -10,22 +10,9 @@ const orderOperations = { download: 'DOWNLOAD', }; -const dateRange = (start, end) => { - if (start && end) - return { - DateRange: { - Start: start, - End: end, - }, - }; - - return {}; -}; - module.exports = { name, version, orderOperations, productString: `${name} ${version}`, - dateRange, }; diff --git a/lib/predefinedOrders/HAC.js b/lib/predefinedOrders/HAC.js index dcf86b5..82f8f58 100644 --- a/lib/predefinedOrders/HAC.js +++ b/lib/predefinedOrders/HAC.js @@ -1,6 +1,6 @@ 'use strict'; -const utils = require('../consts'); +const utils = require('../utils'); module.exports = (start = null, end = null) => ({ version: 'h004', diff --git a/lib/predefinedOrders/PTK.js b/lib/predefinedOrders/PTK.js index 38ad1c5..a0b7e77 100644 --- a/lib/predefinedOrders/PTK.js +++ b/lib/predefinedOrders/PTK.js @@ -1,6 +1,6 @@ 'use strict'; -const utils = require('../consts'); +const utils = require('../utils'); module.exports = (start = null, end = null) => ({ version: 'h004', diff --git a/lib/predefinedOrders/STA.js b/lib/predefinedOrders/STA.js index 039353a..4eb44e9 100644 --- a/lib/predefinedOrders/STA.js +++ b/lib/predefinedOrders/STA.js @@ -1,6 +1,6 @@ 'use strict'; -const utils = require('../consts'); +const utils = require('../utils'); module.exports = (start = null, end = null) => ({ version: 'h004', diff --git a/lib/predefinedOrders/VMK.js b/lib/predefinedOrders/VMK.js index e525e56..315af09 100644 --- a/lib/predefinedOrders/VMK.js +++ b/lib/predefinedOrders/VMK.js @@ -1,6 +1,6 @@ 'use strict'; -const utils = require('../consts'); +const utils = require('../utils'); module.exports = (start = null, end = null) => ({ version: 'h004', diff --git a/lib/predefinedOrders/Z53.js b/lib/predefinedOrders/Z53.js index 9d877d1..d196841 100644 --- a/lib/predefinedOrders/Z53.js +++ b/lib/predefinedOrders/Z53.js @@ -1,6 +1,6 @@ 'use strict'; -const utils = require('../consts'); +const utils = require('../utils'); module.exports = (start = null, end = null) => ({ version: 'h004', diff --git a/lib/utils.js b/lib/utils.js new file mode 100644 index 0000000..3390ead --- /dev/null +++ b/lib/utils.js @@ -0,0 +1,18 @@ +'use strict'; + +const dateRange = (start, end) => { + if (start && end) + return { + DateRange: { + Start: start, + End: end, + }, + }; + + return {}; +}; + + +module.exports = { + dateRange, +};