You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
451 B
20 lines
451 B
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
const BaseURL = "https://api.servicetrade.com/api"
|
|
|
|
// DecodeJSONResponse decodes a JSON response into the provided interface
|
|
func DecodeJSONResponse(resp *http.Response, v interface{}) error {
|
|
defer resp.Body.Close()
|
|
|
|
if resp.StatusCode != http.StatusOK {
|
|
return fmt.Errorf("API request failed with status code: %d", resp.StatusCode)
|
|
}
|
|
|
|
return json.NewDecoder(resp.Body).Decode(v)
|
|
}
|
|
|