2021-10-12 16:27:27 +03:00
|
|
|
const ValueObject = require('./shared/ValueObject');
|
|
|
|
const InvalidOfferStatus = require('../errors').InvalidOfferStatus;
|
|
|
|
|
|
|
|
/** @extends ValueObject<'active'|'archived'> */
|
|
|
|
class OfferStatus extends ValueObject {
|
|
|
|
/** @param {unknown} status */
|
|
|
|
static create(status) {
|
|
|
|
if (typeof status !== 'string') {
|
|
|
|
throw new InvalidOfferStatus({
|
|
|
|
message: 'Offer `status` must be a string.'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status !== 'active' && status !== 'archived') {
|
|
|
|
throw new InvalidOfferStatus({
|
|
|
|
message: 'Offer `status` must be either "active" or "archived".'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return new OfferStatus(status);
|
|
|
|
}
|
2021-11-04 20:52:20 +03:00
|
|
|
|
2022-02-15 15:27:22 +03:00
|
|
|
static InvalidOfferStatus = InvalidOfferStatus;
|
2021-10-12 16:27:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = OfferStatus;
|