-
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.
- Loading branch information
Xziy
committed
May 5, 2024
1 parent
2492b44
commit 2016b53
Showing
14 changed files
with
229 additions
and
11 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Order from "../../models/Order"; | ||
export type InitCheckout = { | ||
/** Order nonce */ | ||
nonce: number; | ||
/** | ||
* Intervals during which an order can be placed | ||
* */ | ||
worktimeIntervals: [number, number][]; | ||
/** | ||
* Will it be possible to order as quickly as possible? | ||
*/ | ||
allowSoonAsPossible: boolean; | ||
/** | ||
* Allow order by time | ||
*/ | ||
allowOrderToTime: boolean; | ||
}; | ||
export declare class OrderHelper { | ||
private constructor(); | ||
static initCheckout(populatedOrder: Order): Promise<InitCheckout>; | ||
static orderHash(populatedOrder: Order): string; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OrderHelper = void 0; | ||
const hashCode_1 = __importDefault(require("../hashCode")); | ||
const stringsInArray_1 = require("../stringsInArray"); | ||
class OrderHelper { | ||
constructor(orderId) { | ||
} | ||
static async initCheckout(populatedOrder) { | ||
let initCheckout = { | ||
worktimeIntervals: [], | ||
allowSoonAsPossible: false, | ||
allowOrderToTime: false, | ||
nonce: 0 | ||
}; | ||
await emitter.emit('core:order-init-checkout', populatedOrder, initCheckout); | ||
initCheckout.nonce = populatedOrder.nonce; | ||
return initCheckout; | ||
} | ||
static orderHash(populatedOrder) { | ||
const fieldsToExclude = [ | ||
'createdAt', | ||
'updatedAt', | ||
'shortId', | ||
'isPromoting', | ||
'nonce', | ||
'hash' | ||
]; | ||
let summarizeOrder = (0, stringsInArray_1.extractFieldValues)(populatedOrder, fieldsToExclude).join(""); | ||
let hash = (0, hashCode_1.default)(summarizeOrder); | ||
return hash; | ||
} | ||
} | ||
exports.OrderHelper = OrderHelper; |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Order from "../../models/Order"; | ||
import hashCode from "../hashCode"; | ||
import { extractFieldValues } from "../stringsInArray"; | ||
|
||
export type InitCheckout = { | ||
/** Order nonce */ | ||
nonce: number | ||
/** | ||
* Intervals during which an order can be placed | ||
* */ | ||
worktimeIntervals: [number, number][] | ||
|
||
/** | ||
* Will it be possible to order as quickly as possible? | ||
*/ | ||
allowSoonAsPossible: boolean | ||
|
||
/** | ||
* Allow order by time | ||
*/ | ||
allowOrderToTime: boolean | ||
} | ||
export class OrderHelper { | ||
private constructor(orderId: string) { | ||
|
||
} | ||
|
||
public static async initCheckout(populatedOrder: Order): Promise<InitCheckout> { | ||
let initCheckout: InitCheckout = { | ||
worktimeIntervals: [], | ||
allowSoonAsPossible: false, | ||
allowOrderToTime: false, | ||
nonce: 0 | ||
} | ||
await emitter.emit('core:order-init-checkout', populatedOrder, initCheckout); | ||
initCheckout.nonce = populatedOrder.nonce | ||
return initCheckout; | ||
} | ||
|
||
public static orderHash(populatedOrder: Order): string { | ||
const fieldsToExclude = [ | ||
'createdAt', | ||
'updatedAt', | ||
'shortId', | ||
'isPromoting', | ||
'nonce', | ||
'hash' | ||
] | ||
|
||
let summarizeOrder = extractFieldValues(populatedOrder,fieldsToExclude).join("") | ||
|
||
let hash: string = hashCode(summarizeOrder); | ||
|
||
return hash | ||
} | ||
} |
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,2 +1,3 @@ | ||
export declare function stringsInArray(check: string[] | string, array: string[]): boolean; | ||
export declare function someInArray(check: string[] | string, array: string[]): boolean; | ||
export declare function extractFieldValues(obj: any, fields: any, exclude?: boolean, result?: any[]): any[]; |
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 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.