add price func struct
This commit is contained in:
parent
97af1343d4
commit
56bbdd1393
@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -61,7 +62,7 @@ func (p *TCGPlayer) getHeader() map[string]string {
|
|||||||
// NewTCGApi -
|
// NewTCGApi -
|
||||||
func NewTCGApi(apiVersion string) (api *TCGPlayer, err error) {
|
func NewTCGApi(apiVersion string) (api *TCGPlayer, err error) {
|
||||||
if len(apiVersion) == 0 {
|
if len(apiVersion) == 0 {
|
||||||
apiVersion = "1.19.0"
|
apiVersion = "v1.19.0"
|
||||||
}
|
}
|
||||||
api = &TCGPlayer{}
|
api = &TCGPlayer{}
|
||||||
api.APIVersion = apiVersion
|
api.APIVersion = apiVersion
|
||||||
@ -122,16 +123,16 @@ func (p *TCGPlayer) GetToken() (err error) {
|
|||||||
|
|
||||||
// TCGPlayerCategory -
|
// TCGPlayerCategory -
|
||||||
type TCGPlayerCategory struct {
|
type TCGPlayerCategory struct {
|
||||||
CaegoryID int `json:"categoryId"`
|
CaegoryID int `json:"categoryId"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
DisplayName string `json:"displayName"`
|
DisplayName string `json:"displayName"`
|
||||||
ModifiedOn time.Time `json:"modifiedOn"`
|
ModifiedOn string `json:"modifiedOn"`
|
||||||
SEOCategoryName string `json:"seoCategoryName"`
|
SEOCategoryName string `json:"seoCategoryName"`
|
||||||
SealedLabel string `json:"sealedLabel"`
|
SealedLabel string `json:"sealedLabel"`
|
||||||
NonSealedLabel string `json:"nonSealedLabel"`
|
NonSealedLabel string `json:"nonSealedLabel"`
|
||||||
ConditionGuideURL string `json:"conditionGuideUrl"`
|
ConditionGuideURL string `json:"conditionGuideUrl"`
|
||||||
IsScannable bool `json:"isScannable"`
|
IsScannable bool `json:"isScannable"`
|
||||||
Popularity int `json:"popularity"`
|
Popularity int `json:"popularity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListCategory -
|
// ListCategory -
|
||||||
@ -197,18 +198,18 @@ func (p *TCGPlayer) ListCategory(limit, offset int) (category []*TCGPlayerCatego
|
|||||||
|
|
||||||
// TCGPlayerCategoryGroup -
|
// TCGPlayerCategoryGroup -
|
||||||
type TCGPlayerCategoryGroup struct {
|
type TCGPlayerCategoryGroup struct {
|
||||||
GroupID int `json:"groupId"`
|
GroupID int `json:"groupId"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Abbreviation string `json:"abbreviation"`
|
Abbreviation string `json:"abbreviation"`
|
||||||
Supplemental bool `json:"supplemental"`
|
Supplemental bool `json:"supplemental"`
|
||||||
PublishedOn string `json:"publishedOn"`
|
PublishedOn string `json:"publishedOn"`
|
||||||
ModifiedOn time.Time `json:"modifiedOn"`
|
ModifiedOn string `json:"modifiedOn"`
|
||||||
Category TCGPlayerCategory `json:"category"`
|
CategoryID int `json:"categoryId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListCategoryGroups -
|
// ListCategoryGroups -
|
||||||
func (p *TCGPlayer) ListCategoryGroups(categoryID, limit, offset int) (groups []*TCGPlayerCategoryGroup, err error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -254,6 +255,8 @@ func (p *TCGPlayer) ListCategoryGroups(categoryID, limit, offset int) (groups []
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println(string(respByte))
|
||||||
|
|
||||||
err = json.Unmarshal(respByte, &tmpStruct)
|
err = json.Unmarshal(respByte, &tmpStruct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -268,3 +271,19 @@ func (p *TCGPlayer) ListCategoryGroups(categoryID, limit, offset int) (groups []
|
|||||||
|
|
||||||
return tmpStruct.Results, nil
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user