-
Notifications
You must be signed in to change notification settings - Fork 1
/
contractproduct.go
783 lines (695 loc) · 34 KB
/
contractproduct.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
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package metronome
import (
"context"
"net/http"
"net/url"
"time"
"github.com/Metronome-Industries/metronome-go/internal/apijson"
"github.com/Metronome-Industries/metronome-go/internal/apiquery"
"github.com/Metronome-Industries/metronome-go/internal/pagination"
"github.com/Metronome-Industries/metronome-go/internal/param"
"github.com/Metronome-Industries/metronome-go/internal/requestconfig"
"github.com/Metronome-Industries/metronome-go/option"
"github.com/Metronome-Industries/metronome-go/shared"
)
// ContractProductService contains methods and other services that help with
// interacting with the metronome API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewContractProductService] method instead.
type ContractProductService struct {
Options []option.RequestOption
}
// NewContractProductService generates a new service that applies the given options
// to each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewContractProductService(opts ...option.RequestOption) (r *ContractProductService) {
r = &ContractProductService{}
r.Options = opts
return
}
// Create a new product
func (r *ContractProductService) New(ctx context.Context, body ContractProductNewParams, opts ...option.RequestOption) (res *ContractProductNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "contract-pricing/products/create"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Get a specific product
func (r *ContractProductService) Get(ctx context.Context, body ContractProductGetParams, opts ...option.RequestOption) (res *ContractProductGetResponse, err error) {
opts = append(r.Options[:], opts...)
path := "contract-pricing/products/get"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Update a product
func (r *ContractProductService) Update(ctx context.Context, body ContractProductUpdateParams, opts ...option.RequestOption) (res *ContractProductUpdateResponse, err error) {
opts = append(r.Options[:], opts...)
path := "contract-pricing/products/update"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// List products
func (r *ContractProductService) List(ctx context.Context, params ContractProductListParams, opts ...option.RequestOption) (res *pagination.CursorPage[ContractProductListResponse], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "contract-pricing/products/list"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// List products
func (r *ContractProductService) ListAutoPaging(ctx context.Context, params ContractProductListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[ContractProductListResponse] {
return pagination.NewCursorPageAutoPager(r.List(ctx, params, opts...))
}
// Archive a product
func (r *ContractProductService) Archive(ctx context.Context, body ContractProductArchiveParams, opts ...option.RequestOption) (res *ContractProductArchiveResponse, err error) {
opts = append(r.Options[:], opts...)
path := "contract-pricing/products/archive"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
type ProductListItemState struct {
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
CreatedBy string `json:"created_by,required"`
Name string `json:"name,required"`
BillableMetricID string `json:"billable_metric_id"`
CompositeProductIDs []string `json:"composite_product_ids" format:"uuid"`
CompositeTags []string `json:"composite_tags"`
ExcludeFreeUsage bool `json:"exclude_free_usage"`
// This field's availability is dependent on your client's configuration.
IsRefundable bool `json:"is_refundable"`
// This field's availability is dependent on your client's configuration.
NetsuiteInternalItemID string `json:"netsuite_internal_item_id"`
// This field's availability is dependent on your client's configuration.
NetsuiteOverageItemID string `json:"netsuite_overage_item_id"`
// For USAGE products only. Groups usage line items on invoices.
PresentationGroupKey []string `json:"presentation_group_key"`
// For USAGE products only. If set, pricing for this product will be determined for
// each pricing_group_key value, as opposed to the product as a whole.
PricingGroupKey []string `json:"pricing_group_key"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// converted using the provided conversion factor and operation. For example, if
// the operation is "multiply" and the conversion factor is 100, then the quantity
// will be multiplied by 100. This can be used in cases where data is sent in one
// unit and priced in another. For example, data could be sent in MB and priced in
// GB. In this case, the conversion factor would be 1024 and the operation would be
// "divide".
QuantityConversion QuantityConversion `json:"quantity_conversion,nullable"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// rounded using the provided rounding method and decimal places. For example, if
// the method is "round up" and the decimal places is 0, then the quantity will be
// rounded up to the nearest integer.
QuantityRounding QuantityRounding `json:"quantity_rounding,nullable"`
StartingAt time.Time `json:"starting_at" format:"date-time"`
Tags []string `json:"tags"`
JSON productListItemStateJSON `json:"-"`
}
// productListItemStateJSON contains the JSON metadata for the struct
// [ProductListItemState]
type productListItemStateJSON struct {
CreatedAt apijson.Field
CreatedBy apijson.Field
Name apijson.Field
BillableMetricID apijson.Field
CompositeProductIDs apijson.Field
CompositeTags apijson.Field
ExcludeFreeUsage apijson.Field
IsRefundable apijson.Field
NetsuiteInternalItemID apijson.Field
NetsuiteOverageItemID apijson.Field
PresentationGroupKey apijson.Field
PricingGroupKey apijson.Field
QuantityConversion apijson.Field
QuantityRounding apijson.Field
StartingAt apijson.Field
Tags apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProductListItemState) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r productListItemStateJSON) RawJSON() string {
return r.raw
}
// Optional. Only valid for USAGE products. If provided, the quantity will be
// converted using the provided conversion factor and operation. For example, if
// the operation is "multiply" and the conversion factor is 100, then the quantity
// will be multiplied by 100. This can be used in cases where data is sent in one
// unit and priced in another. For example, data could be sent in MB and priced in
// GB. In this case, the conversion factor would be 1024 and the operation would be
// "divide".
type QuantityConversion struct {
// The factor to multiply or divide the quantity by.
ConversionFactor float64 `json:"conversion_factor,required"`
// The operation to perform on the quantity
Operation QuantityConversionOperation `json:"operation,required"`
// Optional name for this conversion.
Name string `json:"name"`
JSON quantityConversionJSON `json:"-"`
}
// quantityConversionJSON contains the JSON metadata for the struct
// [QuantityConversion]
type quantityConversionJSON struct {
ConversionFactor apijson.Field
Operation apijson.Field
Name apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *QuantityConversion) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r quantityConversionJSON) RawJSON() string {
return r.raw
}
// The operation to perform on the quantity
type QuantityConversionOperation string
const (
QuantityConversionOperationMultiply QuantityConversionOperation = "MULTIPLY"
QuantityConversionOperationDivide QuantityConversionOperation = "DIVIDE"
)
func (r QuantityConversionOperation) IsKnown() bool {
switch r {
case QuantityConversionOperationMultiply, QuantityConversionOperationDivide:
return true
}
return false
}
// Optional. Only valid for USAGE products. If provided, the quantity will be
// converted using the provided conversion factor and operation. For example, if
// the operation is "multiply" and the conversion factor is 100, then the quantity
// will be multiplied by 100. This can be used in cases where data is sent in one
// unit and priced in another. For example, data could be sent in MB and priced in
// GB. In this case, the conversion factor would be 1024 and the operation would be
// "divide".
type QuantityConversionParam struct {
// The factor to multiply or divide the quantity by.
ConversionFactor param.Field[float64] `json:"conversion_factor,required"`
// The operation to perform on the quantity
Operation param.Field[QuantityConversionOperation] `json:"operation,required"`
// Optional name for this conversion.
Name param.Field[string] `json:"name"`
}
func (r QuantityConversionParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Optional. Only valid for USAGE products. If provided, the quantity will be
// rounded using the provided rounding method and decimal places. For example, if
// the method is "round up" and the decimal places is 0, then the quantity will be
// rounded up to the nearest integer.
type QuantityRounding struct {
DecimalPlaces float64 `json:"decimal_places,required"`
RoundingMethod QuantityRoundingRoundingMethod `json:"rounding_method,required"`
JSON quantityRoundingJSON `json:"-"`
}
// quantityRoundingJSON contains the JSON metadata for the struct
// [QuantityRounding]
type quantityRoundingJSON struct {
DecimalPlaces apijson.Field
RoundingMethod apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *QuantityRounding) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r quantityRoundingJSON) RawJSON() string {
return r.raw
}
type QuantityRoundingRoundingMethod string
const (
QuantityRoundingRoundingMethodRoundUp QuantityRoundingRoundingMethod = "ROUND_UP"
QuantityRoundingRoundingMethodRoundDown QuantityRoundingRoundingMethod = "ROUND_DOWN"
QuantityRoundingRoundingMethodRoundHalfUp QuantityRoundingRoundingMethod = "ROUND_HALF_UP"
)
func (r QuantityRoundingRoundingMethod) IsKnown() bool {
switch r {
case QuantityRoundingRoundingMethodRoundUp, QuantityRoundingRoundingMethodRoundDown, QuantityRoundingRoundingMethodRoundHalfUp:
return true
}
return false
}
// Optional. Only valid for USAGE products. If provided, the quantity will be
// rounded using the provided rounding method and decimal places. For example, if
// the method is "round up" and the decimal places is 0, then the quantity will be
// rounded up to the nearest integer.
type QuantityRoundingParam struct {
DecimalPlaces param.Field[float64] `json:"decimal_places,required"`
RoundingMethod param.Field[QuantityRoundingRoundingMethod] `json:"rounding_method,required"`
}
func (r QuantityRoundingParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type ContractProductNewResponse struct {
Data shared.ID `json:"data,required"`
JSON contractProductNewResponseJSON `json:"-"`
}
// contractProductNewResponseJSON contains the JSON metadata for the struct
// [ContractProductNewResponse]
type contractProductNewResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ContractProductNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r contractProductNewResponseJSON) RawJSON() string {
return r.raw
}
type ContractProductGetResponse struct {
Data ContractProductGetResponseData `json:"data,required"`
JSON contractProductGetResponseJSON `json:"-"`
}
// contractProductGetResponseJSON contains the JSON metadata for the struct
// [ContractProductGetResponse]
type contractProductGetResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ContractProductGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r contractProductGetResponseJSON) RawJSON() string {
return r.raw
}
type ContractProductGetResponseData struct {
ID string `json:"id,required" format:"uuid"`
Current ProductListItemState `json:"current,required"`
Initial ProductListItemState `json:"initial,required"`
Type ContractProductGetResponseDataType `json:"type,required"`
Updates []ContractProductGetResponseDataUpdate `json:"updates,required"`
ArchivedAt time.Time `json:"archived_at,nullable" format:"date-time"`
CustomFields map[string]string `json:"custom_fields"`
JSON contractProductGetResponseDataJSON `json:"-"`
}
// contractProductGetResponseDataJSON contains the JSON metadata for the struct
// [ContractProductGetResponseData]
type contractProductGetResponseDataJSON struct {
ID apijson.Field
Current apijson.Field
Initial apijson.Field
Type apijson.Field
Updates apijson.Field
ArchivedAt apijson.Field
CustomFields apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ContractProductGetResponseData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r contractProductGetResponseDataJSON) RawJSON() string {
return r.raw
}
type ContractProductGetResponseDataType string
const (
ContractProductGetResponseDataTypeUsage ContractProductGetResponseDataType = "USAGE"
ContractProductGetResponseDataTypeSubscription ContractProductGetResponseDataType = "SUBSCRIPTION"
ContractProductGetResponseDataTypeComposite ContractProductGetResponseDataType = "COMPOSITE"
ContractProductGetResponseDataTypeFixed ContractProductGetResponseDataType = "FIXED"
ContractProductGetResponseDataTypeProService ContractProductGetResponseDataType = "PRO_SERVICE"
)
func (r ContractProductGetResponseDataType) IsKnown() bool {
switch r {
case ContractProductGetResponseDataTypeUsage, ContractProductGetResponseDataTypeSubscription, ContractProductGetResponseDataTypeComposite, ContractProductGetResponseDataTypeFixed, ContractProductGetResponseDataTypeProService:
return true
}
return false
}
type ContractProductGetResponseDataUpdate struct {
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
CreatedBy string `json:"created_by,required"`
BillableMetricID string `json:"billable_metric_id" format:"uuid"`
CompositeProductIDs []string `json:"composite_product_ids" format:"uuid"`
CompositeTags []string `json:"composite_tags"`
ExcludeFreeUsage bool `json:"exclude_free_usage"`
IsRefundable bool `json:"is_refundable"`
Name string `json:"name"`
// This field's availability is dependent on your client's configuration.
NetsuiteInternalItemID string `json:"netsuite_internal_item_id"`
// This field's availability is dependent on your client's configuration.
NetsuiteOverageItemID string `json:"netsuite_overage_item_id"`
// For USAGE products only. Groups usage line items on invoices.
PresentationGroupKey []string `json:"presentation_group_key"`
// For USAGE products only. If set, pricing for this product will be determined for
// each pricing_group_key value, as opposed to the product as a whole.
PricingGroupKey []string `json:"pricing_group_key"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// converted using the provided conversion factor and operation. For example, if
// the operation is "multiply" and the conversion factor is 100, then the quantity
// will be multiplied by 100. This can be used in cases where data is sent in one
// unit and priced in another. For example, data could be sent in MB and priced in
// GB. In this case, the conversion factor would be 1024 and the operation would be
// "divide".
QuantityConversion QuantityConversion `json:"quantity_conversion,nullable"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// rounded using the provided rounding method and decimal places. For example, if
// the method is "round up" and the decimal places is 0, then the quantity will be
// rounded up to the nearest integer.
QuantityRounding QuantityRounding `json:"quantity_rounding,nullable"`
StartingAt time.Time `json:"starting_at" format:"date-time"`
Tags []string `json:"tags"`
JSON contractProductGetResponseDataUpdateJSON `json:"-"`
}
// contractProductGetResponseDataUpdateJSON contains the JSON metadata for the
// struct [ContractProductGetResponseDataUpdate]
type contractProductGetResponseDataUpdateJSON struct {
CreatedAt apijson.Field
CreatedBy apijson.Field
BillableMetricID apijson.Field
CompositeProductIDs apijson.Field
CompositeTags apijson.Field
ExcludeFreeUsage apijson.Field
IsRefundable apijson.Field
Name apijson.Field
NetsuiteInternalItemID apijson.Field
NetsuiteOverageItemID apijson.Field
PresentationGroupKey apijson.Field
PricingGroupKey apijson.Field
QuantityConversion apijson.Field
QuantityRounding apijson.Field
StartingAt apijson.Field
Tags apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ContractProductGetResponseDataUpdate) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r contractProductGetResponseDataUpdateJSON) RawJSON() string {
return r.raw
}
type ContractProductUpdateResponse struct {
Data shared.ID `json:"data,required"`
JSON contractProductUpdateResponseJSON `json:"-"`
}
// contractProductUpdateResponseJSON contains the JSON metadata for the struct
// [ContractProductUpdateResponse]
type contractProductUpdateResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ContractProductUpdateResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r contractProductUpdateResponseJSON) RawJSON() string {
return r.raw
}
type ContractProductListResponse struct {
ID string `json:"id,required" format:"uuid"`
Current ProductListItemState `json:"current,required"`
Initial ProductListItemState `json:"initial,required"`
Type ContractProductListResponseType `json:"type,required"`
Updates []ContractProductListResponseUpdate `json:"updates,required"`
ArchivedAt time.Time `json:"archived_at,nullable" format:"date-time"`
CustomFields map[string]string `json:"custom_fields"`
JSON contractProductListResponseJSON `json:"-"`
}
// contractProductListResponseJSON contains the JSON metadata for the struct
// [ContractProductListResponse]
type contractProductListResponseJSON struct {
ID apijson.Field
Current apijson.Field
Initial apijson.Field
Type apijson.Field
Updates apijson.Field
ArchivedAt apijson.Field
CustomFields apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ContractProductListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r contractProductListResponseJSON) RawJSON() string {
return r.raw
}
type ContractProductListResponseType string
const (
ContractProductListResponseTypeUsage ContractProductListResponseType = "USAGE"
ContractProductListResponseTypeSubscription ContractProductListResponseType = "SUBSCRIPTION"
ContractProductListResponseTypeComposite ContractProductListResponseType = "COMPOSITE"
ContractProductListResponseTypeFixed ContractProductListResponseType = "FIXED"
ContractProductListResponseTypeProService ContractProductListResponseType = "PRO_SERVICE"
)
func (r ContractProductListResponseType) IsKnown() bool {
switch r {
case ContractProductListResponseTypeUsage, ContractProductListResponseTypeSubscription, ContractProductListResponseTypeComposite, ContractProductListResponseTypeFixed, ContractProductListResponseTypeProService:
return true
}
return false
}
type ContractProductListResponseUpdate struct {
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
CreatedBy string `json:"created_by,required"`
BillableMetricID string `json:"billable_metric_id" format:"uuid"`
CompositeProductIDs []string `json:"composite_product_ids" format:"uuid"`
CompositeTags []string `json:"composite_tags"`
ExcludeFreeUsage bool `json:"exclude_free_usage"`
IsRefundable bool `json:"is_refundable"`
Name string `json:"name"`
// This field's availability is dependent on your client's configuration.
NetsuiteInternalItemID string `json:"netsuite_internal_item_id"`
// This field's availability is dependent on your client's configuration.
NetsuiteOverageItemID string `json:"netsuite_overage_item_id"`
// For USAGE products only. Groups usage line items on invoices.
PresentationGroupKey []string `json:"presentation_group_key"`
// For USAGE products only. If set, pricing for this product will be determined for
// each pricing_group_key value, as opposed to the product as a whole.
PricingGroupKey []string `json:"pricing_group_key"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// converted using the provided conversion factor and operation. For example, if
// the operation is "multiply" and the conversion factor is 100, then the quantity
// will be multiplied by 100. This can be used in cases where data is sent in one
// unit and priced in another. For example, data could be sent in MB and priced in
// GB. In this case, the conversion factor would be 1024 and the operation would be
// "divide".
QuantityConversion QuantityConversion `json:"quantity_conversion,nullable"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// rounded using the provided rounding method and decimal places. For example, if
// the method is "round up" and the decimal places is 0, then the quantity will be
// rounded up to the nearest integer.
QuantityRounding QuantityRounding `json:"quantity_rounding,nullable"`
StartingAt time.Time `json:"starting_at" format:"date-time"`
Tags []string `json:"tags"`
JSON contractProductListResponseUpdateJSON `json:"-"`
}
// contractProductListResponseUpdateJSON contains the JSON metadata for the struct
// [ContractProductListResponseUpdate]
type contractProductListResponseUpdateJSON struct {
CreatedAt apijson.Field
CreatedBy apijson.Field
BillableMetricID apijson.Field
CompositeProductIDs apijson.Field
CompositeTags apijson.Field
ExcludeFreeUsage apijson.Field
IsRefundable apijson.Field
Name apijson.Field
NetsuiteInternalItemID apijson.Field
NetsuiteOverageItemID apijson.Field
PresentationGroupKey apijson.Field
PricingGroupKey apijson.Field
QuantityConversion apijson.Field
QuantityRounding apijson.Field
StartingAt apijson.Field
Tags apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ContractProductListResponseUpdate) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r contractProductListResponseUpdateJSON) RawJSON() string {
return r.raw
}
type ContractProductArchiveResponse struct {
Data shared.ID `json:"data,required"`
JSON contractProductArchiveResponseJSON `json:"-"`
}
// contractProductArchiveResponseJSON contains the JSON metadata for the struct
// [ContractProductArchiveResponse]
type contractProductArchiveResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ContractProductArchiveResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r contractProductArchiveResponseJSON) RawJSON() string {
return r.raw
}
type ContractProductNewParams struct {
// displayed on invoices
Name param.Field[string] `json:"name,required"`
Type param.Field[ContractProductNewParamsType] `json:"type,required"`
// Required for USAGE products
BillableMetricID param.Field[string] `json:"billable_metric_id" format:"uuid"`
// Required for COMPOSITE products
CompositeProductIDs param.Field[[]string] `json:"composite_product_ids" format:"uuid"`
// Required for COMPOSITE products
CompositeTags param.Field[[]string] `json:"composite_tags"`
// Beta feature only available for composite products. If true, products with $0
// will not be included when computing composite usage. Defaults to false
ExcludeFreeUsage param.Field[bool] `json:"exclude_free_usage"`
// This field's availability is dependent on your client's configuration. Defaults
// to true
IsRefundable param.Field[bool] `json:"is_refundable"`
// This field's availability is dependent on your client's configuration.
NetsuiteInternalItemID param.Field[string] `json:"netsuite_internal_item_id"`
// This field's availability is dependent on your client's configuration.
NetsuiteOverageItemID param.Field[string] `json:"netsuite_overage_item_id"`
// For USAGE products only. Groups usage line items on invoices.
PresentationGroupKey param.Field[[]string] `json:"presentation_group_key"`
// For USAGE products only. If set, pricing for this product will be determined for
// each pricing_group_key value, as opposed to the product as a whole.
PricingGroupKey param.Field[[]string] `json:"pricing_group_key"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// converted using the provided conversion factor and operation. For example, if
// the operation is "multiply" and the conversion factor is 100, then the quantity
// will be multiplied by 100. This can be used in cases where data is sent in one
// unit and priced in another. For example, data could be sent in MB and priced in
// GB. In this case, the conversion factor would be 1024 and the operation would be
// "divide".
QuantityConversion param.Field[QuantityConversionParam] `json:"quantity_conversion"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// rounded using the provided rounding method and decimal places. For example, if
// the method is "round up" and the decimal places is 0, then the quantity will be
// rounded up to the nearest integer.
QuantityRounding param.Field[QuantityRoundingParam] `json:"quantity_rounding"`
Tags param.Field[[]string] `json:"tags"`
}
func (r ContractProductNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type ContractProductNewParamsType string
const (
ContractProductNewParamsTypeFixed ContractProductNewParamsType = "FIXED"
ContractProductNewParamsTypeUsage ContractProductNewParamsType = "USAGE"
ContractProductNewParamsTypeComposite ContractProductNewParamsType = "COMPOSITE"
ContractProductNewParamsTypeSubscription ContractProductNewParamsType = "SUBSCRIPTION"
ContractProductNewParamsTypeProfessionalService ContractProductNewParamsType = "PROFESSIONAL_SERVICE"
ContractProductNewParamsTypeProService ContractProductNewParamsType = "PRO_SERVICE"
)
func (r ContractProductNewParamsType) IsKnown() bool {
switch r {
case ContractProductNewParamsTypeFixed, ContractProductNewParamsTypeUsage, ContractProductNewParamsTypeComposite, ContractProductNewParamsTypeSubscription, ContractProductNewParamsTypeProfessionalService, ContractProductNewParamsTypeProService:
return true
}
return false
}
type ContractProductGetParams struct {
ID shared.IDParam `json:"id,required"`
}
func (r ContractProductGetParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r.ID)
}
type ContractProductUpdateParams struct {
// ID of the product to update
ProductID param.Field[string] `json:"product_id,required" format:"uuid"`
// Timestamp representing when the update should go into effect. It must be on an
// hour boundary (e.g. 1:00, not 1:30).
StartingAt param.Field[time.Time] `json:"starting_at,required" format:"date-time"`
// Available for USAGE products only. If not provided, defaults to product's
// current billable metric.
BillableMetricID param.Field[string] `json:"billable_metric_id" format:"uuid"`
// Available for COMPOSITE products only. If not provided, defaults to product's
// current composite_product_ids.
CompositeProductIDs param.Field[[]string] `json:"composite_product_ids" format:"uuid"`
// Available for COMPOSITE products only. If not provided, defaults to product's
// current composite_tags.
CompositeTags param.Field[[]string] `json:"composite_tags"`
// Beta feature only available for composite products. If true, products with $0
// will not be included when computing composite usage. Defaults to false
ExcludeFreeUsage param.Field[bool] `json:"exclude_free_usage"`
// Defaults to product's current refundability status. This field's availability is
// dependent on your client's configuration.
IsRefundable param.Field[bool] `json:"is_refundable"`
// displayed on invoices. If not provided, defaults to product's current name.
Name param.Field[string] `json:"name"`
// If not provided, defaults to product's current netsuite_internal_item_id. This
// field's availability is dependent on your client's configuration.
NetsuiteInternalItemID param.Field[string] `json:"netsuite_internal_item_id"`
// Available for USAGE and COMPOSITE products only. If not provided, defaults to
// product's current netsuite_overage_item_id. This field's availability is
// dependent on your client's configuration.
NetsuiteOverageItemID param.Field[string] `json:"netsuite_overage_item_id"`
// For USAGE products only. Groups usage line items on invoices.
PresentationGroupKey param.Field[[]string] `json:"presentation_group_key"`
// For USAGE products only. If set, pricing for this product will be determined for
// each pricing_group_key value, as opposed to the product as a whole.
PricingGroupKey param.Field[[]string] `json:"pricing_group_key"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// converted using the provided conversion factor and operation. For example, if
// the operation is "multiply" and the conversion factor is 100, then the quantity
// will be multiplied by 100. This can be used in cases where data is sent in one
// unit and priced in another. For example, data could be sent in MB and priced in
// GB. In this case, the conversion factor would be 1024 and the operation would be
// "divide".
QuantityConversion param.Field[QuantityConversionParam] `json:"quantity_conversion"`
// Optional. Only valid for USAGE products. If provided, the quantity will be
// rounded using the provided rounding method and decimal places. For example, if
// the method is "round up" and the decimal places is 0, then the quantity will be
// rounded up to the nearest integer.
QuantityRounding param.Field[QuantityRoundingParam] `json:"quantity_rounding"`
// If not provided, defaults to product's current tags
Tags param.Field[[]string] `json:"tags"`
}
func (r ContractProductUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type ContractProductListParams struct {
// Max number of results that should be returned
Limit param.Field[int64] `query:"limit"`
// Cursor that indicates where the next page of results should start.
NextPage param.Field[string] `query:"next_page"`
// Filter options for the product list
ArchiveFilter param.Field[ContractProductListParamsArchiveFilter] `json:"archive_filter"`
}
func (r ContractProductListParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// URLQuery serializes [ContractProductListParams]'s query parameters as
// `url.Values`.
func (r ContractProductListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Filter options for the product list
type ContractProductListParamsArchiveFilter string
const (
ContractProductListParamsArchiveFilterArchived ContractProductListParamsArchiveFilter = "ARCHIVED"
ContractProductListParamsArchiveFilterNotArchived ContractProductListParamsArchiveFilter = "NOT_ARCHIVED"
ContractProductListParamsArchiveFilterAll ContractProductListParamsArchiveFilter = "ALL"
)
func (r ContractProductListParamsArchiveFilter) IsKnown() bool {
switch r {
case ContractProductListParamsArchiveFilterArchived, ContractProductListParamsArchiveFilterNotArchived, ContractProductListParamsArchiveFilterAll:
return true
}
return false
}
type ContractProductArchiveParams struct {
// ID of the product to be archived
ProductID param.Field[string] `json:"product_id,required" format:"uuid"`
}
func (r ContractProductArchiveParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}