add predefined orders

This commit is contained in:
Vladislav Hristov 2018-06-20 14:08:31 +03:00
parent 8e9e0df276
commit c0ec4b8fb7
23 changed files with 271 additions and 17 deletions

View File

@ -1,9 +1,11 @@
'use strict';
const Client = require('./lib/Client');
const Orders = require('./lib/predefinedOrders');
const fsKeysStorage = require('./lib/storages/fsKeysStorage');
module.exports = {
Client,
Orders,
fsKeysStorage,
};

View File

@ -107,22 +107,6 @@ module.exports = class Client {
});
}
ini(order) {
return this.initialization(order);
}
payment(order) {
return this.upload(order);
}
statement(order) {
return this.download(order);
}
status(order) {
return this.download(order);
}
keys() {
const keysString = this.keyStorage.read();

View File

@ -47,7 +47,7 @@ module.exports = (keysStorage, passphrase, algorithm = 'aes-256-cbc') => {
return key;
});
storage.save(encrypt(JSON.stringify(keysObject), algo, pass));
storage.write(encrypt(JSON.stringify(keysObject), algo, pass));
return this;
},

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = document => ({
version: 'h004',
orderDetails: { OrderType: 'AZV', OrderAttribute: 'OZHNN', StandardOrderParams: {} },
operation: 'upload',
document,
});

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = document => ({
version: 'h004',
orderDetails: { OrderType: 'CCS', OrderAttribute: 'OZHNN', StandardOrderParams: {} },
operation: 'upload',
document,
});

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = document => ({
version: 'h004',
orderDetails: { OrderType: 'CCT', OrderAttribute: 'OZHNN', StandardOrderParams: {} },
operation: 'upload',
document,
});

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = document => ({
version: 'h004',
orderDetails: { OrderType: 'CD1', OrderAttribute: 'OZHNN', StandardOrderParams: {} },
operation: 'upload',
document,
});

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = document => ({
version: 'h004',
orderDetails: { OrderType: 'CDB', OrderAttribute: 'OZHNN', StandardOrderParams: {} },
operation: 'upload',
document,
});

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = document => ({
version: 'h004',
orderDetails: { OrderType: 'CDD', OrderAttribute: 'OZHNN', StandardOrderParams: {} },
operation: 'upload',
document,
});

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = document => ({
version: 'h004',
orderDetails: { OrderType: 'CDS', OrderAttribute: 'OZHNN', StandardOrderParams: {} },
operation: 'upload',
document,
});

View File

@ -0,0 +1,11 @@
'use strict';
module.exports = {
version: 'h004',
orderDetails: {
OrderType: 'HAA',
OrderAttribute: 'DZHNN',
StandardOrderParams: {},
},
operation: 'download',
};

View File

@ -0,0 +1,23 @@
'use strict';
const dateRange = (start, end) => {
if (start && end)
return {
DateRange: {
Start: start,
End: end,
},
};
return {};
};
module.exports = (start = null, end = null) => ({
version: 'h004',
orderDetails: {
OrderType: 'HAC',
OrderAttribute: 'DZHNN',
StandardOrderParams: dateRange(start, end),
},
operation: 'download',
});

View File

@ -0,0 +1,7 @@
'use strict';
module.exports = {
version: 'h004',
orderDetails: { OrderType: 'HIA', OrderAttribute: 'DZNNN' },
operation: 'ini',
};

View File

@ -0,0 +1,11 @@
'use strict';
module.exports = {
version: 'h004',
orderDetails: {
OrderType: 'HKD',
OrderAttribute: 'DZHNN',
StandardOrderParams: {},
},
operation: 'download',
};

View File

@ -0,0 +1,7 @@
'use strict';
module.exports = {
version: 'h004',
orderDetails: { OrderType: 'HPB', OrderAttribute: 'DZHNN' },
operation: 'ini',
};

View File

@ -0,0 +1,11 @@
'use strict';
module.exports = {
version: 'h004',
orderDetails: {
OrderType: 'HPD',
OrderAttribute: 'DZHNN',
StandardOrderParams: {},
},
operation: 'download',
};

View File

@ -0,0 +1,11 @@
'use strict';
module.exports = {
version: 'h004',
orderDetails: {
OrderType: 'HTD',
OrderAttribute: 'DZHNN',
StandardOrderParams: {},
},
operation: 'download',
};

View File

@ -0,0 +1,7 @@
'use strict';
module.exports = {
version: 'h004',
orderDetails: { OrderType: 'INI', OrderAttribute: 'DZNNN' },
operation: 'ini',
};

View File

@ -0,0 +1,23 @@
'use strict';
const dateRange = (start, end) => {
if (start && end)
return {
DateRange: {
Start: start,
End: end,
},
};
return {};
};
module.exports = (start = null, end = null) => ({
version: 'h004',
orderDetails: {
OrderType: 'PTK',
OrderAttribute: 'DZHNN',
StandardOrderParams: dateRange(start, end),
},
operation: 'download',
});

View File

@ -0,0 +1,23 @@
'use strict';
const dateRange = (start, end) => {
if (start && end)
return {
DateRange: {
Start: start,
End: end,
},
};
return {};
};
module.exports = (start = null, end = null) => ({
version: 'h004',
orderDetails: {
OrderType: 'STA',
OrderAttribute: 'DZHNN',
StandardOrderParams: dateRange(start, end),
},
operation: 'download',
});

View File

@ -0,0 +1,23 @@
'use strict';
const dateRange = (start, end) => {
if (start && end)
return {
DateRange: {
Start: start,
End: end,
},
};
return {};
};
module.exports = (start = null, end = null) => ({
version: 'h004',
orderDetails: {
OrderType: 'VMK',
OrderAttribute: 'DZHNN',
StandardOrderParams: dateRange(start, end),
},
operation: 'download',
});

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = document => ({
version: 'h004',
orderDetails: { OrderType: 'XE3', OrderAttribute: 'OZHNN', StandardOrderParams: {} },
operation: 'upload',
document,
});

View File

@ -0,0 +1,47 @@
'use strict';
const INI = require('./INI');
const HIA = require('./HIA');
const HPB = require('./HPB');
const AZV = require('./AZV');
const CD1 = require('./CD1');
const CDB = require('./CDB');
const CDD = require('./CDD');
const CDS = require('./CDS');
const CCT = require('./CCT');
const CCS = require('./CCS');
const XE3 = require('./XE3');
const STA = require('./STA');
const VMK = require('./VMK');
const HAA = require('./HAA');
const HTD = require('./HTD');
const HPD = require('./HPD');
const HKD = require('./HKD');
const PTK = require('./PTK');
const HAC = require('./HAC');
module.exports = {
INI,
HIA,
HPB,
AZV,
CD1,
CDB,
CDD,
CDS,
CCT,
CCS,
XE3,
STA,
VMK,
HAA,
HTD,
HPD,
HKD,
PTK,
HAC,
};