Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit 1202ad9

Browse files
committed
feat(response): add GetProperties helper function in Object
1 parent 2d3d925 commit 1202ad9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

response.go

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dothill
22

33
import (
44
"encoding/xml"
5+
"fmt"
56
"strconv"
67
"strings"
78
"time"
@@ -91,6 +92,20 @@ func (res *Response) GetStatus() *ResponseStatus {
9192
}
9293
}
9394

95+
func (object *Object) GetProperties(names ...string) ([]*Property, error) {
96+
var properties []*Property
97+
98+
for _, name := range names {
99+
if property, ok := object.PropertiesMap[name]; ok {
100+
properties = append(properties, property)
101+
} else {
102+
return nil, fmt.Errorf("missing property %q", name)
103+
}
104+
}
105+
106+
return properties, nil
107+
}
108+
94109
func fillObjectMap(obj *Object) {
95110
obj.PropertiesMap = make(map[string]*Property)
96111

0 commit comments

Comments
 (0)