Skip to content

Commit

Permalink
Merge pull request #21 from Ulas-Scan/development
Browse files Browse the repository at this point in the history
Error Checking for Product Not Found, New Token Expiration
  • Loading branch information
javakanaya authored Jun 18, 2024
2 parents aba6747 + 872a5dc commit 6b951ce
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions dto/tokopedia.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion service/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
},
Expand Down
5 changes: 5 additions & 0 deletions service/tokopedia.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b951ce

Please sign in to comment.