This repository has been archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcode_enforcement.go
76 lines (67 loc) · 2.56 KB
/
code_enforcement.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package opendsd
import (
"encoding/json"
"fmt"
"io"
)
type CodeEnforcement struct {
Complaints []struct {
ComplaintType string `json:"ComplaintType"`
CaseID int `json:"CaseId"`
} `json:"Complaints"`
CaseID int `json:"CaseId"`
CaseSource string `json:"CaseSource"`
Description string `json:"Description"`
OpenDate Timestamp `json:"OpenDate"`
CloseDate Timestamp `json:"CloseDate"`
StreetAddress string `json:"StreetAddress"`
SortableStreetAddress string `json:"SortableStreetAddress"`
CloseNote string `json:"CloseNote"`
CloseReason string `json:"CloseReason"`
APN string `json:"APN"`
MapReference string `json:"MapReference"`
Longitude float64 `json:"Longitude"`
Latitude float64 `json:"Latitude"`
NAD83Northing string `json:"NAD83Northing"`
NAD83Easting string `json:"NAD83Easting"`
Workgroup string `json:"Workgroup"`
InvestigatorName string `json:"InvestigatorName"`
InvestiagtorPhone string `json:"InvestiagtorPhone"`
InvestigatorActive string `json:"InvestigatorActive"`
InvestigatorEmail string `json:"InvestigatorEmail"`
LastAction string `json:"LastAction"`
LastActionDueDate string `json:"LastActionDueDate"`
RemedyMsg string `json:"RemedyMsg"`
Header []struct {
Jurisdiction string `json:"Jurisdiction"`
Agency string `json:"Agency"`
AgencyAddress string `json:"AgencyAddress"`
AgencyWebsite string `json:"AgencyWebsite"`
ExtractSystem string `json:"ExtractSystem"`
ExtractDate HeaderExtractTimestamp `json:"ExtractDate"`
ExtractQuery string `json:"ExtractQuery"`
} `json:"Header"`
}
func DecodeCodeEnforcement(r io.Reader) (*CodeEnforcement, error) {
var err error
var ce CodeEnforcement
if err = json.NewDecoder(r).Decode(&ce); err != nil {
return nil, err
}
return &ce, nil
}
func (c *Client) CodeEnforcementByID(id int) (*CodeEnforcement, error) {
var err error
var ce CodeEnforcement
uri := fmt.Sprintf("/codeenforcement/%v", id)
if err = c.get(uri, &ce); err != nil {
return nil, err
}
// this is necessary since the API does not report a 404 on not found responses
if ce.CaseID != id {
return nil, APIError{
ErrorMessage: fmt.Sprintf("CodeEnforcement with ID: %v could not be found.", id),
}
}
return &ce, nil
}