From 56bbdd1393e96a3b57f128500086204a7de6d084 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 15 Jan 2019 17:58:46 +0800 Subject: [PATCH] add price func struct --- modules/apiact/tcgplayer.go | 57 ++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/modules/apiact/tcgplayer.go b/modules/apiact/tcgplayer.go index e4027da..505362d 100644 --- a/modules/apiact/tcgplayer.go +++ b/modules/apiact/tcgplayer.go @@ -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 @@ -122,16 +123,16 @@ func (p *TCGPlayer) GetToken() (err error) { // TCGPlayerCategory - type TCGPlayerCategory struct { - CaegoryID int `json:"categoryId"` - Name string `json:"name"` - DisplayName string `json:"displayName"` - ModifiedOn time.Time `json:"modifiedOn"` - SEOCategoryName string `json:"seoCategoryName"` - SealedLabel string `json:"sealedLabel"` - NonSealedLabel string `json:"nonSealedLabel"` - ConditionGuideURL string `json:"conditionGuideUrl"` - IsScannable bool `json:"isScannable"` - Popularity int `json:"popularity"` + CaegoryID int `json:"categoryId"` + Name string `json:"name"` + DisplayName string `json:"displayName"` + ModifiedOn string `json:"modifiedOn"` + SEOCategoryName string `json:"seoCategoryName"` + SealedLabel string `json:"sealedLabel"` + NonSealedLabel string `json:"nonSealedLabel"` + ConditionGuideURL string `json:"conditionGuideUrl"` + IsScannable bool `json:"isScannable"` + Popularity int `json:"popularity"` } // ListCategory - @@ -197,18 +198,18 @@ func (p *TCGPlayer) ListCategory(limit, offset int) (category []*TCGPlayerCatego // TCGPlayerCategoryGroup - type TCGPlayerCategoryGroup struct { - GroupID int `json:"groupId"` - Name string `json:"name"` - Abbreviation string `json:"abbreviation"` - Supplemental bool `json:"supplemental"` - PublishedOn string `json:"publishedOn"` - ModifiedOn time.Time `json:"modifiedOn"` - Category TCGPlayerCategory `json:"category"` + GroupID int `json:"groupId"` + Name string `json:"name"` + Abbreviation string `json:"abbreviation"` + Supplemental bool `json:"supplemental"` + PublishedOn string `json:"publishedOn"` + 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 +}