-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'new-rms-adapter' into alpha
- Loading branch information
Showing
40 changed files
with
845 additions
and
323 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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,52 +1,66 @@ | ||
import OrderResponse from "./OrderResponse"; | ||
import Order from "../../models/Order"; | ||
import Dish from "../../models/Dish"; | ||
import Group from "../../models/Group"; | ||
export type ConfigRMSAdapter = { | ||
[key: string]: number | boolean | string; | ||
}; | ||
/** | ||
* Responce from RMS | ||
*/ | ||
export interface OrderResponse { | ||
code: number; | ||
body: any; | ||
} | ||
/** | ||
* An abstract RMS adapter class. Used to create new RMS adapters. | ||
*/ | ||
export default abstract class RMSAdapter { | ||
protected readonly syncMenuTime: number; | ||
protected readonly syncBalanceTime: number; | ||
protected readonly syncStreetsTime: number; | ||
protected constructor(menuTime: number, balanceTime: number, streetsTime: number); | ||
readonly config: ConfigRMSAdapter; | ||
private static syncProductsInterval; | ||
private static syncOutOfStocksInterval; | ||
constructor(config?: ConfigRMSAdapter); | ||
private static initialize; | ||
/** | ||
* Menu synchronization with RMS system | ||
* At first, groups are synchronized, then dishes are synchronized for each of these groups. | ||
* When synchronizing groups, those groups that were not on the list will be turned off before the start of synchronization | ||
* Those dishes that are left without ties will be marked with isDeleted | ||
* There can be no dishes in the root. | ||
*/ | ||
protected abstract sync(): Promise<void>; | ||
static syncProducts(concept?: string, force?: boolean): Promise<void>; | ||
/** | ||
* Synchronization of streets with RMS systems | ||
* Synchronizing the balance of dishes with the RMS adapter | ||
*/ | ||
protected abstract syncStreets(): Promise<void>; | ||
static syncOutOfStocks(): Promise<void>; | ||
/** | ||
* Synchronizing the balance of dishes with the RMS adapter | ||
* Checks whether the nomenclature was updated if the last time something has changed will return to True | ||
* @returns boolean | ||
*/ | ||
protected abstract syncBalance(): Promise<void>; | ||
protected abstract nomenclatureHasUpdated(): Promise<boolean>; | ||
/** | ||
* | ||
* @returns | ||
*/ | ||
protected abstract loadNomenclatureTree(rmsGroupIds?: string[]): Promise<Group[]>; | ||
protected abstract loadProductsByGroup(group: Group): Promise<Dish[]>; | ||
protected abstract loadOutOfStocksDishes(concept?: string): Promise<Dish[]>; | ||
/** | ||
* Create an order | ||
* @param orderData - webresto order | ||
* @return Order response | ||
*/ | ||
abstract createOrder(orderData: Order): Promise<OrderResponse>; | ||
/** | ||
* Order check | ||
* Order check before order | ||
* @param orderData - webresto order | ||
* @return Order response | ||
*/ | ||
abstract checkOrder(orderData: Order): Promise<OrderResponse>; | ||
/** | ||
* Getting system information | ||
* @return RMS system information | ||
*/ | ||
abstract getSystemData(): Promise<any>; | ||
/** | ||
* Direct request to the RMS API | ||
* @param method - method name | ||
* @param params - params | ||
* @return | ||
*/ | ||
abstract api(method: string, params: any): Promise<any>; | ||
/** | ||
* Method for creating and getting an already existing RMS adapter | ||
* @param params - parameters for initialization | ||
*/ | ||
static getInstance(...params: any[]): RMSAdapter; | ||
} |
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
Oops, something went wrong.