-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(register_opening_protocols): allow empty cash units (#344)
- Loading branch information
1 parent
95f91c1
commit eb812c4
Showing
1 changed file
with
80 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,89 @@ | ||
const { oneOf } = require('../../../helpers/payload-or-null') | ||
|
||
module.exports = { | ||
description: 'Payments grouped by payment options (and currencies if neccessary - and, if indicated by e.g. card cisrcuits).', | ||
additionalProperties: false, | ||
type: 'object', | ||
required: [ | ||
'currency', | ||
'units' | ||
], | ||
properties: { | ||
client_id: { | ||
...oneOf({ | ||
type: 'string', | ||
example: 'd0d40841-b1a7-438a-9d1e-2bfec590d2e3', | ||
minLength: 6, | ||
maxLength: 64, | ||
description: 'A implementer defined identifier. This can be used for local resource matching and has no business implication.' | ||
}), | ||
default: null | ||
}, | ||
currency: { | ||
const properties = { | ||
client_id: { | ||
...oneOf({ | ||
type: 'string', | ||
description: 'The three letter [ISO currency](https://en.wikipedia.org/wiki/ISO_4217) of this item.', | ||
example: 'EUR', | ||
minLength: 3, | ||
maxLength: 3 | ||
}, | ||
units: { | ||
type: 'array', | ||
additionalProperties: false, | ||
description: 'units.', | ||
items: { | ||
type: 'object', | ||
description: 'Cash unit details pre e.g. 7 pieces of 10 Cents coins.', | ||
properties: { | ||
type: { | ||
type: 'string', | ||
example: 'coin', | ||
enum: [ | ||
'bill', | ||
'coin' | ||
] | ||
}, | ||
qty: { | ||
default: null, | ||
...oneOf({ | ||
type: 'number', | ||
description: 'The quantity of this unit.', | ||
examples: [7], | ||
minimum: 0, | ||
maximum: 32767, | ||
multipleOf: 1 | ||
}) | ||
}, | ||
value: { | ||
examples: [0.10], | ||
description: 'The amount by summing all cash for that bill/coin.', | ||
example: 'd0d40841-b1a7-438a-9d1e-2bfec590d2e3', | ||
minLength: 6, | ||
maxLength: 64, | ||
description: 'A implementer defined identifier. This can be used for local resource matching and has no business implication.' | ||
}), | ||
default: null | ||
}, | ||
currency: { | ||
type: 'string', | ||
description: 'The three letter [ISO currency](https://en.wikipedia.org/wiki/ISO_4217) of this item.', | ||
example: 'EUR', | ||
minLength: 3, | ||
maxLength: 3 | ||
}, | ||
units: { | ||
type: 'array', | ||
additionalProperties: false, | ||
description: 'units.', | ||
items: { | ||
type: 'object', | ||
description: 'Cash unit details pre e.g. 7 pieces of 10 Cents coins.', | ||
properties: { | ||
type: { | ||
type: 'string', | ||
example: 'coin', | ||
enum: [ | ||
'bill', | ||
'coin' | ||
] | ||
}, | ||
qty: { | ||
default: null, | ||
...oneOf({ | ||
type: 'number', | ||
description: 'The quantity of this unit.', | ||
examples: [7], | ||
minimum: 0, | ||
maximum: 1000000, | ||
multipleOf: 0.01 | ||
} | ||
maximum: 32767, | ||
multipleOf: 1 | ||
}) | ||
}, | ||
value: { | ||
examples: [0.10], | ||
description: 'The amount by summing all cash for that bill/coin.', | ||
type: 'number', | ||
minimum: 0, | ||
maximum: 1000000, | ||
multipleOf: 0.01 | ||
} | ||
} | ||
} | ||
}, | ||
minItems: 1 | ||
} | ||
} | ||
|
||
module.exports = { | ||
anyOf: [{ | ||
description: 'Payments grouped by payment options (and currencies if neccessary - and, if indicated by e.g. card cisrcuits).', | ||
additionalProperties: false, | ||
type: 'object', | ||
required: [ | ||
'currency', | ||
'units' | ||
], | ||
properties | ||
}, | ||
{ | ||
description: 'Payments grouped by payment options (and currencies if neccessary - and, if indicated by e.g. card cisrcuits).', | ||
additionalProperties: false, | ||
type: 'object', | ||
required: [ | ||
'units' | ||
], | ||
properties: { | ||
...properties, | ||
units: { | ||
...properties.units, | ||
minItems: 0, | ||
maxItems: 0 | ||
} | ||
} | ||
}] | ||
} |