forked from peterssonjesper/booli-api-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresidence.go
37 lines (29 loc) · 906 Bytes
/
residence.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
package client
import (
"encoding/json"
"fmt"
)
// Residences fetches a (filtered) list of residences from the API
func (c *Client) Residences(optionalParams ...map[string]string) ([]byte, error) {
params := map[string]string{}
if len(optionalParams) > 0 {
params = optionalParams[0]
}
return c.Get("residences", params)
}
// Residence fetches a residence from the API
func (c *Client) Residence(residenceID int, optionalParams ...map[string]string) ([]byte, error) {
params := map[string]string{}
if len(optionalParams) > 0 {
params = optionalParams[0]
}
return c.Get(fmt.Sprintf("residences/%d", residenceID), params)
}
// Estimate will POST to /estimation-subscription
func (c *Client) SubscribeToEstimation(params map[string]interface{}) ([]byte, error) {
json, err := json.Marshal(params)
if err != nil {
return nil, err
}
return c.Post("estimation-subscriptions", json)
}