-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoicelineitem.go
832 lines (754 loc) · 30.1 KB
/
invoicelineitem.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
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package orb
import (
"context"
"net/http"
"reflect"
"time"
"github.com/orbcorp/orb-go/internal/apijson"
"github.com/orbcorp/orb-go/internal/param"
"github.com/orbcorp/orb-go/internal/requestconfig"
"github.com/orbcorp/orb-go/option"
"github.com/orbcorp/orb-go/shared"
"github.com/tidwall/gjson"
)
// InvoiceLineItemService contains methods and other services that help with
// interacting with the orb 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 [NewInvoiceLineItemService] method instead.
type InvoiceLineItemService struct {
Options []option.RequestOption
}
// NewInvoiceLineItemService 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 NewInvoiceLineItemService(opts ...option.RequestOption) (r *InvoiceLineItemService) {
r = &InvoiceLineItemService{}
r.Options = opts
return
}
// This creates a one-off fixed fee invoice line item on an Invoice. This can only
// be done for invoices that are in a `draft` status.
func (r *InvoiceLineItemService) New(ctx context.Context, body InvoiceLineItemNewParams, opts ...option.RequestOption) (res *InvoiceLineItemNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "invoice_line_items"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
type InvoiceLineItemNewResponse struct {
// A unique ID for this line item.
ID string `json:"id,required"`
// The final amount after any discounts or minimums.
Amount string `json:"amount,required"`
Discount shared.Discount `json:"discount,required,nullable"`
// The end date of the range of time applied for this line item's price.
EndDate time.Time `json:"end_date,required" format:"date-time"`
// [DEPRECATED] For configured prices that are split by a grouping key, this will
// be populated with the key and a value. The `amount` and `subtotal` will be the
// values for this particular grouping.
Grouping string `json:"grouping,required,nullable"`
Maximum InvoiceLineItemNewResponseMaximum `json:"maximum,required,nullable"`
MaximumAmount string `json:"maximum_amount,required,nullable"`
Minimum InvoiceLineItemNewResponseMinimum `json:"minimum,required,nullable"`
MinimumAmount string `json:"minimum_amount,required,nullable"`
// The name of the price associated with this line item.
Name string `json:"name,required"`
// The Price resource represents a price that can be billed on a subscription,
// resulting in a charge on an invoice in the form of an invoice line item. Prices
// take a quantity and determine an amount to bill.
//
// Orb supports a few different pricing models out of the box. Each of these models
// is serialized differently in a given Price object. The model_type field
// determines the key for the configuration object that is present.
//
// ## Unit pricing
//
// With unit pricing, each unit costs a fixed amount.
//
// ```json
//
// {
// ...
// "model_type": "unit",
// "unit_config": {
// "unit_amount": "0.50"
// }
// ...
// }
//
// ```
//
// ## Tiered pricing
//
// In tiered pricing, the cost of a given unit depends on the tier range that it
// falls into, where each tier range is defined by an upper and lower bound. For
// example, the first ten units may cost $0.50 each and all units thereafter may
// cost $0.10 each.
//
// ```json
//
// {
// ...
// "model_type": "tiered",
// "tiered_config": {
// "tiers": [
// {
// "first_unit": 1,
// "last_unit": 10,
// "unit_amount": "0.50"
// },
// {
// "first_unit": 11,
// "last_unit": null,
// "unit_amount": "0.10"
// }
// ]
// }
// ...
//
// ```
//
// ## Bulk pricing
//
// Bulk pricing applies when the number of units determine the cost of all units.
// For example, if you've bought less than 10 units, they may each be $0.50 for a
// total of $5.00. Once you've bought more than 10 units, all units may now be
// priced at $0.40 (i.e. 101 units total would be $40.40).
//
// ```json
//
// {
// ...
// "model_type": "bulk",
// "bulk_config": {
// "tiers": [
// {
// "maximum_units": 10,
// "unit_amount": "0.50"
// },
// {
// "maximum_units": 1000,
// "unit_amount": "0.40"
// }
// ]
// }
// ...
// }
//
// ```
//
// ## Package pricing
//
// Package pricing defines the size or granularity of a unit for billing purposes.
// For example, if the package size is set to 5, then 4 units will be billed as 5
// and 6 units will be billed at 10.
//
// ```json
//
// {
// ...
// "model_type": "package",
// "package_config": {
// "package_amount": "0.80",
// "package_size": 10
// }
// ...
// }
//
// ```
//
// ## BPS pricing
//
// BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a
// percent (the number of basis points to charge), as well as a cap per event to
// assess. For example, this would allow you to assess a fee of 0.25% on every
// payment you process, with a maximum charge of $25 per payment.
//
// ```json
//
// {
// ...
// "model_type": "bps",
// "bps_config": {
// "bps": 125,
// "per_unit_maximum": "11.00"
// }
// ...
// }
//
// ```
//
// ## Bulk BPS pricing
//
// Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the
// total quantity across all events. Similar to bulk pricing, the BPS parameters of
// a given event depends on the tier range that the billing period falls into. Each
// tier range is defined by an upper bound. For example, after $1.5M of payment
// volume is reached, each individual payment may have a lower cap or a smaller
// take-rate.
//
// ```json
//
// ...
// "model_type": "bulk_bps",
// "bulk_bps_config": {
// "tiers": [
// {
// "maximum_amount": "1000000.00",
// "bps": 125,
// "per_unit_maximum": "19.00"
// },
// {
// "maximum_amount": null,
// "bps": 115,
// "per_unit_maximum": "4.00"
// }
// ]
// }
// ...
// }
//
// ```
//
// ## Tiered BPS pricing
//
// Tiered BPS pricing specifies BPS parameters in a graduated manner, where an
// event's applicable parameter is a function of its marginal addition to the
// period total. Similar to tiered pricing, the BPS parameters of a given event
// depends on the tier range that it falls into, where each tier range is defined
// by an upper and lower bound. For example, the first few payments may have a 0.8
// BPS take-rate and all payments after a specific volume may incur a take-rate of
// 0.5 BPS each.
//
// ```json
//
// ...
// "model_type": "tiered_bps",
// "tiered_bps_config": {
// "tiers": [
// {
// "minimum_amount": "0",
// "maximum_amount": "1000000.00",
// "bps": 125,
// "per_unit_maximum": "19.00"
// },
// {
// "minimum_amount": "1000000.00",
// "maximum_amount": null,
// "bps": 115,
// "per_unit_maximum": "4.00"
// }
// ]
// }
// ...
// }
//
// ```
//
// ## Matrix pricing
//
// Matrix pricing defines a set of unit prices in a one or two-dimensional matrix.
// `dimensions` defines the two event property values evaluated in this pricing
// model. In a one-dimensional matrix, the second value is `null`. Every
// configuration has a list of `matrix_values` which give the unit prices for
// specified property values. In a one-dimensional matrix, the matrix values will
// have `dimension_values` where the second value of the pair is null. If an event
// does not match any of the dimension values in the matrix, it will resort to the
// `default_unit_amount`.
//
// ```json
//
// {
// "model_type": "matrix"
// "matrix_config": {
// "default_unit_amount": "3.00",
// "dimensions": [
// "cluster_name",
// "region"
// ],
// "matrix_values": [
// {
// "dimension_values": [
// "alpha",
// "west"
// ],
// "unit_amount": "2.00"
// },
// ...
// ]
// }
// }
//
// ```
//
// ## Fixed fees
//
// Fixed fees are prices that are applied independent of usage quantities, and
// follow unit pricing. They also have an additional parameter
// `fixed_price_quantity`. If the Price represents a fixed cost, this represents
// the quantity of units applied.
//
// ```json
//
// {
// ...
// "id": "price_id",
// "model_type": "unit",
// "unit_config": {
// "unit_amount": "2.00"
// },
// "fixed_price_quantity": 3.0
// ...
// }
//
// ```
Price Price `json:"price,required,nullable"`
Quantity float64 `json:"quantity,required"`
// The start date of the range of time applied for this line item's price.
StartDate time.Time `json:"start_date,required" format:"date-time"`
// For complex pricing structures, the line item can be broken down further in
// `sub_line_items`.
SubLineItems []InvoiceLineItemNewResponseSubLineItem `json:"sub_line_items,required"`
// The line amount before any line item-specific discounts or minimums.
Subtotal string `json:"subtotal,required"`
// An array of tax rates and their incurred tax amounts. Empty if no tax
// integration is configured.
TaxAmounts []InvoiceLineItemNewResponseTaxAmount `json:"tax_amounts,required"`
JSON invoiceLineItemNewResponseJSON `json:"-"`
}
// invoiceLineItemNewResponseJSON contains the JSON metadata for the struct
// [InvoiceLineItemNewResponse]
type invoiceLineItemNewResponseJSON struct {
ID apijson.Field
Amount apijson.Field
Discount apijson.Field
EndDate apijson.Field
Grouping apijson.Field
Maximum apijson.Field
MaximumAmount apijson.Field
Minimum apijson.Field
MinimumAmount apijson.Field
Name apijson.Field
Price apijson.Field
Quantity apijson.Field
StartDate apijson.Field
SubLineItems apijson.Field
Subtotal apijson.Field
TaxAmounts apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseJSON) RawJSON() string {
return r.raw
}
type InvoiceLineItemNewResponseMaximum struct {
// List of price_ids that this maximum amount applies to. For plan/plan phase
// maximums, this can be a subset of prices.
AppliesToPriceIDs []string `json:"applies_to_price_ids,required"`
// Maximum amount applied
MaximumAmount string `json:"maximum_amount,required"`
JSON invoiceLineItemNewResponseMaximumJSON `json:"-"`
}
// invoiceLineItemNewResponseMaximumJSON contains the JSON metadata for the struct
// [InvoiceLineItemNewResponseMaximum]
type invoiceLineItemNewResponseMaximumJSON struct {
AppliesToPriceIDs apijson.Field
MaximumAmount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseMaximum) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseMaximumJSON) RawJSON() string {
return r.raw
}
type InvoiceLineItemNewResponseMinimum struct {
// List of price_ids that this minimum amount applies to. For plan/plan phase
// minimums, this can be a subset of prices.
AppliesToPriceIDs []string `json:"applies_to_price_ids,required"`
// Minimum amount applied
MinimumAmount string `json:"minimum_amount,required"`
JSON invoiceLineItemNewResponseMinimumJSON `json:"-"`
}
// invoiceLineItemNewResponseMinimumJSON contains the JSON metadata for the struct
// [InvoiceLineItemNewResponseMinimum]
type invoiceLineItemNewResponseMinimumJSON struct {
AppliesToPriceIDs apijson.Field
MinimumAmount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseMinimum) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseMinimumJSON) RawJSON() string {
return r.raw
}
type InvoiceLineItemNewResponseSubLineItem struct {
// The total amount for this sub line item.
Amount string `json:"amount,required"`
// This field can have the runtime type of
// [InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemGrouping],
// [InvoiceLineItemNewResponseSubLineItemsTierSubLineItemGrouping],
// [InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemGrouping].
Grouping interface{} `json:"grouping,required"`
Name string `json:"name,required"`
Quantity float64 `json:"quantity,required"`
Type InvoiceLineItemNewResponseSubLineItemsType `json:"type,required"`
// This field can have the runtime type of
// [InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemMatrixConfig].
MatrixConfig interface{} `json:"matrix_config"`
// This field can have the runtime type of
// [InvoiceLineItemNewResponseSubLineItemsTierSubLineItemTierConfig].
TierConfig interface{} `json:"tier_config"`
JSON invoiceLineItemNewResponseSubLineItemJSON `json:"-"`
union InvoiceLineItemNewResponseSubLineItemsUnion
}
// invoiceLineItemNewResponseSubLineItemJSON contains the JSON metadata for the
// struct [InvoiceLineItemNewResponseSubLineItem]
type invoiceLineItemNewResponseSubLineItemJSON struct {
Amount apijson.Field
Grouping apijson.Field
Name apijson.Field
Quantity apijson.Field
Type apijson.Field
MatrixConfig apijson.Field
TierConfig apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r invoiceLineItemNewResponseSubLineItemJSON) RawJSON() string {
return r.raw
}
func (r *InvoiceLineItemNewResponseSubLineItem) UnmarshalJSON(data []byte) (err error) {
*r = InvoiceLineItemNewResponseSubLineItem{}
err = apijson.UnmarshalRoot(data, &r.union)
if err != nil {
return err
}
return apijson.Port(r.union, &r)
}
// AsUnion returns a [InvoiceLineItemNewResponseSubLineItemsUnion] interface which
// you can cast to the specific types for more type safety.
//
// Possible runtime types of the union are
// [InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItem],
// [InvoiceLineItemNewResponseSubLineItemsTierSubLineItem],
// [InvoiceLineItemNewResponseSubLineItemsOtherSubLineItem].
func (r InvoiceLineItemNewResponseSubLineItem) AsUnion() InvoiceLineItemNewResponseSubLineItemsUnion {
return r.union
}
// Union satisfied by [InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItem],
// [InvoiceLineItemNewResponseSubLineItemsTierSubLineItem] or
// [InvoiceLineItemNewResponseSubLineItemsOtherSubLineItem].
type InvoiceLineItemNewResponseSubLineItemsUnion interface {
implementsInvoiceLineItemNewResponseSubLineItem()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*InvoiceLineItemNewResponseSubLineItemsUnion)(nil)).Elem(),
"type",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItem{}),
DiscriminatorValue: "matrix",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(InvoiceLineItemNewResponseSubLineItemsTierSubLineItem{}),
DiscriminatorValue: "tier",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(InvoiceLineItemNewResponseSubLineItemsOtherSubLineItem{}),
DiscriminatorValue: "'null'",
},
)
}
type InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItem struct {
// The total amount for this sub line item.
Amount string `json:"amount,required"`
Grouping InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemGrouping `json:"grouping,required,nullable"`
MatrixConfig InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemMatrixConfig `json:"matrix_config,required"`
Name string `json:"name,required"`
Quantity float64 `json:"quantity,required"`
Type InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemType `json:"type,required"`
JSON invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemJSON `json:"-"`
}
// invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemJSON contains the JSON
// metadata for the struct
// [InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItem]
type invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemJSON struct {
Amount apijson.Field
Grouping apijson.Field
MatrixConfig apijson.Field
Name apijson.Field
Quantity apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItem) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemJSON) RawJSON() string {
return r.raw
}
func (r InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItem) implementsInvoiceLineItemNewResponseSubLineItem() {
}
type InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemGrouping struct {
Key string `json:"key,required"`
// No value indicates the default group
Value string `json:"value,required,nullable"`
JSON invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemGroupingJSON `json:"-"`
}
// invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemGroupingJSON contains the
// JSON metadata for the struct
// [InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemGrouping]
type invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemGroupingJSON struct {
Key apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemGrouping) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemGroupingJSON) RawJSON() string {
return r.raw
}
type InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemMatrixConfig struct {
// The ordered dimension values for this line item.
DimensionValues []string `json:"dimension_values,required"`
JSON invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemMatrixConfigJSON `json:"-"`
}
// invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemMatrixConfigJSON contains
// the JSON metadata for the struct
// [InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemMatrixConfig]
type invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemMatrixConfigJSON struct {
DimensionValues apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemMatrixConfig) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseSubLineItemsMatrixSubLineItemMatrixConfigJSON) RawJSON() string {
return r.raw
}
type InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemType string
const (
InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemTypeMatrix InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemType = "matrix"
)
func (r InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemType) IsKnown() bool {
switch r {
case InvoiceLineItemNewResponseSubLineItemsMatrixSubLineItemTypeMatrix:
return true
}
return false
}
type InvoiceLineItemNewResponseSubLineItemsTierSubLineItem struct {
// The total amount for this sub line item.
Amount string `json:"amount,required"`
Grouping InvoiceLineItemNewResponseSubLineItemsTierSubLineItemGrouping `json:"grouping,required,nullable"`
Name string `json:"name,required"`
Quantity float64 `json:"quantity,required"`
TierConfig InvoiceLineItemNewResponseSubLineItemsTierSubLineItemTierConfig `json:"tier_config,required"`
Type InvoiceLineItemNewResponseSubLineItemsTierSubLineItemType `json:"type,required"`
JSON invoiceLineItemNewResponseSubLineItemsTierSubLineItemJSON `json:"-"`
}
// invoiceLineItemNewResponseSubLineItemsTierSubLineItemJSON contains the JSON
// metadata for the struct [InvoiceLineItemNewResponseSubLineItemsTierSubLineItem]
type invoiceLineItemNewResponseSubLineItemsTierSubLineItemJSON struct {
Amount apijson.Field
Grouping apijson.Field
Name apijson.Field
Quantity apijson.Field
TierConfig apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseSubLineItemsTierSubLineItem) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseSubLineItemsTierSubLineItemJSON) RawJSON() string {
return r.raw
}
func (r InvoiceLineItemNewResponseSubLineItemsTierSubLineItem) implementsInvoiceLineItemNewResponseSubLineItem() {
}
type InvoiceLineItemNewResponseSubLineItemsTierSubLineItemGrouping struct {
Key string `json:"key,required"`
// No value indicates the default group
Value string `json:"value,required,nullable"`
JSON invoiceLineItemNewResponseSubLineItemsTierSubLineItemGroupingJSON `json:"-"`
}
// invoiceLineItemNewResponseSubLineItemsTierSubLineItemGroupingJSON contains the
// JSON metadata for the struct
// [InvoiceLineItemNewResponseSubLineItemsTierSubLineItemGrouping]
type invoiceLineItemNewResponseSubLineItemsTierSubLineItemGroupingJSON struct {
Key apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseSubLineItemsTierSubLineItemGrouping) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseSubLineItemsTierSubLineItemGroupingJSON) RawJSON() string {
return r.raw
}
type InvoiceLineItemNewResponseSubLineItemsTierSubLineItemTierConfig struct {
FirstUnit float64 `json:"first_unit,required"`
LastUnit float64 `json:"last_unit,required,nullable"`
UnitAmount string `json:"unit_amount,required"`
JSON invoiceLineItemNewResponseSubLineItemsTierSubLineItemTierConfigJSON `json:"-"`
}
// invoiceLineItemNewResponseSubLineItemsTierSubLineItemTierConfigJSON contains the
// JSON metadata for the struct
// [InvoiceLineItemNewResponseSubLineItemsTierSubLineItemTierConfig]
type invoiceLineItemNewResponseSubLineItemsTierSubLineItemTierConfigJSON struct {
FirstUnit apijson.Field
LastUnit apijson.Field
UnitAmount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseSubLineItemsTierSubLineItemTierConfig) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseSubLineItemsTierSubLineItemTierConfigJSON) RawJSON() string {
return r.raw
}
type InvoiceLineItemNewResponseSubLineItemsTierSubLineItemType string
const (
InvoiceLineItemNewResponseSubLineItemsTierSubLineItemTypeTier InvoiceLineItemNewResponseSubLineItemsTierSubLineItemType = "tier"
)
func (r InvoiceLineItemNewResponseSubLineItemsTierSubLineItemType) IsKnown() bool {
switch r {
case InvoiceLineItemNewResponseSubLineItemsTierSubLineItemTypeTier:
return true
}
return false
}
type InvoiceLineItemNewResponseSubLineItemsOtherSubLineItem struct {
// The total amount for this sub line item.
Amount string `json:"amount,required"`
Grouping InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemGrouping `json:"grouping,required,nullable"`
Name string `json:"name,required"`
Quantity float64 `json:"quantity,required"`
Type InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemType `json:"type,required"`
JSON invoiceLineItemNewResponseSubLineItemsOtherSubLineItemJSON `json:"-"`
}
// invoiceLineItemNewResponseSubLineItemsOtherSubLineItemJSON contains the JSON
// metadata for the struct [InvoiceLineItemNewResponseSubLineItemsOtherSubLineItem]
type invoiceLineItemNewResponseSubLineItemsOtherSubLineItemJSON struct {
Amount apijson.Field
Grouping apijson.Field
Name apijson.Field
Quantity apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseSubLineItemsOtherSubLineItem) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseSubLineItemsOtherSubLineItemJSON) RawJSON() string {
return r.raw
}
func (r InvoiceLineItemNewResponseSubLineItemsOtherSubLineItem) implementsInvoiceLineItemNewResponseSubLineItem() {
}
type InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemGrouping struct {
Key string `json:"key,required"`
// No value indicates the default group
Value string `json:"value,required,nullable"`
JSON invoiceLineItemNewResponseSubLineItemsOtherSubLineItemGroupingJSON `json:"-"`
}
// invoiceLineItemNewResponseSubLineItemsOtherSubLineItemGroupingJSON contains the
// JSON metadata for the struct
// [InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemGrouping]
type invoiceLineItemNewResponseSubLineItemsOtherSubLineItemGroupingJSON struct {
Key apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemGrouping) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseSubLineItemsOtherSubLineItemGroupingJSON) RawJSON() string {
return r.raw
}
type InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemType string
const (
InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemTypeNull InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemType = "'null'"
)
func (r InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemType) IsKnown() bool {
switch r {
case InvoiceLineItemNewResponseSubLineItemsOtherSubLineItemTypeNull:
return true
}
return false
}
type InvoiceLineItemNewResponseSubLineItemsType string
const (
InvoiceLineItemNewResponseSubLineItemsTypeMatrix InvoiceLineItemNewResponseSubLineItemsType = "matrix"
InvoiceLineItemNewResponseSubLineItemsTypeTier InvoiceLineItemNewResponseSubLineItemsType = "tier"
InvoiceLineItemNewResponseSubLineItemsTypeNull InvoiceLineItemNewResponseSubLineItemsType = "'null'"
)
func (r InvoiceLineItemNewResponseSubLineItemsType) IsKnown() bool {
switch r {
case InvoiceLineItemNewResponseSubLineItemsTypeMatrix, InvoiceLineItemNewResponseSubLineItemsTypeTier, InvoiceLineItemNewResponseSubLineItemsTypeNull:
return true
}
return false
}
type InvoiceLineItemNewResponseTaxAmount struct {
// The amount of additional tax incurred by this tax rate.
Amount string `json:"amount,required"`
// The human-readable description of the applied tax rate.
TaxRateDescription string `json:"tax_rate_description,required"`
// The tax rate percentage, out of 100.
TaxRatePercentage string `json:"tax_rate_percentage,required,nullable"`
JSON invoiceLineItemNewResponseTaxAmountJSON `json:"-"`
}
// invoiceLineItemNewResponseTaxAmountJSON contains the JSON metadata for the
// struct [InvoiceLineItemNewResponseTaxAmount]
type invoiceLineItemNewResponseTaxAmountJSON struct {
Amount apijson.Field
TaxRateDescription apijson.Field
TaxRatePercentage apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InvoiceLineItemNewResponseTaxAmount) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r invoiceLineItemNewResponseTaxAmountJSON) RawJSON() string {
return r.raw
}
type InvoiceLineItemNewParams struct {
// The total amount in the invoice's currency to add to the line item.
Amount param.Field[string] `json:"amount,required"`
// A date string to specify the line item's end date in the customer's timezone.
EndDate param.Field[time.Time] `json:"end_date,required" format:"date"`
// The id of the Invoice to add this line item.
InvoiceID param.Field[string] `json:"invoice_id,required"`
// The item name associated with this line item. If an item with the same name
// exists in Orb, that item will be associated with the line item.
Name param.Field[string] `json:"name,required"`
// The number of units on the line item
Quantity param.Field[float64] `json:"quantity,required"`
// A date string to specify the line item's start date in the customer's timezone.
StartDate param.Field[time.Time] `json:"start_date,required" format:"date"`
}
func (r InvoiceLineItemNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}