@teko-builder/plugin-teko-product
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -5,3 +5,2 @@ import { DiscoveryProduct, MenuItem, SearchBody, TekoProduct, Terminal } from './types'; | ||
private _env; | ||
private _terminalCode; | ||
private _locationCode; | ||
@@ -11,4 +10,2 @@ private _mockTerminals; | ||
set env(value: string); | ||
set terminalCode(value: string); | ||
get terminalCode(): string; | ||
set mockTerminals(value: Terminal[]); | ||
@@ -18,3 +15,6 @@ get mockTerminals(): Terminal[]; | ||
get discoveryURI(): string; | ||
fetchProducts(terminalCode: string, menuItemId: number | string, size?: number, page?: number, baseMenuItem?: MenuItem): Promise<{ | ||
fetchProducts(terminal: { | ||
code?: string; | ||
id?: number; | ||
}, menuItemId: number | string, size?: number, page?: number, baseMenuItem?: MenuItem): Promise<{ | ||
products: DiscoveryProduct[]; | ||
@@ -44,3 +44,6 @@ hasNextPage?: boolean; | ||
interface FetchProductOption { | ||
terminalCode: string; | ||
terminal: { | ||
code?: string; | ||
id?: number; | ||
}; | ||
locationCode?: string; | ||
@@ -47,0 +50,0 @@ menuItemId?: number; |
@@ -141,8 +141,2 @@ import { Api } from '@teko-builder/utils'; | ||
} | ||
set terminalCode(value) { | ||
this._terminalCode = value; | ||
} | ||
get terminalCode() { | ||
return this._terminalCode; | ||
} | ||
set mockTerminals(value) { | ||
@@ -160,8 +154,11 @@ this._mockTerminals = value; | ||
} | ||
async fetchProducts(terminalCode, menuItemId, size = 10, page = 1, baseMenuItem) { | ||
async fetchProducts(terminal, menuItemId, size = 10, page = 1, baseMenuItem) { | ||
var _a, _b; | ||
const hasTerminal = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || (terminal === null || terminal === void 0 ? void 0 : terminal.id); | ||
const terminalCode = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || undefined; | ||
const terminalId = (terminal === null || terminal === void 0 ? void 0 : terminal.id) || undefined; | ||
if (!this.discoveryURI) { | ||
throw 'Please set discoveryURI!'; | ||
} | ||
if (!menuItemId || !terminalCode) { | ||
if (!menuItemId || !hasTerminal) { | ||
return; | ||
@@ -180,3 +177,4 @@ } | ||
}; | ||
const res = await client.post(`${this.discoveryURI}/v1/search`, Object.assign(Object.assign({}, transformSearchBody(menuItem)), { terminalCode, location: this._locationCode, pagination: { | ||
const res = await client.post(`${this.discoveryURI}/v1/search`, Object.assign(Object.assign({}, transformSearchBody(menuItem)), { terminalCode, | ||
terminalId, location: this._locationCode, pagination: { | ||
pageNumber: page, | ||
@@ -208,3 +206,6 @@ itemsPerPage: size, | ||
var _a, _b; | ||
const { menuItemId, terminalCode, locationCode, size = 10, page = 1, } = options; | ||
const { menuItemId, terminal, locationCode, size = 10, page = 1 } = options; | ||
const hasTerminal = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || (terminal === null || terminal === void 0 ? void 0 : terminal.id); | ||
const terminalCode = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || undefined; | ||
const terminalId = (terminal === null || terminal === void 0 ? void 0 : terminal.id) || undefined; | ||
const discoveryURI = discoveryURIMap[env]; | ||
@@ -214,3 +215,3 @@ if (!discoveryURI) { | ||
} | ||
if (!menuItemId || !terminalCode) { | ||
if (!menuItemId || !hasTerminal) { | ||
return; | ||
@@ -229,3 +230,4 @@ } | ||
}; | ||
const res = await client.post(`${discoveryURI}/v1/search`, Object.assign(Object.assign({}, transformSearchBody(menuItem)), { terminalCode, location: locationCode, pagination: { | ||
const res = await client.post(`${discoveryURI}/v1/search`, Object.assign(Object.assign({}, transformSearchBody(menuItem)), { terminalCode, | ||
terminalId, location: locationCode, pagination: { | ||
pageNumber: page, | ||
@@ -244,3 +246,6 @@ itemsPerPage: size, | ||
var _a, _b; | ||
const { slug, terminalCode, locationCode, size = 10, page = 1 } = options; | ||
const { slug, terminal, locationCode, size = 10, page = 1 } = options; | ||
const hasTerminal = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || (terminal === null || terminal === void 0 ? void 0 : terminal.id); | ||
const terminalCode = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || undefined; | ||
const terminalId = (terminal === null || terminal === void 0 ? void 0 : terminal.id) || undefined; | ||
const discoveryURI = discoveryURIMap[env]; | ||
@@ -250,3 +255,3 @@ if (!discoveryURI) { | ||
} | ||
if (!slug || !terminalCode) { | ||
if (!slug || !hasTerminal) { | ||
return; | ||
@@ -258,2 +263,3 @@ } | ||
terminalCode, | ||
terminalId, | ||
location: locationCode, | ||
@@ -260,0 +266,0 @@ pagination: { |
@@ -145,8 +145,2 @@ 'use strict'; | ||
} | ||
set terminalCode(value) { | ||
this._terminalCode = value; | ||
} | ||
get terminalCode() { | ||
return this._terminalCode; | ||
} | ||
set mockTerminals(value) { | ||
@@ -164,8 +158,11 @@ this._mockTerminals = value; | ||
} | ||
async fetchProducts(terminalCode, menuItemId, size = 10, page = 1, baseMenuItem) { | ||
async fetchProducts(terminal, menuItemId, size = 10, page = 1, baseMenuItem) { | ||
var _a, _b; | ||
const hasTerminal = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || (terminal === null || terminal === void 0 ? void 0 : terminal.id); | ||
const terminalCode = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || undefined; | ||
const terminalId = (terminal === null || terminal === void 0 ? void 0 : terminal.id) || undefined; | ||
if (!this.discoveryURI) { | ||
throw 'Please set discoveryURI!'; | ||
} | ||
if (!menuItemId || !terminalCode) { | ||
if (!menuItemId || !hasTerminal) { | ||
return; | ||
@@ -184,3 +181,4 @@ } | ||
}; | ||
const res = await client.post(`${this.discoveryURI}/v1/search`, Object.assign(Object.assign({}, transformSearchBody(menuItem)), { terminalCode, location: this._locationCode, pagination: { | ||
const res = await client.post(`${this.discoveryURI}/v1/search`, Object.assign(Object.assign({}, transformSearchBody(menuItem)), { terminalCode, | ||
terminalId, location: this._locationCode, pagination: { | ||
pageNumber: page, | ||
@@ -212,3 +210,6 @@ itemsPerPage: size, | ||
var _a, _b; | ||
const { menuItemId, terminalCode, locationCode, size = 10, page = 1, } = options; | ||
const { menuItemId, terminal, locationCode, size = 10, page = 1 } = options; | ||
const hasTerminal = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || (terminal === null || terminal === void 0 ? void 0 : terminal.id); | ||
const terminalCode = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || undefined; | ||
const terminalId = (terminal === null || terminal === void 0 ? void 0 : terminal.id) || undefined; | ||
const discoveryURI = discoveryURIMap[env]; | ||
@@ -218,3 +219,3 @@ if (!discoveryURI) { | ||
} | ||
if (!menuItemId || !terminalCode) { | ||
if (!menuItemId || !hasTerminal) { | ||
return; | ||
@@ -233,3 +234,4 @@ } | ||
}; | ||
const res = await client.post(`${discoveryURI}/v1/search`, Object.assign(Object.assign({}, transformSearchBody(menuItem)), { terminalCode, location: locationCode, pagination: { | ||
const res = await client.post(`${discoveryURI}/v1/search`, Object.assign(Object.assign({}, transformSearchBody(menuItem)), { terminalCode, | ||
terminalId, location: locationCode, pagination: { | ||
pageNumber: page, | ||
@@ -248,3 +250,6 @@ itemsPerPage: size, | ||
var _a, _b; | ||
const { slug, terminalCode, locationCode, size = 10, page = 1 } = options; | ||
const { slug, terminal, locationCode, size = 10, page = 1 } = options; | ||
const hasTerminal = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || (terminal === null || terminal === void 0 ? void 0 : terminal.id); | ||
const terminalCode = (terminal === null || terminal === void 0 ? void 0 : terminal.code) || undefined; | ||
const terminalId = (terminal === null || terminal === void 0 ? void 0 : terminal.id) || undefined; | ||
const discoveryURI = discoveryURIMap[env]; | ||
@@ -254,3 +259,3 @@ if (!discoveryURI) { | ||
} | ||
if (!slug || !terminalCode) { | ||
if (!slug || !hasTerminal) { | ||
return; | ||
@@ -262,2 +267,3 @@ } | ||
terminalCode, | ||
terminalId, | ||
location: locationCode, | ||
@@ -264,0 +270,0 @@ pagination: { |
{ | ||
"name": "@teko-builder/plugin-teko-product", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Plugin Teko Product of Landing Builder", | ||
@@ -14,3 +14,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@teko-builder/utils": "^0.2.3" | ||
"@teko-builder/utils": "^0.2.5" | ||
}, | ||
@@ -17,0 +17,0 @@ "devDependencies": { |
@@ -0,0 +0,0 @@ import { MenuItem } from '..'; |
@@ -21,3 +21,2 @@ import { Api } from '@teko-builder/utils'; | ||
private _env: string; | ||
private _terminalCode: string; | ||
private _locationCode: string; | ||
@@ -37,10 +36,2 @@ private _mockTerminals: Terminal[] = []; | ||
set terminalCode(value: string) { | ||
this._terminalCode = value; | ||
} | ||
get terminalCode() { | ||
return this._terminalCode; | ||
} | ||
set mockTerminals(value: Terminal[]) { | ||
@@ -63,3 +54,6 @@ this._mockTerminals = value; | ||
public async fetchProducts( | ||
terminalCode: string, | ||
terminal: { | ||
code?: string; | ||
id?: number; | ||
}, | ||
menuItemId: number | string, | ||
@@ -74,6 +68,9 @@ size = 10, | ||
}> { | ||
const hasTerminal = terminal?.code || terminal?.id; | ||
const terminalCode = terminal?.code || undefined; | ||
const terminalId = terminal?.id || undefined; | ||
if (!this.discoveryURI) { | ||
throw 'Please set discoveryURI!'; | ||
} | ||
if (!menuItemId || !terminalCode) { | ||
if (!menuItemId || !hasTerminal) { | ||
return; | ||
@@ -97,2 +94,3 @@ } | ||
terminalCode, | ||
terminalId, | ||
location: this._locationCode, | ||
@@ -152,3 +150,6 @@ pagination: { | ||
interface FetchProductOption { | ||
terminalCode: string; | ||
terminal: { | ||
code?: string; | ||
id?: number; | ||
}; | ||
locationCode?: string; | ||
@@ -170,9 +171,7 @@ menuItemId?: number; | ||
}> => { | ||
const { | ||
menuItemId, | ||
terminalCode, | ||
locationCode, | ||
size = 10, | ||
page = 1, | ||
} = options; | ||
const { menuItemId, terminal, locationCode, size = 10, page = 1 } = options; | ||
const hasTerminal = terminal?.code || terminal?.id; | ||
const terminalCode = terminal?.code || undefined; | ||
const terminalId = terminal?.id || undefined; | ||
const discoveryURI = discoveryURIMap[env]; | ||
@@ -182,3 +181,3 @@ if (!discoveryURI) { | ||
} | ||
if (!menuItemId || !terminalCode) { | ||
if (!menuItemId || !hasTerminal) { | ||
return; | ||
@@ -202,2 +201,3 @@ } | ||
terminalCode, | ||
terminalId, | ||
location: locationCode, | ||
@@ -225,3 +225,7 @@ pagination: { | ||
}> => { | ||
const { slug, terminalCode, locationCode, size = 10, page = 1 } = options; | ||
const { slug, terminal, locationCode, size = 10, page = 1 } = options; | ||
const hasTerminal = terminal?.code || terminal?.id; | ||
const terminalCode = terminal?.code || undefined; | ||
const terminalId = terminal?.id || undefined; | ||
const discoveryURI = discoveryURIMap[env]; | ||
@@ -231,3 +235,3 @@ if (!discoveryURI) { | ||
} | ||
if (!slug || !terminalCode) { | ||
if (!slug || !hasTerminal) { | ||
return; | ||
@@ -241,2 +245,3 @@ } | ||
terminalCode, | ||
terminalId, | ||
location: locationCode, | ||
@@ -243,0 +248,0 @@ pagination: { |
@@ -0,0 +0,0 @@ import { UrlObject } from 'url'; |
@@ -0,0 +0,0 @@ import { |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65849
1659
Updated@teko-builder/utils@^0.2.5