-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmetadata.go
38 lines (30 loc) · 848 Bytes
/
metadata.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
package peloton
import (
"encoding/json"
"fmt"
"io/ioutil"
"github.com/jchenry/peloton/model"
)
//GetRideTypes return a list of RideTypes based on the SearchFilter
func GetClassTypes(c Client) ([]model.ClassType, error) {
a, err := metadataMappings(c)
return a.ClassTypes, err
}
//GetInstructors return a list of Instructors based on the SearchFilter
func GetInstructors(c Client) ([]model.Instructor, error) {
m, err := metadataMappings(c)
return m.Instructors, err
}
func metadataMappings(c Client) (*model.MetadataMappings, error) {
meta := &model.MetadataMappings{}
resp, err := c.HTTPClient.Get(fmt.Sprintf("%s/api/ride/metadata_mappings", apiBase))
if err != nil {
return meta, err
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err.Error())
}
err = json.Unmarshal(body, &meta)
return meta, err
}