-
Notifications
You must be signed in to change notification settings - Fork 2
/
statuses.go
43 lines (37 loc) · 1.34 KB
/
statuses.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package wordpress
import (
"context"
"fmt"
)
// Status represents a WordPress post status.
type Status struct {
Name string `json:"name,omitempty"`
Private bool `json:"private,omitempty"`
Public bool `json:"public,omitempty"`
Queryable bool `json:"queryable,omitempty"`
ShowInList bool `json:"show_in_list,omitempty"`
Slug string `json:"slug,omitempty"`
}
// Statuses describes multiple Statuses.
type Statuses struct {
Publish Status `json:"publish,omitempty"`
Future Status `json:"future,omitempty"`
Draft Status `json:"draft,omitempty"`
Pending Status `json:"pending,omitempty"`
Private Status `json:"private,omitempty"`
}
// StatusesService provides access to the Status related functions in the WordPress REST API.
type StatusesService service
// List returns a list of statuses.
func (c *StatusesService) List(ctx context.Context, params interface{}) (*Statuses, *Response, error) {
var statuses Statuses
resp, err := c.client.List(ctx, "statuses", params, &statuses)
return &statuses, resp, err
}
// Get returns a single status for the given id.
func (c *StatusesService) Get(ctx context.Context, slug string, params interface{}) (*Status, *Response, error) {
var entity Status
entityURL := fmt.Sprintf("statuses/%v", slug)
resp, err := c.client.Get(ctx, entityURL, params, &entity)
return &entity, resp, err
}