-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinsight.go
More file actions
10188 lines (9103 loc) · 371 KB
/
Copy pathinsight.go
File metadata and controls
10188 lines (9103 loc) · 371 KB
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by Fern. DO NOT EDIT.
package api
import (
json "encoding/json"
fmt "fmt"
internal "github.com/VapiAI/server-sdk-go/v2/internal"
big "math/big"
time "time"
)
var (
insightControllerFindAllRequestFieldId = big.NewInt(1 << 0)
insightControllerFindAllRequestFieldPage = big.NewInt(1 << 1)
insightControllerFindAllRequestFieldSortOrder = big.NewInt(1 << 2)
insightControllerFindAllRequestFieldLimit = big.NewInt(1 << 3)
insightControllerFindAllRequestFieldCreatedAtGt = big.NewInt(1 << 4)
insightControllerFindAllRequestFieldCreatedAtLt = big.NewInt(1 << 5)
insightControllerFindAllRequestFieldCreatedAtGe = big.NewInt(1 << 6)
insightControllerFindAllRequestFieldCreatedAtLe = big.NewInt(1 << 7)
insightControllerFindAllRequestFieldUpdatedAtGt = big.NewInt(1 << 8)
insightControllerFindAllRequestFieldUpdatedAtLt = big.NewInt(1 << 9)
insightControllerFindAllRequestFieldUpdatedAtGe = big.NewInt(1 << 10)
insightControllerFindAllRequestFieldUpdatedAtLe = big.NewInt(1 << 11)
)
type InsightControllerFindAllRequest struct {
Id *string `json:"-" url:"id,omitempty"`
// This is the page number to return. Defaults to 1.
Page *float64 `json:"-" url:"page,omitempty"`
// This is the sort order for pagination. Defaults to 'DESC'.
SortOrder *InsightControllerFindAllRequestSortOrder `json:"-" url:"sortOrder,omitempty"`
// This is the maximum number of items to return. Defaults to 100.
Limit *float64 `json:"-" url:"limit,omitempty"`
// This will return items where the createdAt is greater than the specified value.
CreatedAtGt *time.Time `json:"-" url:"createdAtGt,omitempty"`
// This will return items where the createdAt is less than the specified value.
CreatedAtLt *time.Time `json:"-" url:"createdAtLt,omitempty"`
// This will return items where the createdAt is greater than or equal to the specified value.
CreatedAtGe *time.Time `json:"-" url:"createdAtGe,omitempty"`
// This will return items where the createdAt is less than or equal to the specified value.
CreatedAtLe *time.Time `json:"-" url:"createdAtLe,omitempty"`
// This will return items where the updatedAt is greater than the specified value.
UpdatedAtGt *time.Time `json:"-" url:"updatedAtGt,omitempty"`
// This will return items where the updatedAt is less than the specified value.
UpdatedAtLt *time.Time `json:"-" url:"updatedAtLt,omitempty"`
// This will return items where the updatedAt is greater than or equal to the specified value.
UpdatedAtGe *time.Time `json:"-" url:"updatedAtGe,omitempty"`
// This will return items where the updatedAt is less than or equal to the specified value.
UpdatedAtLe *time.Time `json:"-" url:"updatedAtLe,omitempty"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (i *InsightControllerFindAllRequest) require(field *big.Int) {
if i.explicitFields == nil {
i.explicitFields = big.NewInt(0)
}
i.explicitFields.Or(i.explicitFields, field)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetId(id *string) {
i.Id = id
i.require(insightControllerFindAllRequestFieldId)
}
// SetPage sets the Page field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetPage(page *float64) {
i.Page = page
i.require(insightControllerFindAllRequestFieldPage)
}
// SetSortOrder sets the SortOrder field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetSortOrder(sortOrder *InsightControllerFindAllRequestSortOrder) {
i.SortOrder = sortOrder
i.require(insightControllerFindAllRequestFieldSortOrder)
}
// SetLimit sets the Limit field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetLimit(limit *float64) {
i.Limit = limit
i.require(insightControllerFindAllRequestFieldLimit)
}
// SetCreatedAtGt sets the CreatedAtGt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetCreatedAtGt(createdAtGt *time.Time) {
i.CreatedAtGt = createdAtGt
i.require(insightControllerFindAllRequestFieldCreatedAtGt)
}
// SetCreatedAtLt sets the CreatedAtLt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetCreatedAtLt(createdAtLt *time.Time) {
i.CreatedAtLt = createdAtLt
i.require(insightControllerFindAllRequestFieldCreatedAtLt)
}
// SetCreatedAtGe sets the CreatedAtGe field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetCreatedAtGe(createdAtGe *time.Time) {
i.CreatedAtGe = createdAtGe
i.require(insightControllerFindAllRequestFieldCreatedAtGe)
}
// SetCreatedAtLe sets the CreatedAtLe field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetCreatedAtLe(createdAtLe *time.Time) {
i.CreatedAtLe = createdAtLe
i.require(insightControllerFindAllRequestFieldCreatedAtLe)
}
// SetUpdatedAtGt sets the UpdatedAtGt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetUpdatedAtGt(updatedAtGt *time.Time) {
i.UpdatedAtGt = updatedAtGt
i.require(insightControllerFindAllRequestFieldUpdatedAtGt)
}
// SetUpdatedAtLt sets the UpdatedAtLt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetUpdatedAtLt(updatedAtLt *time.Time) {
i.UpdatedAtLt = updatedAtLt
i.require(insightControllerFindAllRequestFieldUpdatedAtLt)
}
// SetUpdatedAtGe sets the UpdatedAtGe field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetUpdatedAtGe(updatedAtGe *time.Time) {
i.UpdatedAtGe = updatedAtGe
i.require(insightControllerFindAllRequestFieldUpdatedAtGe)
}
// SetUpdatedAtLe sets the UpdatedAtLe field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindAllRequest) SetUpdatedAtLe(updatedAtLe *time.Time) {
i.UpdatedAtLe = updatedAtLe
i.require(insightControllerFindAllRequestFieldUpdatedAtLe)
}
var (
insightControllerFindOneRequestFieldId = big.NewInt(1 << 0)
)
type InsightControllerFindOneRequest struct {
Id string `json:"-" url:"-"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (i *InsightControllerFindOneRequest) require(field *big.Int) {
if i.explicitFields == nil {
i.explicitFields = big.NewInt(0)
}
i.explicitFields.Or(i.explicitFields, field)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerFindOneRequest) SetId(id string) {
i.Id = id
i.require(insightControllerFindOneRequestFieldId)
}
var (
insightControllerRemoveRequestFieldId = big.NewInt(1 << 0)
)
type InsightControllerRemoveRequest struct {
Id string `json:"-" url:"-"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (i *InsightControllerRemoveRequest) require(field *big.Int) {
if i.explicitFields == nil {
i.explicitFields = big.NewInt(0)
}
i.explicitFields.Or(i.explicitFields, field)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerRemoveRequest) SetId(id string) {
i.Id = id
i.require(insightControllerRemoveRequestFieldId)
}
var (
insightRunDtoFieldId = big.NewInt(1 << 0)
insightRunDtoFieldFormatPlan = big.NewInt(1 << 1)
insightRunDtoFieldTimeRangeOverride = big.NewInt(1 << 2)
)
type InsightRunDto struct {
Id string `json:"-" url:"-"`
FormatPlan *InsightRunFormatPlan `json:"formatPlan,omitempty" url:"-"`
// This is the optional time range override for the insight.
// If provided, overrides every field in the insight's timeRange.
// If this is provided with missing fields, defaults will be used, not the insight's timeRange.
// start default - "-7d"
// end default - "now"
// step default - "day"
// For Pie and Text Insights, step will be ignored even if provided.
TimeRangeOverride *InsightTimeRangeWithStep `json:"timeRangeOverride,omitempty" url:"-"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (i *InsightRunDto) require(field *big.Int) {
if i.explicitFields == nil {
i.explicitFields = big.NewInt(0)
}
i.explicitFields.Or(i.explicitFields, field)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightRunDto) SetId(id string) {
i.Id = id
i.require(insightRunDtoFieldId)
}
// SetFormatPlan sets the FormatPlan field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightRunDto) SetFormatPlan(formatPlan *InsightRunFormatPlan) {
i.FormatPlan = formatPlan
i.require(insightRunDtoFieldFormatPlan)
}
// SetTimeRangeOverride sets the TimeRangeOverride field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightRunDto) SetTimeRangeOverride(timeRangeOverride *InsightTimeRangeWithStep) {
i.TimeRangeOverride = timeRangeOverride
i.require(insightRunDtoFieldTimeRangeOverride)
}
func (i *InsightRunDto) UnmarshalJSON(data []byte) error {
type unmarshaler InsightRunDto
var body unmarshaler
if err := json.Unmarshal(data, &body); err != nil {
return err
}
*i = InsightRunDto(body)
return nil
}
func (i *InsightRunDto) MarshalJSON() ([]byte, error) {
type embed InsightRunDto
var marshaler = struct {
embed
}{
embed: embed(*i),
}
explicitMarshaler := internal.HandleExplicitFields(marshaler, i.explicitFields)
return json.Marshal(explicitMarshaler)
}
var (
insightControllerUpdateRequestFieldId = big.NewInt(1 << 0)
)
type InsightControllerUpdateRequest struct {
Id string `json:"-" url:"-"`
Body *InsightControllerUpdateRequestBody `json:"-" url:"-"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (i *InsightControllerUpdateRequest) require(field *big.Int) {
if i.explicitFields == nil {
i.explicitFields = big.NewInt(0)
}
i.explicitFields.Or(i.explicitFields, field)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (i *InsightControllerUpdateRequest) SetId(id string) {
i.Id = id
i.require(insightControllerUpdateRequestFieldId)
}
func (i *InsightControllerUpdateRequest) UnmarshalJSON(data []byte) error {
body := new(InsightControllerUpdateRequestBody)
if err := json.Unmarshal(data, &body); err != nil {
return err
}
i.Body = body
return nil
}
func (i *InsightControllerUpdateRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(i.Body)
}
var (
barInsightFieldName = big.NewInt(1 << 0)
barInsightFieldFormulas = big.NewInt(1 << 1)
barInsightFieldMetadata = big.NewInt(1 << 2)
barInsightFieldTimeRange = big.NewInt(1 << 3)
barInsightFieldGroupBy = big.NewInt(1 << 4)
barInsightFieldQueries = big.NewInt(1 << 5)
barInsightFieldId = big.NewInt(1 << 6)
barInsightFieldOrgId = big.NewInt(1 << 7)
barInsightFieldCreatedAt = big.NewInt(1 << 8)
barInsightFieldUpdatedAt = big.NewInt(1 << 9)
)
type BarInsight struct {
// This is the name of the Insight.
Name *string `json:"name,omitempty" url:"name,omitempty"`
// Formulas are mathematical expressions applied on the data returned by the queries to transform them before being used to create the insight.
// The formulas needs to be a valid mathematical expression, supported by MathJS - https://mathjs.org/docs/expressions/syntax.html
// A formula is created by using the query names as the variable.
// The formulas must contain at least one query name in the LiquidJS format {{query_name}} or {{['query name']}} which will be substituted with the query result.
// For example, if you have 2 queries, 'Was Booking Made' and 'Average Call Duration', you can create a formula like this:
// ```
// {{['Query 1']}} / {{['Query 2']}} * 100
// ```
//
// ```
// ({{[Query 1]}} * 10) + {{[Query 2]}}
// ```
// This will take the
//
// You can also use the query names as the variable in the formula.
Formulas []*InsightFormula `json:"formulas,omitempty" url:"formulas,omitempty"`
// This is the metadata for the insight.
Metadata *BarInsightMetadata `json:"metadata,omitempty" url:"metadata,omitempty"`
TimeRange *InsightTimeRangeWithStep `json:"timeRange,omitempty" url:"timeRange,omitempty"`
// This is the group by column for the insight when table is `call`.
// These are the columns to group the results by.
// All results are grouped by the time range step by default.
GroupBy *BarInsightGroupBy `json:"groupBy,omitempty" url:"groupBy,omitempty"`
// These are the queries to run to generate the insight.
Queries []*BarInsightQueriesItem `json:"queries" url:"queries"`
// This is the unique identifier for the Insight.
Id string `json:"id" url:"id"`
// This is the unique identifier for the org that this Insight belongs to.
OrgId string `json:"orgId" url:"orgId"`
// This is the ISO 8601 date-time string of when the Insight was created.
CreatedAt time.Time `json:"createdAt" url:"createdAt"`
// This is the ISO 8601 date-time string of when the Insight was last updated.
UpdatedAt time.Time `json:"updatedAt" url:"updatedAt"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BarInsight) GetName() *string {
if b == nil {
return nil
}
return b.Name
}
func (b *BarInsight) GetFormulas() []*InsightFormula {
if b == nil {
return nil
}
return b.Formulas
}
func (b *BarInsight) GetMetadata() *BarInsightMetadata {
if b == nil {
return nil
}
return b.Metadata
}
func (b *BarInsight) GetTimeRange() *InsightTimeRangeWithStep {
if b == nil {
return nil
}
return b.TimeRange
}
func (b *BarInsight) GetGroupBy() *BarInsightGroupBy {
if b == nil {
return nil
}
return b.GroupBy
}
func (b *BarInsight) GetQueries() []*BarInsightQueriesItem {
if b == nil {
return nil
}
return b.Queries
}
func (b *BarInsight) GetId() string {
if b == nil {
return ""
}
return b.Id
}
func (b *BarInsight) GetOrgId() string {
if b == nil {
return ""
}
return b.OrgId
}
func (b *BarInsight) GetCreatedAt() time.Time {
if b == nil {
return time.Time{}
}
return b.CreatedAt
}
func (b *BarInsight) GetUpdatedAt() time.Time {
if b == nil {
return time.Time{}
}
return b.UpdatedAt
}
func (b *BarInsight) GetExtraProperties() map[string]interface{} {
if b == nil {
return nil
}
return b.extraProperties
}
func (b *BarInsight) require(field *big.Int) {
if b.explicitFields == nil {
b.explicitFields = big.NewInt(0)
}
b.explicitFields.Or(b.explicitFields, field)
}
// SetName sets the Name field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetName(name *string) {
b.Name = name
b.require(barInsightFieldName)
}
// SetFormulas sets the Formulas field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetFormulas(formulas []*InsightFormula) {
b.Formulas = formulas
b.require(barInsightFieldFormulas)
}
// SetMetadata sets the Metadata field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetMetadata(metadata *BarInsightMetadata) {
b.Metadata = metadata
b.require(barInsightFieldMetadata)
}
// SetTimeRange sets the TimeRange field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetTimeRange(timeRange *InsightTimeRangeWithStep) {
b.TimeRange = timeRange
b.require(barInsightFieldTimeRange)
}
// SetGroupBy sets the GroupBy field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetGroupBy(groupBy *BarInsightGroupBy) {
b.GroupBy = groupBy
b.require(barInsightFieldGroupBy)
}
// SetQueries sets the Queries field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetQueries(queries []*BarInsightQueriesItem) {
b.Queries = queries
b.require(barInsightFieldQueries)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetId(id string) {
b.Id = id
b.require(barInsightFieldId)
}
// SetOrgId sets the OrgId field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetOrgId(orgId string) {
b.OrgId = orgId
b.require(barInsightFieldOrgId)
}
// SetCreatedAt sets the CreatedAt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetCreatedAt(createdAt time.Time) {
b.CreatedAt = createdAt
b.require(barInsightFieldCreatedAt)
}
// SetUpdatedAt sets the UpdatedAt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsight) SetUpdatedAt(updatedAt time.Time) {
b.UpdatedAt = updatedAt
b.require(barInsightFieldUpdatedAt)
}
func (b *BarInsight) UnmarshalJSON(data []byte) error {
type embed BarInsight
var unmarshaler = struct {
embed
CreatedAt *internal.DateTime `json:"createdAt"`
UpdatedAt *internal.DateTime `json:"updatedAt"`
}{
embed: embed(*b),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*b = BarInsight(unmarshaler.embed)
b.CreatedAt = unmarshaler.CreatedAt.Time()
b.UpdatedAt = unmarshaler.UpdatedAt.Time()
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BarInsight) MarshalJSON() ([]byte, error) {
type embed BarInsight
var marshaler = struct {
embed
CreatedAt *internal.DateTime `json:"createdAt"`
UpdatedAt *internal.DateTime `json:"updatedAt"`
}{
embed: embed(*b),
CreatedAt: internal.NewDateTime(b.CreatedAt),
UpdatedAt: internal.NewDateTime(b.UpdatedAt),
}
explicitMarshaler := internal.HandleExplicitFields(marshaler, b.explicitFields)
return json.Marshal(explicitMarshaler)
}
func (b *BarInsight) String() string {
if b == nil {
return "<nil>"
}
if len(b.rawJSON) > 0 {
if value, err := internal.StringifyJSON(b.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(b); err == nil {
return value
}
return fmt.Sprintf("%#v", b)
}
// This is the group by column for the insight when table is `call`.
// These are the columns to group the results by.
// All results are grouped by the time range step by default.
type BarInsightGroupBy string
const (
BarInsightGroupByAssistantId BarInsightGroupBy = "assistantId"
BarInsightGroupByWorkflowId BarInsightGroupBy = "workflowId"
BarInsightGroupBySquadId BarInsightGroupBy = "squadId"
BarInsightGroupByPhoneNumberId BarInsightGroupBy = "phoneNumberId"
BarInsightGroupByType BarInsightGroupBy = "type"
BarInsightGroupByEndedReason BarInsightGroupBy = "endedReason"
BarInsightGroupByCustomerNumber BarInsightGroupBy = "customerNumber"
BarInsightGroupByCampaignId BarInsightGroupBy = "campaignId"
BarInsightGroupByArtifactStructuredOutputsOutputId BarInsightGroupBy = "artifact.structuredOutputs[OutputID]"
)
func NewBarInsightGroupByFromString(s string) (BarInsightGroupBy, error) {
switch s {
case "assistantId":
return BarInsightGroupByAssistantId, nil
case "workflowId":
return BarInsightGroupByWorkflowId, nil
case "squadId":
return BarInsightGroupBySquadId, nil
case "phoneNumberId":
return BarInsightGroupByPhoneNumberId, nil
case "type":
return BarInsightGroupByType, nil
case "endedReason":
return BarInsightGroupByEndedReason, nil
case "customerNumber":
return BarInsightGroupByCustomerNumber, nil
case "campaignId":
return BarInsightGroupByCampaignId, nil
case "artifact.structuredOutputs[OutputID]":
return BarInsightGroupByArtifactStructuredOutputsOutputId, nil
}
var t BarInsightGroupBy
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (b BarInsightGroupBy) Ptr() *BarInsightGroupBy {
return &b
}
var (
barInsightMetadataFieldXAxisLabel = big.NewInt(1 << 0)
barInsightMetadataFieldYAxisLabel = big.NewInt(1 << 1)
barInsightMetadataFieldYAxisMin = big.NewInt(1 << 2)
barInsightMetadataFieldYAxisMax = big.NewInt(1 << 3)
barInsightMetadataFieldName = big.NewInt(1 << 4)
)
type BarInsightMetadata struct {
XAxisLabel *string `json:"xAxisLabel,omitempty" url:"xAxisLabel,omitempty"`
YAxisLabel *string `json:"yAxisLabel,omitempty" url:"yAxisLabel,omitempty"`
YAxisMin *float64 `json:"yAxisMin,omitempty" url:"yAxisMin,omitempty"`
YAxisMax *float64 `json:"yAxisMax,omitempty" url:"yAxisMax,omitempty"`
Name *string `json:"name,omitempty" url:"name,omitempty"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BarInsightMetadata) GetXAxisLabel() *string {
if b == nil {
return nil
}
return b.XAxisLabel
}
func (b *BarInsightMetadata) GetYAxisLabel() *string {
if b == nil {
return nil
}
return b.YAxisLabel
}
func (b *BarInsightMetadata) GetYAxisMin() *float64 {
if b == nil {
return nil
}
return b.YAxisMin
}
func (b *BarInsightMetadata) GetYAxisMax() *float64 {
if b == nil {
return nil
}
return b.YAxisMax
}
func (b *BarInsightMetadata) GetName() *string {
if b == nil {
return nil
}
return b.Name
}
func (b *BarInsightMetadata) GetExtraProperties() map[string]interface{} {
if b == nil {
return nil
}
return b.extraProperties
}
func (b *BarInsightMetadata) require(field *big.Int) {
if b.explicitFields == nil {
b.explicitFields = big.NewInt(0)
}
b.explicitFields.Or(b.explicitFields, field)
}
// SetXAxisLabel sets the XAxisLabel field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsightMetadata) SetXAxisLabel(xAxisLabel *string) {
b.XAxisLabel = xAxisLabel
b.require(barInsightMetadataFieldXAxisLabel)
}
// SetYAxisLabel sets the YAxisLabel field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsightMetadata) SetYAxisLabel(yAxisLabel *string) {
b.YAxisLabel = yAxisLabel
b.require(barInsightMetadataFieldYAxisLabel)
}
// SetYAxisMin sets the YAxisMin field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsightMetadata) SetYAxisMin(yAxisMin *float64) {
b.YAxisMin = yAxisMin
b.require(barInsightMetadataFieldYAxisMin)
}
// SetYAxisMax sets the YAxisMax field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsightMetadata) SetYAxisMax(yAxisMax *float64) {
b.YAxisMax = yAxisMax
b.require(barInsightMetadataFieldYAxisMax)
}
// SetName sets the Name field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (b *BarInsightMetadata) SetName(name *string) {
b.Name = name
b.require(barInsightMetadataFieldName)
}
func (b *BarInsightMetadata) UnmarshalJSON(data []byte) error {
type unmarshaler BarInsightMetadata
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BarInsightMetadata(value)
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BarInsightMetadata) MarshalJSON() ([]byte, error) {
type embed BarInsightMetadata
var marshaler = struct {
embed
}{
embed: embed(*b),
}
explicitMarshaler := internal.HandleExplicitFields(marshaler, b.explicitFields)
return json.Marshal(explicitMarshaler)
}
func (b *BarInsightMetadata) String() string {
if b == nil {
return "<nil>"
}
if len(b.rawJSON) > 0 {
if value, err := internal.StringifyJSON(b.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(b); err == nil {
return value
}
return fmt.Sprintf("%#v", b)
}
type BarInsightQueriesItem struct {
JsonQueryOnCallTableWithStringTypeColumn *JsonQueryOnCallTableWithStringTypeColumn
JsonQueryOnCallTableWithNumberTypeColumn *JsonQueryOnCallTableWithNumberTypeColumn
JsonQueryOnCallTableWithStructuredOutputColumn *JsonQueryOnCallTableWithStructuredOutputColumn
JsonQueryOnEventsTable *JsonQueryOnEventsTable
typ string
}
func (b *BarInsightQueriesItem) GetJsonQueryOnCallTableWithStringTypeColumn() *JsonQueryOnCallTableWithStringTypeColumn {
if b == nil {
return nil
}
return b.JsonQueryOnCallTableWithStringTypeColumn
}
func (b *BarInsightQueriesItem) GetJsonQueryOnCallTableWithNumberTypeColumn() *JsonQueryOnCallTableWithNumberTypeColumn {
if b == nil {
return nil
}
return b.JsonQueryOnCallTableWithNumberTypeColumn
}
func (b *BarInsightQueriesItem) GetJsonQueryOnCallTableWithStructuredOutputColumn() *JsonQueryOnCallTableWithStructuredOutputColumn {
if b == nil {
return nil
}
return b.JsonQueryOnCallTableWithStructuredOutputColumn
}
func (b *BarInsightQueriesItem) GetJsonQueryOnEventsTable() *JsonQueryOnEventsTable {
if b == nil {
return nil
}
return b.JsonQueryOnEventsTable
}
func (b *BarInsightQueriesItem) UnmarshalJSON(data []byte) error {
valueJsonQueryOnCallTableWithStringTypeColumn := new(JsonQueryOnCallTableWithStringTypeColumn)
if err := json.Unmarshal(data, &valueJsonQueryOnCallTableWithStringTypeColumn); err == nil {
b.typ = "JsonQueryOnCallTableWithStringTypeColumn"
b.JsonQueryOnCallTableWithStringTypeColumn = valueJsonQueryOnCallTableWithStringTypeColumn
return nil
}
valueJsonQueryOnCallTableWithNumberTypeColumn := new(JsonQueryOnCallTableWithNumberTypeColumn)
if err := json.Unmarshal(data, &valueJsonQueryOnCallTableWithNumberTypeColumn); err == nil {
b.typ = "JsonQueryOnCallTableWithNumberTypeColumn"
b.JsonQueryOnCallTableWithNumberTypeColumn = valueJsonQueryOnCallTableWithNumberTypeColumn
return nil
}
valueJsonQueryOnCallTableWithStructuredOutputColumn := new(JsonQueryOnCallTableWithStructuredOutputColumn)
if err := json.Unmarshal(data, &valueJsonQueryOnCallTableWithStructuredOutputColumn); err == nil {
b.typ = "JsonQueryOnCallTableWithStructuredOutputColumn"
b.JsonQueryOnCallTableWithStructuredOutputColumn = valueJsonQueryOnCallTableWithStructuredOutputColumn
return nil
}
valueJsonQueryOnEventsTable := new(JsonQueryOnEventsTable)
if err := json.Unmarshal(data, &valueJsonQueryOnEventsTable); err == nil {
b.typ = "JsonQueryOnEventsTable"
b.JsonQueryOnEventsTable = valueJsonQueryOnEventsTable
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, b)
}
func (b BarInsightQueriesItem) MarshalJSON() ([]byte, error) {
if b.typ == "JsonQueryOnCallTableWithStringTypeColumn" || b.JsonQueryOnCallTableWithStringTypeColumn != nil {
return json.Marshal(b.JsonQueryOnCallTableWithStringTypeColumn)
}
if b.typ == "JsonQueryOnCallTableWithNumberTypeColumn" || b.JsonQueryOnCallTableWithNumberTypeColumn != nil {
return json.Marshal(b.JsonQueryOnCallTableWithNumberTypeColumn)
}
if b.typ == "JsonQueryOnCallTableWithStructuredOutputColumn" || b.JsonQueryOnCallTableWithStructuredOutputColumn != nil {
return json.Marshal(b.JsonQueryOnCallTableWithStructuredOutputColumn)
}
if b.typ == "JsonQueryOnEventsTable" || b.JsonQueryOnEventsTable != nil {
return json.Marshal(b.JsonQueryOnEventsTable)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", b)
}
type BarInsightQueriesItemVisitor interface {
VisitJsonQueryOnCallTableWithStringTypeColumn(*JsonQueryOnCallTableWithStringTypeColumn) error
VisitJsonQueryOnCallTableWithNumberTypeColumn(*JsonQueryOnCallTableWithNumberTypeColumn) error
VisitJsonQueryOnCallTableWithStructuredOutputColumn(*JsonQueryOnCallTableWithStructuredOutputColumn) error
VisitJsonQueryOnEventsTable(*JsonQueryOnEventsTable) error
}
func (b *BarInsightQueriesItem) Accept(visitor BarInsightQueriesItemVisitor) error {
if b.typ == "JsonQueryOnCallTableWithStringTypeColumn" || b.JsonQueryOnCallTableWithStringTypeColumn != nil {
return visitor.VisitJsonQueryOnCallTableWithStringTypeColumn(b.JsonQueryOnCallTableWithStringTypeColumn)
}
if b.typ == "JsonQueryOnCallTableWithNumberTypeColumn" || b.JsonQueryOnCallTableWithNumberTypeColumn != nil {
return visitor.VisitJsonQueryOnCallTableWithNumberTypeColumn(b.JsonQueryOnCallTableWithNumberTypeColumn)
}
if b.typ == "JsonQueryOnCallTableWithStructuredOutputColumn" || b.JsonQueryOnCallTableWithStructuredOutputColumn != nil {
return visitor.VisitJsonQueryOnCallTableWithStructuredOutputColumn(b.JsonQueryOnCallTableWithStructuredOutputColumn)
}
if b.typ == "JsonQueryOnEventsTable" || b.JsonQueryOnEventsTable != nil {
return visitor.VisitJsonQueryOnEventsTable(b.JsonQueryOnEventsTable)
}
return fmt.Errorf("type %T does not include a non-empty union type", b)
}
var (
createBarInsightFromCallTableDtoFieldName = big.NewInt(1 << 0)
createBarInsightFromCallTableDtoFieldFormulas = big.NewInt(1 << 1)
createBarInsightFromCallTableDtoFieldMetadata = big.NewInt(1 << 2)
createBarInsightFromCallTableDtoFieldTimeRange = big.NewInt(1 << 3)
createBarInsightFromCallTableDtoFieldGroupBy = big.NewInt(1 << 4)
createBarInsightFromCallTableDtoFieldQueries = big.NewInt(1 << 5)
)
type CreateBarInsightFromCallTableDto struct {
// This is the name of the Insight.
Name *string `json:"name,omitempty" url:"name,omitempty"`
// Formulas are mathematical expressions applied on the data returned by the queries to transform them before being used to create the insight.
// The formulas needs to be a valid mathematical expression, supported by MathJS - https://mathjs.org/docs/expressions/syntax.html
// A formula is created by using the query names as the variable.
// The formulas must contain at least one query name in the LiquidJS format {{query_name}} or {{['query name']}} which will be substituted with the query result.
// For example, if you have 2 queries, 'Was Booking Made' and 'Average Call Duration', you can create a formula like this:
// ```
// {{['Query 1']}} / {{['Query 2']}} * 100
// ```
//
// ```
// ({{[Query 1]}} * 10) + {{[Query 2]}}
// ```
// This will take the
//
// You can also use the query names as the variable in the formula.
Formulas []*InsightFormula `json:"formulas,omitempty" url:"formulas,omitempty"`
// This is the metadata for the insight.
Metadata *BarInsightMetadata `json:"metadata,omitempty" url:"metadata,omitempty"`
TimeRange *InsightTimeRangeWithStep `json:"timeRange,omitempty" url:"timeRange,omitempty"`
// This is the group by column for the insight when table is `call`.
// These are the columns to group the results by.
// All results are grouped by the time range step by default.
GroupBy *CreateBarInsightFromCallTableDtoGroupBy `json:"groupBy,omitempty" url:"groupBy,omitempty"`
// These are the queries to run to generate the insight.
Queries []*CreateBarInsightFromCallTableDtoQueriesItem `json:"queries" url:"queries"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CreateBarInsightFromCallTableDto) GetName() *string {
if c == nil {
return nil
}
return c.Name
}
func (c *CreateBarInsightFromCallTableDto) GetFormulas() []*InsightFormula {
if c == nil {
return nil
}
return c.Formulas
}
func (c *CreateBarInsightFromCallTableDto) GetMetadata() *BarInsightMetadata {
if c == nil {
return nil
}
return c.Metadata
}
func (c *CreateBarInsightFromCallTableDto) GetTimeRange() *InsightTimeRangeWithStep {
if c == nil {
return nil
}
return c.TimeRange
}
func (c *CreateBarInsightFromCallTableDto) GetGroupBy() *CreateBarInsightFromCallTableDtoGroupBy {
if c == nil {
return nil
}
return c.GroupBy
}
func (c *CreateBarInsightFromCallTableDto) GetQueries() []*CreateBarInsightFromCallTableDtoQueriesItem {
if c == nil {
return nil
}
return c.Queries
}
func (c *CreateBarInsightFromCallTableDto) GetExtraProperties() map[string]interface{} {
if c == nil {
return nil
}
return c.extraProperties
}
func (c *CreateBarInsightFromCallTableDto) require(field *big.Int) {
if c.explicitFields == nil {
c.explicitFields = big.NewInt(0)
}
c.explicitFields.Or(c.explicitFields, field)
}
// SetName sets the Name field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (c *CreateBarInsightFromCallTableDto) SetName(name *string) {
c.Name = name
c.require(createBarInsightFromCallTableDtoFieldName)
}
// SetFormulas sets the Formulas field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (c *CreateBarInsightFromCallTableDto) SetFormulas(formulas []*InsightFormula) {
c.Formulas = formulas
c.require(createBarInsightFromCallTableDtoFieldFormulas)
}
// SetMetadata sets the Metadata field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (c *CreateBarInsightFromCallTableDto) SetMetadata(metadata *BarInsightMetadata) {
c.Metadata = metadata
c.require(createBarInsightFromCallTableDtoFieldMetadata)
}
// SetTimeRange sets the TimeRange field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (c *CreateBarInsightFromCallTableDto) SetTimeRange(timeRange *InsightTimeRangeWithStep) {
c.TimeRange = timeRange
c.require(createBarInsightFromCallTableDtoFieldTimeRange)
}
// SetGroupBy sets the GroupBy field and marks it as non-optional;