This is work in progress. Final filtering proposal will be updated as development proceeds.
When creating a new payment, a filter can be specified. Vouchers spent for the payment must satisfy the filter's criteria in order to be accepted. Filtering is performed both on the client (Pocket) and on the server (Registry).
For basic functionality, a simple filter mode can be used. A simple filter has several limitations, that make its implementations more performant and its specification easier.
- A single, optional, filter on the voucher's source/aim;
- A single, optional, condition on the voucher's generation timestamp, expressed as a simple “maximum age”;
- A single, optional, geographical filter expressed as a bounding box.
As a JSON object, a simple filter takes the following form:
{
"Type": "simple",
"Source": "URL",
"Age": 12345,
"BoundingBox": {
"NorthEast": {
"type": "Point",
"coordinates": [ 43.732383, 12.646840 ]
},
"SouthWest": {
"type": "Point",
"coordinates": [ 43.717436, 12.620702 ]
}
}
}Where:
Sourceis the URL to the voucher's generator (see Source/Aim filtering below for further details);Ageis the amount of seconds back in time (since UTC ‘now’) that is accepted;BoundingBoxis a basic axis-aligned bounding box specified by two points. Each point is expressed as a GeoJSON geometry that must be of typePoint.
A filter must have at least one filtering condition.
Complex filters can be used to express advanced filtering options using logical operators. They are encoded as a hierarchy of JSON objects, in the following form:
{
"Type": "complex",
"Source": "URL",
"TimeRange": [ "2018-01-01", "2018-01-31" ],
"Age": 12345,
"BoundingBox" : { },
"Geometry": {
"type": "Polygon",
"coordinates": [
[ 43.732383, 12.646840 ],
[ 43.717436, 12.620702 ],
[ 43.732383, 12.620702 ]
]
},
"Or": [ ]
}Where:
Source,Age, andBoundingBoxwork just like in simple filters;TimeRangeexpresses an interval of time, encoded as a couple of ISO dates;Geometrycan take any GeoJSON geometry object (but onlyPolygontypes make sense and are supported by default);AgeandTimeRange,BoundingBoxandGeometryare mutually exclusive.
Any filter may have any number of the filtering conditions above. A filter without any filtering condition is valid and accepts all vouchers.
The Or property takes an array of filter objects (which must also be of the “complex” type).
The parent filter accepts a voucher if any sub-filter accepts the voucher.
For example, the following filter accepts all vouchers generated by a specific source around Urbino (Source and BoundingBox filters) or any voucher generated during the last week (Age filter).
{
"Type": "complex",
"Or": [
{
"Type": "complex",
"Source": "https://wom.social/...",
"BoundingBox": {
"NorthEast": {
"type": "Point",
"coordinates": [ 43.732383, 12.646840 ]
},
"SouthWest": {
"type": "Point",
"coordinates": [ 43.717436, 12.620702 ]
}
}
},
{
"Type": "complex",
"Age": 604800
}
]
}TBD.