add price func struct

This commit is contained in:
Jay 2019-01-15 17:58:46 +08:00
parent 97af1343d4
commit 56bbdd1393

View File

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"strconv"
@ -61,7 +62,7 @@ func (p *TCGPlayer) getHeader() map[string]string {
// NewTCGApi -
func NewTCGApi(apiVersion string) (api *TCGPlayer, err error) {
if len(apiVersion) == 0 {
apiVersion = "1.19.0"
apiVersion = "v1.19.0"
}
api = &TCGPlayer{}
api.APIVersion = apiVersion
@ -125,7 +126,7 @@ type TCGPlayerCategory struct {
CaegoryID int `json:"categoryId"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
ModifiedOn time.Time `json:"modifiedOn"`
ModifiedOn string `json:"modifiedOn"`
SEOCategoryName string `json:"seoCategoryName"`
SealedLabel string `json:"sealedLabel"`
NonSealedLabel string `json:"nonSealedLabel"`
@ -202,13 +203,13 @@ type TCGPlayerCategoryGroup struct {
Abbreviation string `json:"abbreviation"`
Supplemental bool `json:"supplemental"`
PublishedOn string `json:"publishedOn"`
ModifiedOn time.Time `json:"modifiedOn"`
Category TCGPlayerCategory `json:"category"`
ModifiedOn string `json:"modifiedOn"`
CategoryID int `json:"categoryId"`
}
// ListCategoryGroups -
func (p *TCGPlayer) ListCategoryGroups(categoryID, limit, offset int) (groups []*TCGPlayerCategoryGroup, err error) {
apiURL, err := p.getAPIURL(fmt.Sprintf("/catalog/categories/%d", categoryID), true)
apiURL, err := p.getAPIURL(fmt.Sprintf("/catalog/categories/%d/groups", categoryID), true)
if err != nil {
return nil, err
}
@ -254,6 +255,8 @@ func (p *TCGPlayer) ListCategoryGroups(categoryID, limit, offset int) (groups []
return nil, err
}
log.Println(string(respByte))
err = json.Unmarshal(respByte, &tmpStruct)
if err != nil {
return nil, err
@ -268,3 +271,19 @@ func (p *TCGPlayer) ListCategoryGroups(categoryID, limit, offset int) (groups []
return tmpStruct.Results, nil
}
// TCGPlayerProductPrice -
type TCGPlayerProductPrice struct {
ProductID int `json:"productId"`
LowPrice float32 `json:"lowPrice"`
MidPrice float32 `json:"midPrice"`
HighPrice float32 `json:"highPrice"`
MarketPrice float32 `json:"marketPrice"`
DirectLowPrice float32 `json:"directLowPrice"`
SubTypeName string `json:"subTypeName"`
}
// ListGroupProductPrice -
func (p *TCGPlayer) ListGroupProductPrice(groupID int) (prices []*TCGPlayerProductPrice, err error) {
return
}