-
Notifications
You must be signed in to change notification settings - Fork 0
/
EAD.go
36 lines (28 loc) · 1.06 KB
/
EAD.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
package aspace
import (
"fmt"
"io"
)
func (a *ASClient) GetEADAsByteArray(repositoryId int, resourceId int, unpublished bool) ([]byte, error) {
eadBytes := []byte{}
endpoint := fmt.Sprintf("/repositories/%d/resource_descriptions/%d.xml?include_unpublished=%t&include_daos=%t&numbered_cs=%t&ead3=%t&print_pdf=%t", repositoryId, resourceId, unpublished, true, false, false, false)
response, err := a.get(endpoint, true)
if err != nil {
return eadBytes, err
}
eadBytes, err = io.ReadAll(response.Body)
return eadBytes, err
}
func (a *ASClient) SerializeEAD(repositoryId int, resourceId int, daos bool, unpub bool, num_cs bool, ead3 bool, pdf bool) ([]byte, error) {
var ead []byte = []byte{}
endpoint := fmt.Sprintf("/repositories/%d/resource_descriptions/%d.xml?include_unpublished=%t&include_daos=%t&numbered_cs=%t&ead3=%t&print_pdf=%t", repositoryId, resourceId, unpub, daos, num_cs, ead3, pdf)
response, err := a.get(endpoint, true)
if err != nil {
return ead, err
}
ead, err = io.ReadAll(response.Body)
if err != nil {
return ead, err
}
return ead, nil
}