package client import ( "fmt" "time" ) func QueryPrice(client *FhoClient, lastUpdatedTime time.Time) ([]*PriceSchedule, error) { data, err := client.query("station_price_updates", lastUpdatedTime) if err != nil { fmt.Println("query error:", err.Error()) return nil, err } var prices []*PriceSchedule pricesMap := make(map[string]*PriceSchedule) for _, rec := range data { _price, err := PriceScheduleFromMap(rec) if err != nil { return nil, err } if _, ok := pricesMap[_price.ID]; ok { _price = pricesMap[_price.ID] } else { pricesMap[_price.ID] = _price prices = append(prices, _price) } _product := PriceScheduleProductFromMap(rec) _price.PriceScheduleProducts = append(_price.PriceScheduleProducts, _product) } return prices, nil } func QueryProducts(client *FhoClient, lastUpdatedTime time.Time) ([]*Product, error) { data, err := client.query("products", lastUpdatedTime) if err != nil { fmt.Println("query error:", err.Error()) return nil, err } var products []*Product for _, rec := range data { _product := ProductFromMap(rec) products = append(products, _product) } return products, nil }