-
Notifications
You must be signed in to change notification settings - Fork 1
/
team.go
381 lines (335 loc) · 10.3 KB
/
team.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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
// This file was auto-generated by Fern from our API Definition.
package square
import (
json "encoding/json"
fmt "fmt"
internal "github.com/square/square-go-sdk/internal"
)
type CreateJobRequest struct {
// The job to create. The `title` field is required and `is_tip_eligible` defaults to true.
Job *Job `json:"job,omitempty" url:"-"`
// A unique identifier for the `CreateJob` request. Keys can be any valid string,
// but must be unique for each request. For more information, see
// [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).
IdempotencyKey string `json:"idempotency_key" url:"-"`
}
type ListJobsRequest struct {
// The pagination cursor returned by the previous call to this endpoint. Provide this
// cursor to retrieve the next page of results for your original request. For more information,
// see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"-" url:"cursor,omitempty"`
}
type RetrieveJobRequest struct {
// The ID of the job to retrieve.
JobID string `json:"-" url:"-"`
}
type UpdateJobRequest struct {
// The ID of the job to update.
JobID string `json:"-" url:"-"`
// The job with the updated fields, either `title`, `is_tip_eligible`, or both. Only changed fields need
// to be included in the request. Optionally include `version` to enable optimistic concurrency control.
Job *Job `json:"job,omitempty" url:"-"`
}
// Represents a [CreateJob](api-endpoint:Team-CreateJob) response. Either `job` or `errors`
// is present in the response.
type CreateJobResponse struct {
// The new job.
Job *Job `json:"job,omitempty" url:"job,omitempty"`
// The errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CreateJobResponse) GetJob() *Job {
if c == nil {
return nil
}
return c.Job
}
func (c *CreateJobResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CreateJobResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CreateJobResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CreateJobResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CreateJobResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CreateJobResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Represents a job that can be assigned to [team members](entity:TeamMember). This object defines the
// job's title and tip eligibility. Compensation is defined in a [job assignment](entity:JobAssignment)
// in a team member's wage setting.
type Job struct {
// **Read only** The unique Square-assigned ID of the job. If you need a job ID for an API request,
// call [ListJobs](api-endpoint:Team-ListJobs) or use the ID returned when you created the job.
// You can also get job IDs from a team member's wage setting.
ID *string `json:"id,omitempty" url:"id,omitempty"`
// The title of the job.
Title *string `json:"title,omitempty" url:"title,omitempty"`
// Indicates whether team members can earn tips for the job.
IsTipEligible *bool `json:"is_tip_eligible,omitempty" url:"is_tip_eligible,omitempty"`
// The timestamp when the job was created, in RFC 3339 format.
CreatedAt *string `json:"created_at,omitempty" url:"created_at,omitempty"`
// The timestamp when the job was last updated, in RFC 3339 format.
UpdatedAt *string `json:"updated_at,omitempty" url:"updated_at,omitempty"`
// **Read only** The current version of the job. Include this field in `UpdateJob` requests to enable
// [optimistic concurrency](https://developer.squareup.com/docs/working-with-apis/optimistic-concurrency)
// control and avoid overwrites from concurrent requests. Requests fail if the provided version doesn't
// match the server version at the time of the request.
Version *int `json:"version,omitempty" url:"version,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (j *Job) GetID() *string {
if j == nil {
return nil
}
return j.ID
}
func (j *Job) GetTitle() *string {
if j == nil {
return nil
}
return j.Title
}
func (j *Job) GetIsTipEligible() *bool {
if j == nil {
return nil
}
return j.IsTipEligible
}
func (j *Job) GetCreatedAt() *string {
if j == nil {
return nil
}
return j.CreatedAt
}
func (j *Job) GetUpdatedAt() *string {
if j == nil {
return nil
}
return j.UpdatedAt
}
func (j *Job) GetVersion() *int {
if j == nil {
return nil
}
return j.Version
}
func (j *Job) GetExtraProperties() map[string]interface{} {
return j.extraProperties
}
func (j *Job) UnmarshalJSON(data []byte) error {
type unmarshaler Job
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*j = Job(value)
extraProperties, err := internal.ExtractExtraProperties(data, *j)
if err != nil {
return err
}
j.extraProperties = extraProperties
j.rawJSON = json.RawMessage(data)
return nil
}
func (j *Job) String() string {
if len(j.rawJSON) > 0 {
if value, err := internal.StringifyJSON(j.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(j); err == nil {
return value
}
return fmt.Sprintf("%#v", j)
}
// Represents a [ListJobs](api-endpoint:Team-ListJobs) response. Either `jobs` or `errors`
// is present in the response. If additional results are available, the `cursor` field is also present.
type ListJobsResponse struct {
// The retrieved jobs. A single paged response contains up to 100 jobs.
Jobs []*Job `json:"jobs,omitempty" url:"jobs,omitempty"`
// An opaque cursor used to retrieve the next page of results. This field is present only
// if the request succeeded and additional results are available. For more information, see
// [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"cursor,omitempty" url:"cursor,omitempty"`
// The errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (l *ListJobsResponse) GetJobs() []*Job {
if l == nil {
return nil
}
return l.Jobs
}
func (l *ListJobsResponse) GetCursor() *string {
if l == nil {
return nil
}
return l.Cursor
}
func (l *ListJobsResponse) GetErrors() []*Error {
if l == nil {
return nil
}
return l.Errors
}
func (l *ListJobsResponse) GetExtraProperties() map[string]interface{} {
return l.extraProperties
}
func (l *ListJobsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler ListJobsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = ListJobsResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *l)
if err != nil {
return err
}
l.extraProperties = extraProperties
l.rawJSON = json.RawMessage(data)
return nil
}
func (l *ListJobsResponse) String() string {
if len(l.rawJSON) > 0 {
if value, err := internal.StringifyJSON(l.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
// Represents a [RetrieveJob](api-endpoint:Team-RetrieveJob) response. Either `job` or `errors`
// is present in the response.
type RetrieveJobResponse struct {
// The retrieved job.
Job *Job `json:"job,omitempty" url:"job,omitempty"`
// The errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (r *RetrieveJobResponse) GetJob() *Job {
if r == nil {
return nil
}
return r.Job
}
func (r *RetrieveJobResponse) GetErrors() []*Error {
if r == nil {
return nil
}
return r.Errors
}
func (r *RetrieveJobResponse) GetExtraProperties() map[string]interface{} {
return r.extraProperties
}
func (r *RetrieveJobResponse) UnmarshalJSON(data []byte) error {
type unmarshaler RetrieveJobResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*r = RetrieveJobResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *r)
if err != nil {
return err
}
r.extraProperties = extraProperties
r.rawJSON = json.RawMessage(data)
return nil
}
func (r *RetrieveJobResponse) String() string {
if len(r.rawJSON) > 0 {
if value, err := internal.StringifyJSON(r.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(r); err == nil {
return value
}
return fmt.Sprintf("%#v", r)
}
// Represents an [UpdateJob](api-endpoint:Team-UpdateJob) response. Either `job` or `errors`
// is present in the response.
type UpdateJobResponse struct {
// The updated job.
Job *Job `json:"job,omitempty" url:"job,omitempty"`
// The errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (u *UpdateJobResponse) GetJob() *Job {
if u == nil {
return nil
}
return u.Job
}
func (u *UpdateJobResponse) GetErrors() []*Error {
if u == nil {
return nil
}
return u.Errors
}
func (u *UpdateJobResponse) GetExtraProperties() map[string]interface{} {
return u.extraProperties
}
func (u *UpdateJobResponse) UnmarshalJSON(data []byte) error {
type unmarshaler UpdateJobResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*u = UpdateJobResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *u)
if err != nil {
return err
}
u.extraProperties = extraProperties
u.rawJSON = json.RawMessage(data)
return nil
}
func (u *UpdateJobResponse) String() string {
if len(u.rawJSON) > 0 {
if value, err := internal.StringifyJSON(u.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(u); err == nil {
return value
}
return fmt.Sprintf("%#v", u)
}