-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspaces.go
More file actions
35 lines (30 loc) · 790 Bytes
/
spaces.go
File metadata and controls
35 lines (30 loc) · 790 Bytes
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
package gontentful
import (
"bytes"
"encoding/json"
"fmt"
"net/url"
)
type SpacesService service
func (s *SpacesService) Get(query url.Values) ([]byte, error) {
path := fmt.Sprintf(pathSpaces, s.client.Options.SpaceID)
return s.client.get(path, query)
}
func (s *SpacesService) GetSpace() (*Space, error) {
data, err := s.Get(nil)
if err != nil {
return nil, err
}
res := &Space{}
err = json.Unmarshal(data, &res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *SpacesService) Create(body []byte) ([]byte, error) {
path := pathSpacesCreate
s.client.headers[headerContentType] = "application/vnd.contentful.management.v1+json"
s.client.headers[headerContentfulOrganization] = s.client.Options.OrgID
return s.client.post(path, bytes.NewBuffer(body))
}