update cart actor
Some checks failed
Build and Publish / BuildAndDeploy (push) Failing after 3m44s
Build and Publish / BuildAndDeployAmd64 (push) Has been cancelled

This commit is contained in:
matst80
2025-04-18 15:22:58 +02:00
parent 10c52ac409
commit 1397822a1a
3 changed files with 92 additions and 197 deletions

View File

@@ -3,74 +3,19 @@ package main
import (
"encoding/json"
"net/http"
"github.com/matst80/slask-finder/pkg/index"
)
type EnergyRating struct {
Value string `json:"value,omitempty"`
Min string `json:"min,omitempty"`
Max string `json:"max,omitempty"`
}
/** end */
type PriceTuple struct {
IncVat int `json:"inc"`
ExVat int `json:"exl"`
}
type OutletItem struct {
ArticleNumber string `json:"sku,omitempty"`
Price PriceTuple `json:"price,omitempty"`
Title string `json:"title"`
}
type ItemProp struct {
Url string `json:"url"`
Disclaimer string `json:"disclaimer,omitempty"`
ReleaseDate string `json:"releaseDate,omitempty"`
SaleStatus string `json:"saleStatus"`
MarginPercent float64 `json:"mp,omitempty"`
PresaleDate string `json:"presaleDate,omitempty"`
Restock string `json:"restock,omitempty"`
AdvertisingText string `json:"advertisingText,omitempty"`
Img string `json:"img,omitempty"`
BadgeUrl string `json:"badgeUrl,omitempty"`
EnergyRating *EnergyRating `json:"energyRating,omitempty"`
BulletPoints string `json:"bp,omitempty"`
LastUpdate int64 `json:"lastUpdate,omitempty"`
Created int64 `json:"created,omitempty"`
Buyable bool `json:"buyable"`
Description string `json:"description,omitempty"`
BuyableInStore bool `json:"buyableInStore"`
BoxSize string `json:"boxSize,omitempty"`
CheapestBItem *OutletItem `json:"bItem,omitempty"`
AItem *OutletItem `json:"aItem,omitempty"`
}
type BaseItem struct {
ItemProp
StockLevel string `json:"stockLevel,omitempty"`
Stock LocationStock `json:"stock"`
Id uint `json:"id"`
Sku string `json:"sku"`
Title string `json:"title"`
}
type DataItem struct {
*BaseItem
Fields map[uint]interface{} `json:"values"`
}
type LocationStock []struct {
Id string `json:"id"`
Level string `json:"level"`
}
func FetchItem(sku string) (*DataItem, error) {
func FetchItem(sku string) (*index.DataItem, error) {
res, err := http.Get("https://slask-finder.tornberg.me/api/get/" + sku)
if err != nil {
return nil, err
}
defer res.Body.Close()
var item DataItem
var item index.DataItem
err = json.NewDecoder(res.Body).Decode(&item)
return &item, err
}