mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 00:23:03 +00:00
feat: add core
This commit is contained in:
128
src/core/base/ThingThatCanBeOffered.ts
Normal file
128
src/core/base/ThingThatCanBeOffered.ts
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2018 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCThing, SCThingTranslatableProperties} from '../Thing';
|
||||
import {SCBuildingWithoutReferences} from '../things/Building';
|
||||
import {SCOrganizationWithoutReferences} from '../things/Organization';
|
||||
import {SCPersonWithoutReferences} from '../things/Person';
|
||||
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest';
|
||||
import {SCRoomWithoutReferences} from '../things/Room';
|
||||
import {SCTranslations} from '../types/i18n';
|
||||
import {SCISO8601Date} from '../types/Time';
|
||||
|
||||
/**
|
||||
* A map from group name to price
|
||||
*/
|
||||
export interface SCPriceGroup {
|
||||
[s: string]: number | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Price distinctions for academic context
|
||||
*/
|
||||
export interface SCAcademicPriceGroup extends SCPriceGroup {
|
||||
/**
|
||||
* Price for employees
|
||||
*/
|
||||
employee?: number;
|
||||
|
||||
/**
|
||||
* Price for guests
|
||||
*/
|
||||
guest?: number;
|
||||
|
||||
/**
|
||||
* Price for students
|
||||
*/
|
||||
student?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A thing without references that has a price tag
|
||||
*/
|
||||
export interface SCThingThatCanBeOffered<T extends SCPriceGroup> extends SCThing {
|
||||
/**
|
||||
* List of offers for that thing
|
||||
*/
|
||||
offers?: Array<SCThingThatCanBeOfferedOffer<T>>;
|
||||
|
||||
/**
|
||||
* Translations of a thing that can be offered
|
||||
*/
|
||||
translations?: SCTranslations<SCThingThatCanBeOfferedTranslatableProperties>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Offer of a thing
|
||||
*/
|
||||
export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup> {
|
||||
/**
|
||||
* Availability of an offer
|
||||
*/
|
||||
availability: SCThingThatCanBeOfferedAvailabilty;
|
||||
|
||||
/**
|
||||
* The time when the thing becomes unavailable as an SCISO8601Date formatted string.
|
||||
*/
|
||||
availabilityEnds?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* The time when the thing becomes available as an SCISO8601Date formatted string.
|
||||
*/
|
||||
availabilityStarts?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Default price of the thing
|
||||
*/
|
||||
price: number;
|
||||
|
||||
/**
|
||||
* List of prices that are distinct for specific groups
|
||||
*/
|
||||
prices?: T;
|
||||
|
||||
/**
|
||||
* Provider of an offer
|
||||
*/
|
||||
provider: SCThingThatCanBeOfferedProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a thing that can be offered
|
||||
*/
|
||||
export interface SCThingThatCanBeOfferedTranslatableProperties extends SCThingTranslatableProperties {
|
||||
/**
|
||||
* Availability of an offer
|
||||
*/
|
||||
'offers[].availability'?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible things a provider can be
|
||||
*/
|
||||
export type SCThingThatCanBeOfferedProvider =
|
||||
SCBuildingWithoutReferences
|
||||
| SCOrganizationWithoutReferences
|
||||
| SCPersonWithoutReferences
|
||||
| SCPointOfInterestWithoutReferences
|
||||
| SCRoomWithoutReferences;
|
||||
|
||||
/**
|
||||
* Availability of an Offer
|
||||
*/
|
||||
export type SCThingThatCanBeOfferedAvailabilty =
|
||||
'in stock'
|
||||
| 'out of stock'
|
||||
| 'online only'
|
||||
| 'limited availabilty';
|
||||
Reference in New Issue
Block a user