Just a whole bunch of fixing

This commit is contained in:
2018-07-09 21:41:17 +02:00
parent 5633460b97
commit 9c7b79403e
25 changed files with 208 additions and 320 deletions

View File

@@ -26,7 +26,7 @@ type FileInfo struct {
}
// GetFileInfo gets the FileInfo from the pixeldrain API
func (p *PixelAPI) GetFileInfo(id string) (resp *FileInfo, err *Error) {
func (p *PixelAPI) GetFileInfo(id string) (resp *FileInfo, err error) {
resp = &FileInfo{}
err = p.jsonRequest("GET", p.apiEndpoint+"/file/"+id+"/info", resp)
if err != nil {

View File

@@ -27,7 +27,7 @@ type ListFile struct {
// GetList get a List from the pixeldrain API. Errors will be available through
// List.Error. Standard error checks apply.
func (p *PixelAPI) GetList(id string) (resp *List, err *Error) {
func (p *PixelAPI) GetList(id string) (resp *List, err error) {
resp = &List{}
err = p.jsonRequest("GET", p.apiEndpoint+"/list/"+id, resp)
if err != nil {

View File

@@ -4,7 +4,7 @@ type Recaptcha struct {
SiteKey string `json:"site_key"`
}
func (p *PixelAPI) GetRecaptcha() (resp *Recaptcha, err *Error) {
func (p *PixelAPI) GetRecaptcha() (resp *Recaptcha, err error) {
err = p.jsonRequest("GET", p.apiEndpoint+"/misc/recpatcha", resp)
if err != nil {
return nil, err

View File

@@ -45,7 +45,7 @@ type SuccessResponse struct {
Success bool `json:"success"`
}
func (p *PixelAPI) jsonRequest(method, url string, target interface{}) *Error {
func (p *PixelAPI) jsonRequest(method, url string, target interface{}) error {
req, err := http.NewRequest(method, url, nil)
if err != nil {
return &Error{
@@ -116,7 +116,7 @@ func (p *PixelAPI) getRaw(url string) (io.ReadCloser, error) {
return resp.Body, err
}
func (p *PixelAPI) postForm(url string, vals url.Values, target interface{}) *Error {
func (p *PixelAPI) postForm(url string, vals url.Values, target interface{}) error {
req, err := http.NewRequest("POST", url, strings.NewReader(vals.Encode()))
if err != nil {
return &Error{
@@ -145,7 +145,7 @@ func (p *PixelAPI) postForm(url string, vals url.Values, target interface{}) *Er
return parseJSONResponse(resp, target)
}
func parseJSONResponse(resp *http.Response, target interface{}) *Error {
func parseJSONResponse(resp *http.Response, target interface{}) error {
var jdec = json.NewDecoder(resp.Body)
var err error

View File

@@ -21,7 +21,7 @@ type RegistrationError struct {
// never be able to reset your password in case you forget it. captcha depends
// on whether reCaptcha is enabled on the Pixeldrain server, this can be checked
// through the GetRecaptcha function.
func (p *PixelAPI) UserRegister(username, email, password, captcha string) (resp *Registration, err *Error) {
func (p *PixelAPI) UserRegister(username, email, password, captcha string) (resp *Registration, err error) {
resp = &Registration{}
var form = url.Values{}
form.Add("username", username)
@@ -42,7 +42,7 @@ type UserInfo struct {
}
// UserInfo returns information about the logged in user. Requires an API key
func (p *PixelAPI) UserInfo() (resp *UserInfo, err *Error) {
func (p *PixelAPI) UserInfo() (resp *UserInfo, err error) {
resp = &UserInfo{}
err = p.jsonRequest("GET", p.apiEndpoint+"/user", resp)
if err != nil {
@@ -53,7 +53,7 @@ func (p *PixelAPI) UserInfo() (resp *UserInfo, err *Error) {
// UserSessionDestroy destroys an API key so it can no longer be used to perform
// actions
func (p *PixelAPI) UserSessionDestroy(key string) (resp *SuccessResponse, err *Error) {
func (p *PixelAPI) UserSessionDestroy(key string) (resp *SuccessResponse, err error) {
resp = &SuccessResponse{}
err = p.jsonRequest("DELETE", p.apiEndpoint+"/user/session", resp)
if err != nil {
@@ -67,7 +67,7 @@ type UserFiles struct {
Files []FileInfo `json:"files"`
}
func (p *PixelAPI) UserFiles(page, limit int) (resp *UserFiles, err *Error) {
func (p *PixelAPI) UserFiles(page, limit int) (resp *UserFiles, err error) {
resp = &UserFiles{Files: make([]FileInfo, 0)}
err = p.jsonRequest(
"GET",