From b181fd06c47266f903663882ea0a2f188ffb27c3 Mon Sep 17 00:00:00 2001 From: Java Kanaya Prada Date: Wed, 19 Jun 2024 00:19:50 +0700 Subject: [PATCH 1/3] fix: error checking for wrong product key --- dto/tokopedia.go | 1 + service/tokopedia.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/dto/tokopedia.go b/dto/tokopedia.go index efabb49..a83b935 100644 --- a/dto/tokopedia.go +++ b/dto/tokopedia.go @@ -20,6 +20,7 @@ var ( ErrNotTokopediaUrls = errors.New("invalid domain, only tokopedia.com urls are accepted") ErrProductId = errors.New("failed to extract product id") ErrShopAvatarNotFound = errors.New("shop avatar not found") + ErrProductNotFound = errors.New("product not found") ) type ProductReviewResponseTokopedia struct { diff --git a/service/tokopedia.go b/service/tokopedia.go index bd1bb6e..620d249 100644 --- a/service/tokopedia.go +++ b/service/tokopedia.go @@ -72,6 +72,11 @@ func (s *tokopediaService) GetProduct(ctx context.Context, req dto.GetProductReq return dto.GetProductResponse{}, dto.ErrParseJson } + // Check for errors in the response + if errors, ok := response["errors"].([]interface{}); ok && len(errors) > 0 { + return dto.GetProductResponse{}, dto.ErrProductNotFound + } + // Extracting necessary data productData := response["data"].(map[string]interface{})["pdpGetLayout"].(map[string]interface{})["components"].([]interface{}) var productName string From 723102755fe89b6b4b13cdcd63de889d451a3542 Mon Sep 17 00:00:00 2001 From: Java Kanaya Prada <87474722+javakanaya@users.noreply.github.com> Date: Wed, 19 Jun 2024 00:21:27 +0700 Subject: [PATCH 2/3] docs: update cloud architecture image on README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bb8c8ce..2a3121f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ Welcome to the backend repository for the Ulascan: Bangkit 2024 Batch 6 capstone The API documentation for this project can be found [here](https://www.postman.com/supply-administrator-61638669/workspace/ulascan/folder/36341500-c7118b3a-2f29-4fcd-9e08-9641cf52d5a8). ## Backend and Cloud Architecture -![KELOMPOK MAS ACLYS](https://github.com/Ulas-Scan/UlaScan_BE/assets/87474722/c6f832e5-9ceb-4243-a9f6-095b89dae825) +![Cloud Architecture](https://github.com/Ulas-Scan/UlaScan_BE/assets/87474722/cbcc7a9a-36c3-4212-9f1a-7d2afe5e0e2e) + ## Local Installation for Development From 6d1fdb7ebc4325e50406ed602a246f566c345296 Mon Sep 17 00:00:00 2001 From: Java Kanaya Prada Date: Wed, 19 Jun 2024 00:29:50 +0700 Subject: [PATCH 3/3] feat: set token expiresAt to 7 days --- service/jwt.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/jwt.go b/service/jwt.go index 6180466..9be9c95 100644 --- a/service/jwt.go +++ b/service/jwt.go @@ -46,7 +46,7 @@ func (j *jwtService) GenerateToken(userId string, role string) string { userId, role, jwt.RegisteredClaims{ - ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Minute * 2)), + ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour * 24 * 7)), Issuer: j.issuer, IssuedAt: jwt.NewNumericDate(time.Now()), },