1. add cron module
2. add pool module
3. add tcgplayer background job
4. add card price model
This commit is contained in:
Jay
2019-01-16 16:53:08 +08:00
parent 6a41584aa2
commit 273278d322
68 changed files with 10668 additions and 5 deletions
+44 -1
View File
@@ -285,5 +285,48 @@ type TCGPlayerProductPrice struct {
// ListGroupProductPrice -
func (p *TCGPlayer) ListGroupProductPrice(groupID int) (prices []*TCGPlayerProductPrice, err error) {
return
apiURL, err := p.getAPIURL(fmt.Sprintf("/pricing/group/%d", groupID), true)
if err != nil {
return nil, err
}
tmpStruct := struct {
TCGPlayerAPIRes
Results []*TCGPlayerProductPrice `json:"results"`
}{}
reqObj := RequestObject{
URL: apiURL,
Headers: p.getHeader(),
Method: "GET",
}
req, err := GetRequest(reqObj)
if err != nil {
return nil, err
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
respByte, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
err = json.Unmarshal(respByte, &tmpStruct)
if err != nil {
return nil, err
}
if tmpStruct.Success != true {
if len(tmpStruct.Errors) > 0 {
return nil, errors.New(tmpStruct.Errors[0])
}
return nil, errors.New("get product price fail")
}
return tmpStruct.Results, nil
}