update
1. add cron module 2. add pool module 3. add tcgplayer background job 4. add card price model
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user