Skip to content

Commit

Permalink
Merge pull request #148 from telemark/support-foedselsdato
Browse files Browse the repository at this point in the history
Support foedselsdato
  • Loading branch information
runely authored Apr 28, 2021
2 parents 0d937cc + 2ee247f commit 50be90c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const config = {
const method = 'hentDetaljer' // See supported methods
const query = {
saksref: 'your-reference',
foedselsnr: '26118633333',
foedselsnr: '26118633333', // requires this or foedselsdato
foedselsdato: '261186', // requires this or foedselsnr
etternavn: 'Enge',
fornavn: 'Jonas'
}
Expand Down Expand Up @@ -64,7 +65,8 @@ const config = {
const method = 'hentDetaljer' // See supported methods
const query = {
saksref: 'your-reference',
foedselsnr: '26118633333',
foedselsnr: '26118633333', // requires this or foedselsdato
foedselsdato: '261186', // requires this or foedselsnr
etternavn: 'Enge',
fornavn: 'Jonas'
}
Expand Down
4 changes: 2 additions & 2 deletions lib/dsf.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ module.exports = options => {
if (!options.query.saksref) {
throw Error('Missing required input: options.query.saksref')
}
if (!options.query.foedselsnr) {
throw Error('Missing required input: options.query.foedselsnr')
if (!options.query.foedselsnr && !options.query.foedselsdato) {
throw Error('Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato')
}
if (options.query.etternavn && !options.query.fornavn) {
throw Error('Missing required input: options.query.fornavn')
Expand Down
3 changes: 2 additions & 1 deletion test/data/options.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"config": {
"url": "http://ws-test.infotorg.no/xml/ErgoGroup/DetSentraleFolkeregister1_4/2011-09-26/DetSentraleFolkeregister1_4.wsdl",
"url": "http://ws-test.infotorg.no/xml/ErgoGroup/DetSentraleFolkeregister1_4/2015-08-10/DetSentraleFolkeregister1_4.wsdl",
"namespaceBrukersesjon": "http://ws.infotorg.no/xml/Admin/Brukersesjon/2006-07-07/Brukersesjon.xsd",
"distribusjonskanal": "PTP",
"systemnavn": "Systemnavn",
Expand All @@ -11,6 +11,7 @@
"query": {
"saksref": "your-reference",
"foedselsnr": "27105500837",
"foedselsdato": "271055",
"etternavn": "AMOR",
"fornavn": "SIV"
}
Expand Down
15 changes: 12 additions & 3 deletions test/lib/node-dsf-promise-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,19 @@ test('requires param options.query.saksref to exist', t => {
})
})

test('requires param options.query.foedselsnr to exist', t => {
test('requires param options.query.foedselsnr to exist if options.query.foedselsdato is not supplied', t => {
const options = JSON.parse(JSON.stringify(masterOptions))
const expectedErrorMessage = 'Missing required input: options.query.foedselsnr'
options.query.foedselsnr = false
const expectedErrorMessage = 'Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato'
delete options.query.foedselsdato
return dsf(options).catch(error => {
t.deepEqual(error.message, expectedErrorMessage, expectedErrorMessage)
})
})

test('requires param options.query.foedselsdato to exist if options.query.foedselsnr is not supplied', t => {
const options = JSON.parse(JSON.stringify(masterOptions))
const expectedErrorMessage = 'Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato'
delete options.query.foedselsnr
return dsf(options).catch(error => {
t.deepEqual(error.message, expectedErrorMessage, expectedErrorMessage)
})
Expand Down
16 changes: 13 additions & 3 deletions test/lib/node-dsf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,20 @@ test.cb('requires param options.query.saksref to exist', t => {
})
})

test.cb('requires param options.query.foedselsnr to exist', t => {
test.cb('requires param options.query.foedselsnr to exist if options.query.foedselsdato is not supplied', t => {
const options = JSON.parse(JSON.stringify(masterOptions))
const expectedErrorMessage = 'Missing required input: options.query.foedselsnr'
options.query.foedselsnr = false
const expectedErrorMessage = 'Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato'
delete options.query.foedselsdato
dsf(options, (error, data) => {
t.deepEqual(error.message, expectedErrorMessage, expectedErrorMessage)
t.end()
})
})

test.cb('requires param options.query.foedselsdato to exist if options.query.foedselsnr is not supplied', t => {
const options = JSON.parse(JSON.stringify(masterOptions))
const expectedErrorMessage = 'Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato'
delete options.query.foedselsnr
dsf(options, (error, data) => {
t.deepEqual(error.message, expectedErrorMessage, expectedErrorMessage)
t.end()
Expand Down
3 changes: 2 additions & 1 deletion tst.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const config = {
const method = 'hentDetaljer'
const query = {
saksref: 'your-reference',
foedselsnr: '01010750160',
foedselsnr: '01010750160', // comment out the one not needed
foedselsdato: "010107", // comment out the one not needed
etternavn: 'TOPSTAD',
fornavn: 'TOMAS'
}
Expand Down

0 comments on commit 50be90c

Please sign in to comment.