-
Notifications
You must be signed in to change notification settings - Fork 3
/
serverStructs.go
237 lines (200 loc) · 8.02 KB
/
serverStructs.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package structs
import (
"encoding/json"
"errors"
)
//This file is all of the structs that will come back from the WSO2 services
//Timesheet gives all data about the current clock state for an employee and his/her jobs
type Timesheet struct {
//BYUID is the byu id
BYUID string `json:"byu_id"`
//PersonName is the person's name in Last, First format
PersonName string `json:"person_name"`
//WeeklyTotal is the total hours worked so far in the week in format h:mm (string)
WeeklyTotal string `json:"weekly_total"`
//PeriodTotal is the total hours worked so far in the pay period in format h:mm (string)
PeriodTotal string `json:"period_total"`
//Jobs is the array containing current clock intformation about each job
Jobs []Job `json:"jobs"`
//InternationalMessage is used to indicate that a warning should be shown to the user due to hour working limits
InternationalMessage string `json:"international_message"`
// International is going away in a new version of the api
International bool `json:"international"`
}
//EmployeeCache is the cache list
type EmployeeCache struct {
Employees []EmployeeRecord `json:"employees"`
}
//EmployeeRecord comes back in the cache list
type EmployeeRecord struct {
BYUID string `json:"byu_id"`
NETID string `json:"net_id"`
Jobs []Job `json:"jobs"`
Name string `json:"sort_name"`
}
//Job represents the current state of an employee's job
type Job struct {
JobCodeDesc string `json:"job_code_description"`
PunchType string `json:"punch_type"`
EmployeeRecord int `json:"employee_record"`
WeeklySubtotal string `json:"weekly_subtotal"`
PeriodSubtotal string `json:"period_subtotal"`
PhysicalFacilities *bool `json:"physical_facilities,omitempty"`
OperatingUnit string `json:"operating_unit"`
TRCs []TRC `json:"trcs"`
CurrentWorkOrder WorkOrder `json:"current_work_order"`
CurrentTRC TRC `json:"current_trc"`
FullPartTime string `json:"full_part_time"`
HasPunchException *bool `json:"has_punch_exception,omitempty"`
HasWorkOrderException *bool `json:"has_work_order_exception,omitempty"`
}
func (j *Job) UnmarshalJSON(data []byte) error {
type Alias Job
aux := &struct {
PhysicalFacilities string `json:"physical_facilities,omitempty"`
*Alias
}{
Alias: (*Alias)(j),
}
if err := json.Unmarshal(data, &aux); err != nil {
var jerr *json.UnmarshalTypeError
if errors.As(err, &jerr) && jerr.Field == "physical_facilities" && jerr.Value == "bool" {
aux2 := &struct {
*Alias
}{
Alias: (*Alias)(j),
}
if err := json.Unmarshal(data, aux2); err != nil {
return err
}
return nil
}
}
if aux.PhysicalFacilities == "N" {
j.PhysicalFacilities = newFalse()
} else {
j.PhysicalFacilities = newTrue()
}
return nil
}
func newTrue() *bool {
b := true
return &b
}
func newFalse() *bool {
b := false
return &b
}
//TRC is a code for the type of hours that an employee can punch in under
type TRC struct {
TRCID string `json:"trc_id"`
TRCDescription string `json:"trc_description"`
}
//WorkOrder is ID and description for a work order
type WorkOrder struct {
WorkOrderID string `json:"work_order_id"`
WorkOrderDescription string `json:"work_order_description"`
}
//TimeClockDay represents a day with activity on the clock
type TimeClockDay struct {
Date string `json:"date"`
HasPunchException *bool `json:"has_punch_exception,omitempty"`
HasWorkOrderException *bool `json:"has_work_order_exception,omitempty"`
Punches []Punch `json:"punches"`
PunchedHours string `json:"punched_hours"`
}
//Punch represents a single punch in or out for an employee
type Punch struct {
PunchType string `json:"punch_type"`
PunchTime string `json:"punch_time"`
SequenceNumber *int `json:"sequence_number,omitempty"`
DeletablePair *int `json:"deletable_pair,omitempty"`
Latitude *string `json:"latitude,omitempty"`
Longitude *string `json:"longitude,omitempty"`
LocationDescription *string `json:"location_description,omitempty"`
TimeCollectionSource *string `json:"time_collection_source,omitempty"`
WorkOrderID *string `json:"work_order_id,omitempty"`
TRCID *string `json:"trc_id,omitempty"`
PunchDate *string `json:"punch_date,omitempty"`
EmployeeRecord *int `json:"employee_record,omitempty"`
PunchZone *string `json:"punch_zone,omitempty"`
InternetAddress *string `json:"internet_address,omitempty"`
}
//WorkOrderDaySummary is returned when querying a date for work orders logged on that date
type WorkOrderDaySummary struct {
Date string `json:"punch_date"`
WorkOrderEntries []WorkOrderEntry `json:"work_order_entries"`
ReportedHours string `json:"reported_hours"`
PhysicalFacilitiesHours string `json:"physical_facilities_hours"`
OtherHours string `json:"other_hours"`
HasPunchException *bool `json:"has_punch_exception,omitempty"`
HasWorkOrderException *bool `json:"has_work_order_exception,omitempty"`
}
//WorkOrderEntry represents a single work order logged for part of a day
type WorkOrderEntry struct {
WorkOrder WorkOrder `json:"work_order"`
TRC TRC `json:"trc"`
TimeReportingCodeHours string `json:"time_reporting_code_hours"`
SequenceNumber int `json:"sequence_number"`
Editable bool `json:"editable"`
//these only used when posting
EmployeeRecord int `json:"employee_record"`
}
//ElapsedTimeSummary is the parent structure for sick and vacation hours
type ElapsedTimeSummary struct {
SickLeaveBalanceHours string `json:"sick_leave_balance_hours"`
VacationLeaveBalanceHours string `json:"vacation_leave_balance_hours"`
Dates []ElapsedTimeDay `json:"elapsed_time_dates"`
}
//ElapsedTimeDay is the parent structure for sick and vacation hours for a day
type ElapsedTimeDay struct {
PunchDate string `json:"punch_date"`
ElapsedTimeEntries []ElapsedTimeEntry `json:"punches"`
}
//ElapsedTimeEntry is the structure for a single amount of sick or vacation time
type ElapsedTimeEntry struct {
//these only come back when GETTING
Editable *bool `json:"editable,omitempty"`
TRC TRC `json:"trc"`
//these come back for GET and are used on POST
TimeReportingCodeHours string `json:"time_reporting_code_hours"`
SequenceNumber int `json:"sequence_number"`
EmployeeRecord int `json:"employee_record"`
//POST only
PunchDate string `json:"punch_date"`
TRCID string `json:"trc_id"`
TimeCollectionSource string `json:"time_collection_source"`
}
//ElapsedTimeEntryWrapper is th structure to use when POSTING sick or vacation
type ElapsedTimeEntryWrapper struct {
ElapsedTimeEntry ElapsedTimeEntry `json:"elapsed_time_entry"`
}
//DeleteWorkOrderEntry .
type DeleteWorkOrderEntry struct {
JobID int `json:"employee-job-id"`
Date string `json:"date"`
SequenceNumber int `json:"sequence-number"`
}
//YTimeLocation .
type YTimeLocation struct {
YtimeLocation string `json:"ytime_location"`
UpdatedByName string `json:"updated_by_name"`
LocationSource string `json:"location_source"`
YtimeLocationCode string `json:"ytime_location_code"`
UpdatedDatetime interface{} `json:"updated_datetime"`
Latitude float64 `json:"latitude"`
YtimeLocationAbbreviation string `json:"ytime_location_abbreviation"`
Status string `json:"status"`
Longitude float64 `json:"longitude"`
}
//ServerErrorMessage .
type ServerErrorMessage struct {
Message string `json:"message"`
}
//ServerLoginErrorMessage .
type ServerLoginErrorMessage struct {
Status struct {
Code string `json:"code"`
Message string `json:"message"`
}
}