-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.go
35 lines (32 loc) · 991 Bytes
/
map.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
package dnas
import (
"context"
"fmt"
"net/http"
)
// GetHierarchy returns the Map hierarchy and includes campus, buildings and floors.
func (s *MapService) GetHierarchy(ctx context.Context) (MapHierarchyResponse, error) {
mhr := MapHierarchyResponse{}
url := fmt.Sprintf("%s/map/hierarchy", s.client.BaseURL)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return mhr, err
}
if err := s.client.makeRequest(ctx, req, &mhr); err != nil {
return mhr, err
}
return mhr, nil
}
// GetMapElement retrieves a map element using it's identifier. The elements are campus, buildings and floors.
func (s *MapService) GetMapElement(ctx context.Context, id string) (MapElementResponse, error) {
mer := MapElementResponse{}
url := fmt.Sprintf("%s/map/elements/%s", s.client.BaseURL, id)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return mer, err
}
if err := s.client.makeRequest(ctx, req, &mer); err != nil {
return mer, err
}
return mer, nil
}