From 8a88c703080348f0b989675c58e4052d2338e6aa Mon Sep 17 00:00:00 2001 From: meitar Date: Tue, 9 Oct 2018 14:07:56 +0300 Subject: [PATCH] bug fixes from original library --- client.go | 9 ++++++--- posts.go | 4 +++- terms.go | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index e1163ad..dbc6c39 100644 --- a/client.go +++ b/client.go @@ -3,11 +3,12 @@ package wordpress import ( "bytes" "fmt" - "github.com/parnurzeal/gorequest" "io/ioutil" "log" "net/http" "reflect" + + "github.com/parnurzeal/gorequest" ) const ( @@ -111,7 +112,7 @@ func (client *Client) Taxonomies() *TaxonomiesCollection { func (client *Client) Terms() *TermsCollection { return &TermsCollection{ client: client, - url: fmt.Sprintf("%v/%v", client.baseURL, CollectionTerms), + url: fmt.Sprintf("%v", client.baseURL), } } func (client *Client) Statuses() *StatusesCollection { @@ -141,7 +142,9 @@ func (client *Client) Create(url string, content interface{}, result interface{} contentVal := unpackInterfacePointer(content) client.req.TargetType = "json" req := client.req.Post(url).Send(contentVal) + fmt.Printf("\n\n\n%+v\n\n\n", req) resp, body, errSlice := req.EndBytes() + fmt.Printf("\n\n\n%+v\n\n\n", resp) if errSlice != nil && len(errSlice) > 0 { return nil, body, errSlice[len(errSlice)-1] } @@ -201,7 +204,7 @@ func (client *Client) PostData(url string, content []byte, contentType string, f } req.Header.Set("Content-Type", contentType) - req.Header.Set("Content-Disposition", fmt.Sprintf("filename=%v", filename)) + req.Header.Set("Content-Disposition", fmt.Sprintf("attachment; filename=%v", filename)) // Add basic auth req.SetBasicAuth(s.BasicAuth.Username, s.BasicAuth.Password) diff --git a/posts.go b/posts.go index e082b7a..201abd1 100644 --- a/posts.go +++ b/posts.go @@ -70,11 +70,13 @@ type Post struct { Content Content `json:"content,omitempty"` Author int `json:"author,omitempty"` Excerpt Excerpt `json:"excerpt,omitempty"` - FeaturedImage int `json:"featured_image,omitempty"` + FeaturedImage int `json:"featured_media,omitempty"` CommentStatus string `json:"comment_status,omitempty"` PingStatus string `json:"ping_status,omitempty"` Format string `json:"format,omitempty"` Sticky bool `json:"sticky,omitempty"` + Categories []int `json:"categories,omitempty"` + Tags []int `json:"tags,omitempty"` } func (entity *Post) setCollection(col *PostsCollection) { diff --git a/terms.go b/terms.go index 9c0e343..bbce63c 100644 --- a/terms.go +++ b/terms.go @@ -29,7 +29,7 @@ func (col *TermsCollection) List(taxonomy string, params interface{}) ([]Term, * func (col *TermsCollection) Tag() *TermsTaxonomyCollection { return &TermsTaxonomyCollection{ client: col.client, - url: fmt.Sprintf("%v/tag", col.url), + url: fmt.Sprintf("%v/tags", col.url), taxonomyBase: "tag", } }