From 5964f27d3fe5f1755faf48e707ce4dfd2824c836 Mon Sep 17 00:00:00 2001 From: KadirBalku Date: Fri, 26 Apr 2024 17:48:06 +0200 Subject: [PATCH 1/2] feat: methods to fetch structure of cart and adress module --- src/ViURShopClient.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ViURShopClient.js b/src/ViURShopClient.js index bde17cb..a1e9f16 100644 --- a/src/ViURShopClient.js +++ b/src/ViURShopClient.js @@ -52,6 +52,7 @@ export class ViURShopClient { this.shop_url = `${this.host_url}/${this.shop_module}`; this.shop_json_url = `${this.host_url}/json/${this.shop_module}`; this.shop_api_url = `${this.shop_url}/api`; + this.getStructure_url = `${this.host_url}/vi/getStructure` } @@ -194,6 +195,13 @@ export class ViURShopClient { .then(req => req.json()) } + cart_structure() { + return request(`${this.getStructure_url}/shop.cart`, { + method: 'GET', + }) + .then(req => req.json()) + } + // --- Address ------------------------------------------------------------ address_list({} = {}) { @@ -251,6 +259,13 @@ export class ViURShopClient { }); } + address_structure() { + return request(`${this.getStructure_url}/shop.address`, { + method: 'GET', + }) + .then(req => req.json()) + } + // --- Order -------------------------------------------------------------- payment_providers_list({} = {}) { From 78431d363c879ad88ebb3571b175c33b327ed462 Mon Sep 17 00:00:00 2001 From: Sven Eberth Date: Fri, 26 Apr 2024 19:03:17 +0200 Subject: [PATCH 2/2] Use dynamic shop module name with `${this.shop_module}` --- src/ViURShopClient.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ViURShopClient.js b/src/ViURShopClient.js index a1e9f16..1dd86e9 100644 --- a/src/ViURShopClient.js +++ b/src/ViURShopClient.js @@ -196,7 +196,7 @@ export class ViURShopClient { } cart_structure() { - return request(`${this.getStructure_url}/shop.cart`, { + return request(`${this.getStructure_url}/${this.shop_module}.cart`, { method: 'GET', }) .then(req => req.json()) @@ -260,7 +260,7 @@ export class ViURShopClient { } address_structure() { - return request(`${this.getStructure_url}/shop.address`, { + return request(`${this.getStructure_url}/${this.shop_module}.address`, { method: 'GET', }) .then(req => req.json())