Returned StarCityGames support

This commit is contained in:
Aryom Belousov 2020-11-09 15:24:32 +03:00
parent de1187b96c
commit 7c6a6176dc
12 changed files with 133 additions and 72 deletions

View file

@ -1,10 +1,15 @@
package cardsinfo
import (
"fmt"
"strings"
)
type CardPrice struct {
type CardPrice interface {
Format() string
}
type TcgCardPrice struct {
FullArt bool
Name string
Price string
@ -13,6 +18,27 @@ type CardPrice struct {
Edition string
}
func (t *TcgCardPrice) Format() string {
return fmt.Sprintf("%v\nRegular: %v\nFoil: %v\n%v\n", t.Edition, formatTcgPrice(t.Price), formatTcgPrice(t.PriceFoil), t.Link)
}
func formatTcgPrice(price string) string {
if price == "" {
return "-"
}
return fmt.Sprintf("$%v", price)
}
type ScgCardPrice struct {
Price string
Edition string
Link string
}
func (s *ScgCardPrice) Format() string {
return fmt.Sprintf("%v: %v\n%v\n", s.Edition, s.Price, s.Link)
}
type Card struct {
Name string `json:"name"`
Layout string `json:"layout"`
@ -24,20 +50,3 @@ func (c *Card) getName() string {
}
return c.Name
}
type ScgResponse struct {
Response ScgResponseContainer `json:"response"`
}
type ScgResponseContainer struct {
Data []ScgConditionContainer `json:"data"`
}
type ScgConditionContainer struct {
Price float64 `json:"price"`
OptionValues []ScgCondition `json:"option_values"`
}
type ScgCondition struct {
Label string `json:"label"`
}