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 pathproject.go
152 lines (143 loc) · 5.76 KB
/
project.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package opendsd
import (
"encoding/json"
"fmt"
"io"
)
type Project struct {
Customers []struct {
ProjectID int `json:"ProjectId"`
CustomerID int `json:"CustomerId"`
Role string `json:"Role"`
FirmName string `json:"FirmName"`
Name string `json:"Name"`
} `json:"Customers"`
ReviewCycles []struct {
ReviewCycleID int `json:"ReviewCycleId"`
CycleNum int `json:"CycleNum"`
Method string `json:"Method"`
Status string `json:"Status"`
StatusSequence int `json:"StatusSequence"`
SubmitDate interface{} `json:"SubmitDate"`
DueDate interface{} `json:"DueDate"`
CloseDate interface{} `json:"CloseDate"`
Performance interface{} `json:"Performance"`
Reviews []struct {
ReviewCycleID int `json:"ReviewCycleId"`
ReviewID int `json:"ReviewId"`
Discipline string `json:"Discipline"`
Status string `json:"Status"`
DueDate interface{} `json:"DueDate"`
CompletedDate interface{} `json:"CompletedDate"`
Performance string `json:"Performance"`
Name string `json:"Name"`
Phone string `json:"Phone"`
Email string `json:"Email"`
IsActive bool `json:"IsActive"`
} `json:"Reviews"`
} `json:"ReviewCycles"`
Jobs []struct {
SignOffs []struct {
DisciplineID int `json:"DisciplineId"`
DisciplineDescription string `json:"DisciplineDescription"`
SignedDate string `json:"SignedDate"`
} `json:"SignOffs"`
ApprovalInfo []interface{} `json:"ApprovalInfo"`
Approvals []struct {
JobID int `json:"JobId"`
ApprovalID int `json:"ApprovalId"`
Type string `json:"Type"`
Status string `json:"Status"`
Scope string `json:"Scope"`
Depiction string `json:"Depiction"`
IssuedBy string `json:"IssuedBy"`
IssueDate Timestamp `json:"IssueDate"`
FirstInspectionDate Timestamp `json:"FirstInspectionDate"`
CompleteCancelDate Timestamp `json:"CompleteCancelDate"`
PermitHolder string `json:"PermitHolder"`
NetChangeDU string `json:"NetChangeDU"`
Valuation string `json:"Valuation"`
SquareFootage interface{} `json:"SquareFootage"`
} `json:"Approvals"`
ProjectID int `json:"ProjectId"`
JobID int `json:"JobId"`
Description string `json:"Description"`
APN string `json:"APN"`
StreetAddress string `json:"StreetAddress"`
MapReference string `json:"MapReference"`
SortableStreetAddress string `json:"SortableStreetAddress"`
Latitude float64 `json:"Latitude"`
Longitude float64 `json:"Longitude"`
NAD83Northing interface{} `json:"NAD83Northing"`
NAD83Easting interface{} `json:"NAD83Easting"`
JobFeesSubTotal interface{} `json:"JobFeesSubTotal"`
} `json:"Jobs"`
Fees []struct {
FeeID int `json:"FeeId"`
Description string `json:"Description"`
Category string `json:"Category"`
Unit string `json:"Unit"`
QuantityRequired int `json:"QuantityRequired"`
QuantityPaid int `json:"QuantityPaid"`
InvoiceID int `json:"InvoiceId"`
InvoiceStatus string `json:"InvoiceStatus"`
ProjectID int `json:"ProjectId"`
} `json:"Fees"`
Invoices []struct {
InvoiceID int `json:"InvoiceId"`
InvoiceIssueDate string `json:"InvoiceIssueDate"`
InvoiceStatus string `json:"InvoiceStatus"`
ProjectID int `json:"ProjectId"`
} `json:"Invoices"`
ProjectID int `json:"ProjectId"`
Title string `json:"Title"`
Scope string `json:"Scope"`
ApplicationExpiration Timestamp `json:"ApplicationExpiration"`
ApplicationExpired bool `json:"ApplicationExpired"`
AdminHold bool `json:"AdminHold"`
DevelopmentID int `json:"DevelopmentId"`
DevelopmentTitle string `json:"DevelopmentTitle"`
ApplicationDate Timestamp `json:"ApplicationDate"`
AccountNum string `json:"AccountNum"`
JobOrderNum interface{} `json:"JobOrderNum"`
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"`
ProjectManagerID int `json:"ProjectManagerId"`
ProjectManager struct {
ProjectManagerID int `json:"ProjectManagerId"`
Name string `json:"Name"`
PhoneNum string `json:"PhoneNum"`
EmailAddress string `json:"EmailAddress"`
ActiveIndicator bool `json:"ActiveIndicator"`
} `json:"ProjectManager"`
}
func DecodeProject(r io.Reader) (*Project, error) {
var err error
var project Project
if err = json.NewDecoder(r).Decode(&project); err != nil {
return nil, err
}
return &project, nil
}
func (c *Client) ProjectByID(id int) (*Project, error) {
var err error
var p Project
uri := fmt.Sprintf("/project/%v", id)
if err = c.get(uri, &p); err != nil {
return nil, err
}
// this is necessary since the API does not report a 404 on not found responses
if p.ProjectID != id {
return nil, APIError{
ErrorMessage: fmt.Sprintf("Project with ID: %v could not be found.", id),
}
}
return &p, nil
}