-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcosmetics.go
45 lines (34 loc) · 959 Bytes
/
cosmetics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package adidas_backend
import (
"fmt"
"github.com/google/uuid"
)
var (
BlankCosmetics = Cosmetics{
Image: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ee/Logo_brand_Adidas.png/608px-Logo_brand_Adidas.png",
Name: "NOT FOUND",
Price: "NOT FOUND",
Size: "NOT FOUND",
}
)
func GetCosmetics(checkoutIdResponse *CheckoutIdResponse) Cosmetics {
var cosmetics Cosmetics
if len(checkoutIdResponse.Items) < 1 {
return BlankCosmetics
}
product := checkoutIdResponse.Items[0]
cosmetics.Image = product.Product.Thumbnail
cosmetics.Name = product.Product.Name
cosmetics.Price = fmt.Sprint(product.Prices.Total.Current)
cosmetics.Size = product.Size.Name
return cosmetics
}
func GetOrderNumber(orderResponse *OrderResponse) string {
if len(orderResponse.ProductGroups) < 1 {
return uuid.NewString()
}
if len(orderResponse.ProductGroups[0].OrderItems) < 1 {
return uuid.NewString()
}
return orderResponse.OrderNumber
}