Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

ProductBarcode: rename API call from getproductfromean to products/search-from-barcode

Crumb Owl4a4bf9a175ee
diff --git a/backend/app/api/handlers/v1/v1_ctrl_product_search.go b/backend/app/api/handlers/v1/v1_ctrl_product_search.go
index 922fa67d..73378be5 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_product_search.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_product_search.go
@@ -94,7 +94,7 @@ type BARCODESPIDER_COMResponse struct {
// @Produce json
// @Param data query string false "barcode to be searched"
// @Success 200 {object} []repo.BarcodeProduct
-// @Router /v1/getproductfromean [GET]
+// @Router /v1/products/search-from-barcode [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleProductSearchFromBarcode(conf config.BarcodeAPIConf) errchain.HandlerFunc {
type query struct {
diff --git a/backend/app/api/routes.go b/backend/app/api/routes.go
index 91840946..74f8595f 100644
--- a/backend/app/api/routes.go
+++ b/backend/app/api/routes.go
@@ -157,8 +157,9 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
a.mwRoles(RoleModeOr, authroles.RoleUser.String(), authroles.RoleAttachments.String()),
}
+ r.Get("/products/search-from-barcode", chain.ToHandlerFunc(v1Ctrl.HandleProductSearchFromBarcode(a.conf.Barcode), userMW...))
+
r.Get("/qrcode", chain.ToHandlerFunc(v1Ctrl.HandleGenerateQRCode(), assetMW...))
- r.Get("/getproductfromean", chain.ToHandlerFunc(v1Ctrl.HandleProductSearchFromBarcode(a.conf.Barcode), userMW...))
r.Get(
"/items/{id}/attachments/{attachment_id}",
chain.ToHandlerFunc(v1Ctrl.HandleItemAttachmentGet(), assetMW...),
diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go
index 3df008bb..65ab97a9 100644
--- a/backend/app/api/static/docs/docs.go
+++ b/backend/app/api/static/docs/docs.go
@@ -195,41 +195,6 @@ const docTemplate = `{
}
}
},
- "/v1/getproductfromean": {
- "get": {
- "security": [
- {
- "Bearer": []
- }
- ],
- "produces": [
- "application/json"
- ],
- "tags": [
- "Items"
- ],
- "summary": "Search EAN from Barcode",
- "parameters": [
- {
- "type": "string",
- "description": "barcode to be searched",
- "name": "data",
- "in": "query"
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/repo.BarcodeProduct"
- }
- }
- }
- }
- }
- },
"/v1/groups": {
"get": {
"security": [
@@ -1846,6 +1811,41 @@ const docTemplate = `{
}
}
},
+ "/v1/products/search-from-barcode": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Search EAN from Barcode",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "barcode to be searched",
+ "name": "data",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.BarcodeProduct"
+ }
+ }
+ }
+ }
+ }
+ },
"/v1/qrcode": {
"get": {
"security": [
diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json
index 1c01d28e..764c05bd 100644
--- a/backend/app/api/static/docs/swagger.json
+++ b/backend/app/api/static/docs/swagger.json
@@ -193,41 +193,6 @@
}
}
},
- "/v1/getproductfromean": {
- "get": {
- "security": [
- {
- "Bearer": []
- }
- ],
- "produces": [
- "application/json"
- ],
- "tags": [
- "Items"
- ],
- "summary": "Search EAN from Barcode",
- "parameters": [
- {
- "type": "string",
- "description": "barcode to be searched",
- "name": "data",
- "in": "query"
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/repo.BarcodeProduct"
- }
- }
- }
- }
- }
- },
"/v1/groups": {
"get": {
"security": [
@@ -1844,6 +1809,41 @@
}
}
},
+ "/v1/products/search-from-barcode": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Search EAN from Barcode",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "barcode to be searched",
+ "name": "data",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.BarcodeProduct"
+ }
+ }
+ }
+ }
+ }
+ },
"/v1/qrcode": {
"get": {
"security": [
diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml
index 9d4bc3a9..cf9eae6a 100644
--- a/backend/app/api/static/docs/swagger.yaml
+++ b/backend/app/api/static/docs/swagger.yaml
@@ -1572,27 +1572,6 @@ paths:
summary: Currency
tags:
- Base
- /v1/getproductfromean:
- get:
- parameters:
- - description: barcode to be searched
- in: query
- name: data
- type: string
- produces:
- - application/json
- responses:
- "200":
- description: OK
- schema:
- items:
- $ref: '#/definitions/repo.BarcodeProduct'
- type: array
- security:
- - Bearer: []
- summary: Search EAN from Barcode
- tags:
- - Items
/v1/groups:
get:
produces:
@@ -2585,6 +2564,27 @@ paths:
summary: Test Notifier
tags:
- Notifiers
+ /v1/products/search-from-barcode:
+ get:
+ parameters:
+ - description: barcode to be searched
+ in: query
+ name: data
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.BarcodeProduct'
+ type: array
+ security:
+ - Bearer: []
+ summary: Search EAN from Barcode
+ tags:
+ - Items
/v1/qrcode:
get:
parameters:
diff --git a/docs/en/api/openapi-2.0.json b/docs/en/api/openapi-2.0.json
index 1c01d28e..764c05bd 100644
--- a/docs/en/api/openapi-2.0.json
+++ b/docs/en/api/openapi-2.0.json
@@ -193,41 +193,6 @@
}
}
},
- "/v1/getproductfromean": {
- "get": {
- "security": [
- {
- "Bearer": []
- }
- ],
- "produces": [
- "application/json"
- ],
- "tags": [
- "Items"
- ],
- "summary": "Search EAN from Barcode",
- "parameters": [
- {
- "type": "string",
- "description": "barcode to be searched",
- "name": "data",
- "in": "query"
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/repo.BarcodeProduct"
- }
- }
- }
- }
- }
- },
"/v1/groups": {
"get": {
"security": [
@@ -1844,6 +1809,41 @@
}
}
},
+ "/v1/products/search-from-barcode": {
+ "get": {
+ "security": [
+ {
+ "Bearer": []
+ }
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Items"
+ ],
+ "summary": "Search EAN from Barcode",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "barcode to be searched",
+ "name": "data",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/repo.BarcodeProduct"
+ }
+ }
+ }
+ }
+ }
+ },
"/v1/qrcode": {
"get": {
"security": [
diff --git a/docs/en/api/openapi-2.0.yaml b/docs/en/api/openapi-2.0.yaml
index 9d4bc3a9..cf9eae6a 100644
--- a/docs/en/api/openapi-2.0.yaml
+++ b/docs/en/api/openapi-2.0.yaml
@@ -1572,27 +1572,6 @@ paths:
summary: Currency
tags:
- Base
- /v1/getproductfromean:
- get:
- parameters:
- - description: barcode to be searched
- in: query
- name: data
- type: string
- produces:
- - application/json
- responses:
- "200":
- description: OK
- schema:
- items:
- $ref: '#/definitions/repo.BarcodeProduct'
- type: array
- security:
- - Bearer: []
- summary: Search EAN from Barcode
- tags:
- - Items
/v1/groups:
get:
produces:
@@ -2585,6 +2564,27 @@ paths:
summary: Test Notifier
tags:
- Notifiers
+ /v1/products/search-from-barcode:
+ get:
+ parameters:
+ - description: barcode to be searched
+ in: query
+ name: data
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/repo.BarcodeProduct'
+ type: array
+ security:
+ - Bearer: []
+ summary: Search EAN from Barcode
+ tags:
+ - Items
/v1/qrcode:
get:
parameters:
diff --git a/frontend/components/Item/BarcodeModal.vue b/frontend/components/Item/BarcodeModal.vue
index fb99d645..d0b3bf2d 100644
--- a/frontend/components/Item/BarcodeModal.vue
+++ b/frontend/components/Item/BarcodeModal.vue
@@ -152,7 +152,7 @@
async function retrieveProductInfo(barcode: string) {
products.value = null;
searching.value = true;
- const result = await api.actions.getEAN(barcode);
+ const result = await api.products.searchFromBarcode(barcode);
searching.value = false;
if(result.error)
diff --git a/frontend/lib/api/classes/actions.ts b/frontend/lib/api/classes/actions.ts
index 1a8f94bc..6b74c467 100644
--- a/frontend/lib/api/classes/actions.ts
+++ b/frontend/lib/api/classes/actions.ts
@@ -31,8 +31,4 @@ export class ActionsAPI extends BaseAPI {
url: route("/actions/create-missing-thumbnails"),
});
}
-
- getEAN(productEAN: string) {
- return this.http.get<ItemCreate>({ url: route(`/getproductfromean`, { productEAN }) });
- }
}
diff --git a/frontend/lib/api/classes/product.ts b/frontend/lib/api/classes/product.ts
new file mode 100644
index 00000000..32097227
--- /dev/null
+++ b/frontend/lib/api/classes/product.ts
@@ -0,0 +1,8 @@
+import { BaseAPI, route } from "../base";
+import type { BarcodeProduct } from "../types/data-contracts";
+
+export class ProductAPI extends BaseAPI {
+ searchFromBarcode(productEAN: string) {
+ return this.http.get<BarcodeProduct[]>({ url: route(`/products/search-from-barcode`, { productEAN }) });
+ }
+}
\ No newline at end of file
diff --git a/frontend/lib/api/user.ts b/frontend/lib/api/user.ts
index eccafeaf..ffaede3d 100644
--- a/frontend/lib/api/user.ts
+++ b/frontend/lib/api/user.ts
@@ -10,6 +10,7 @@ import { AssetsApi } from "./classes/assets";
import { ReportsAPI } from "./classes/reports";
import { NotifiersAPI } from "./classes/notifiers";
import { MaintenanceAPI } from "./classes/maintenance";
+import { ProductAPI } from "./classes/product";
import type { Requests } from "~~/lib/requests";
export class UserClient extends BaseAPI {
@@ -24,6 +25,7 @@ export class UserClient extends BaseAPI {
assets: AssetsApi;
reports: ReportsAPI;
notifiers: NotifiersAPI;
+ products: ProductAPI;
constructor(requests: Requests, attachmentToken: string) {
super(requests, attachmentToken);
@@ -39,6 +41,7 @@ export class UserClient extends BaseAPI {
this.assets = new AssetsApi(requests);
this.reports = new ReportsAPI(requests);
this.notifiers = new NotifiersAPI(requests);
+ this.products = new ProductAPI(requests);
Object.freeze(this);
}