-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustomer.go
853 lines (746 loc) · 38.9 KB
/
customer.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
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package metronome
import (
"context"
"errors"
"fmt"
"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/param"
"github.com/Metronome-Industries/metronome-go/internal/requestconfig"
"github.com/Metronome-Industries/metronome-go/option"
"github.com/Metronome-Industries/metronome-go/packages/pagination"
"github.com/Metronome-Industries/metronome-go/shared"
)
// CustomerService 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 [NewCustomerService] method instead.
type CustomerService struct {
Options []option.RequestOption
Alerts *CustomerAlertService
Plans *CustomerPlanService
Invoices *CustomerInvoiceService
BillingConfig *CustomerBillingConfigService
Commits *CustomerCommitService
Credits *CustomerCreditService
NamedSchedules *CustomerNamedScheduleService
}
// NewCustomerService 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 NewCustomerService(opts ...option.RequestOption) (r *CustomerService) {
r = &CustomerService{}
r.Options = opts
r.Alerts = NewCustomerAlertService(opts...)
r.Plans = NewCustomerPlanService(opts...)
r.Invoices = NewCustomerInvoiceService(opts...)
r.BillingConfig = NewCustomerBillingConfigService(opts...)
r.Commits = NewCustomerCommitService(opts...)
r.Credits = NewCustomerCreditService(opts...)
r.NamedSchedules = NewCustomerNamedScheduleService(opts...)
return
}
// Create a new customer
func (r *CustomerService) New(ctx context.Context, body CustomerNewParams, opts ...option.RequestOption) (res *CustomerNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "customers"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Get a customer by Metronome ID.
func (r *CustomerService) Get(ctx context.Context, query CustomerGetParams, opts ...option.RequestOption) (res *CustomerGetResponse, err error) {
opts = append(r.Options[:], opts...)
if query.CustomerID.Value == "" {
err = errors.New("missing required customer_id parameter")
return
}
path := fmt.Sprintf("customers/%s", query.CustomerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// List all customers.
func (r *CustomerService) List(ctx context.Context, query CustomerListParams, opts ...option.RequestOption) (res *pagination.CursorPage[CustomerDetail], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "customers"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &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 all customers.
func (r *CustomerService) ListAutoPaging(ctx context.Context, query CustomerListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[CustomerDetail] {
return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...))
}
// Archive a customer
func (r *CustomerService) Archive(ctx context.Context, body CustomerArchiveParams, opts ...option.RequestOption) (res *CustomerArchiveResponse, err error) {
opts = append(r.Options[:], opts...)
path := "customers/archive"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Get all billable metrics for a given customer.
func (r *CustomerService) ListBillableMetrics(ctx context.Context, params CustomerListBillableMetricsParams, opts ...option.RequestOption) (res *pagination.CursorPage[CustomerListBillableMetricsResponse], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if params.CustomerID.Value == "" {
err = errors.New("missing required customer_id parameter")
return
}
path := fmt.Sprintf("customers/%s/billable-metrics", params.CustomerID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, 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
}
// Get all billable metrics for a given customer.
func (r *CustomerService) ListBillableMetricsAutoPaging(ctx context.Context, params CustomerListBillableMetricsParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[CustomerListBillableMetricsResponse] {
return pagination.NewCursorPageAutoPager(r.ListBillableMetrics(ctx, params, opts...))
}
// Fetch daily pending costs for the specified customer, broken down by credit type
// and line items. Note: this is not supported for customers whose plan includes a
// UNIQUE-type billable metric.
func (r *CustomerService) ListCosts(ctx context.Context, params CustomerListCostsParams, opts ...option.RequestOption) (res *pagination.CursorPage[CustomerListCostsResponse], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if params.CustomerID.Value == "" {
err = errors.New("missing required customer_id parameter")
return
}
path := fmt.Sprintf("customers/%s/costs", params.CustomerID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, 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
}
// Fetch daily pending costs for the specified customer, broken down by credit type
// and line items. Note: this is not supported for customers whose plan includes a
// UNIQUE-type billable metric.
func (r *CustomerService) ListCostsAutoPaging(ctx context.Context, params CustomerListCostsParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[CustomerListCostsResponse] {
return pagination.NewCursorPageAutoPager(r.ListCosts(ctx, params, opts...))
}
// Sets the ingest aliases for a customer. Ingest aliases can be used in the
// `customer_id` field when sending usage events to Metronome. This call is
// idempotent. It fully replaces the set of ingest aliases for the given customer.
func (r *CustomerService) SetIngestAliases(ctx context.Context, params CustomerSetIngestAliasesParams, opts ...option.RequestOption) (err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
if params.CustomerID.Value == "" {
err = errors.New("missing required customer_id parameter")
return
}
path := fmt.Sprintf("customers/%s/setIngestAliases", params.CustomerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, nil, opts...)
return
}
// Updates the specified customer's name.
func (r *CustomerService) SetName(ctx context.Context, params CustomerSetNameParams, opts ...option.RequestOption) (res *CustomerSetNameResponse, err error) {
opts = append(r.Options[:], opts...)
if params.CustomerID.Value == "" {
err = errors.New("missing required customer_id parameter")
return
}
path := fmt.Sprintf("customers/%s/setName", params.CustomerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return
}
// Updates the specified customer's config.
func (r *CustomerService) UpdateConfig(ctx context.Context, params CustomerUpdateConfigParams, opts ...option.RequestOption) (err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
if params.CustomerID.Value == "" {
err = errors.New("missing required customer_id parameter")
return
}
path := fmt.Sprintf("customers/%s/updateConfig", params.CustomerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, nil, opts...)
return
}
type Customer struct {
// the Metronome ID of the customer
ID string `json:"id,required" format:"uuid"`
// (deprecated, use ingest_aliases instead) the first ID (Metronome or ingest
// alias) that can be used in usage events
ExternalID string `json:"external_id,required"`
// aliases for this customer that can be used instead of the Metronome customer ID
// in usage events
IngestAliases []string `json:"ingest_aliases,required"`
Name string `json:"name,required"`
CustomFields map[string]string `json:"custom_fields"`
JSON customerJSON `json:"-"`
}
// customerJSON contains the JSON metadata for the struct [Customer]
type customerJSON struct {
ID apijson.Field
ExternalID apijson.Field
IngestAliases apijson.Field
Name apijson.Field
CustomFields apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *Customer) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerJSON) RawJSON() string {
return r.raw
}
type CustomerDetail struct {
// the Metronome ID of the customer
ID string `json:"id,required" format:"uuid"`
CustomFields map[string]string `json:"custom_fields,required"`
CustomerConfig CustomerDetailCustomerConfig `json:"customer_config,required"`
// (deprecated, use ingest_aliases instead) the first ID (Metronome or ingest
// alias) that can be used in usage events
ExternalID string `json:"external_id,required"`
// aliases for this customer that can be used instead of the Metronome customer ID
// in usage events
IngestAliases []string `json:"ingest_aliases,required"`
Name string `json:"name,required"`
// This field's availability is dependent on your client's configuration.
CurrentBillableStatus CustomerDetailCurrentBillableStatus `json:"current_billable_status"`
JSON customerDetailJSON `json:"-"`
}
// customerDetailJSON contains the JSON metadata for the struct [CustomerDetail]
type customerDetailJSON struct {
ID apijson.Field
CustomFields apijson.Field
CustomerConfig apijson.Field
ExternalID apijson.Field
IngestAliases apijson.Field
Name apijson.Field
CurrentBillableStatus apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerDetail) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerDetailJSON) RawJSON() string {
return r.raw
}
type CustomerDetailCustomerConfig struct {
// The Salesforce account ID for the customer
SalesforceAccountID string `json:"salesforce_account_id,required,nullable"`
JSON customerDetailCustomerConfigJSON `json:"-"`
}
// customerDetailCustomerConfigJSON contains the JSON metadata for the struct
// [CustomerDetailCustomerConfig]
type customerDetailCustomerConfigJSON struct {
SalesforceAccountID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerDetailCustomerConfig) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerDetailCustomerConfigJSON) RawJSON() string {
return r.raw
}
// This field's availability is dependent on your client's configuration.
type CustomerDetailCurrentBillableStatus struct {
Value CustomerDetailCurrentBillableStatusValue `json:"value,required"`
EffectiveAt time.Time `json:"effective_at,nullable" format:"date-time"`
JSON customerDetailCurrentBillableStatusJSON `json:"-"`
}
// customerDetailCurrentBillableStatusJSON contains the JSON metadata for the
// struct [CustomerDetailCurrentBillableStatus]
type customerDetailCurrentBillableStatusJSON struct {
Value apijson.Field
EffectiveAt apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerDetailCurrentBillableStatus) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerDetailCurrentBillableStatusJSON) RawJSON() string {
return r.raw
}
type CustomerDetailCurrentBillableStatusValue string
const (
CustomerDetailCurrentBillableStatusValueBillable CustomerDetailCurrentBillableStatusValue = "billable"
CustomerDetailCurrentBillableStatusValueUnbillable CustomerDetailCurrentBillableStatusValue = "unbillable"
)
func (r CustomerDetailCurrentBillableStatusValue) IsKnown() bool {
switch r {
case CustomerDetailCurrentBillableStatusValueBillable, CustomerDetailCurrentBillableStatusValueUnbillable:
return true
}
return false
}
type CustomerNewResponse struct {
Data Customer `json:"data,required"`
JSON customerNewResponseJSON `json:"-"`
}
// customerNewResponseJSON contains the JSON metadata for the struct
// [CustomerNewResponse]
type customerNewResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerNewResponseJSON) RawJSON() string {
return r.raw
}
type CustomerGetResponse struct {
Data CustomerDetail `json:"data,required"`
JSON customerGetResponseJSON `json:"-"`
}
// customerGetResponseJSON contains the JSON metadata for the struct
// [CustomerGetResponse]
type customerGetResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerGetResponseJSON) RawJSON() string {
return r.raw
}
type CustomerArchiveResponse struct {
Data shared.ID `json:"data,required"`
JSON customerArchiveResponseJSON `json:"-"`
}
// customerArchiveResponseJSON contains the JSON metadata for the struct
// [CustomerArchiveResponse]
type customerArchiveResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerArchiveResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerArchiveResponseJSON) RawJSON() string {
return r.raw
}
type CustomerListBillableMetricsResponse struct {
ID string `json:"id,required" format:"uuid"`
Name string `json:"name,required"`
// (DEPRECATED) use aggregation_type instead
Aggregate string `json:"aggregate"`
// (DEPRECATED) use aggregation_key instead
AggregateKeys []string `json:"aggregate_keys"`
// A key that specifies which property of the event is used to aggregate data. This
// key must be one of the property filter names and is not applicable when the
// aggregation type is 'count'.
AggregationKey string `json:"aggregation_key"`
// Specifies the type of aggregation performed on matching events.
AggregationType CustomerListBillableMetricsResponseAggregationType `json:"aggregation_type"`
// RFC 3339 timestamp indicating when the billable metric was archived. If not
// provided, the billable metric is not archived.
ArchivedAt time.Time `json:"archived_at" format:"date-time"`
CustomFields map[string]string `json:"custom_fields"`
// An optional filtering rule to match the 'event_type' property of an event.
EventTypeFilter shared.EventTypeFilter `json:"event_type_filter"`
// (DEPRECATED) use property_filters & event_type_filter instead
Filter map[string]interface{} `json:"filter"`
// (DEPRECATED) use group_keys instead
GroupBy []string `json:"group_by"`
// Property names that are used to group usage costs on an invoice. Each entry
// represents a set of properties used to slice events into distinct buckets.
GroupKeys [][]string `json:"group_keys"`
// A list of filters to match events to this billable metric. Each filter defines a
// rule on an event property. All rules must pass for the event to match the
// billable metric.
PropertyFilters []shared.PropertyFilter `json:"property_filters"`
// The SQL query associated with the billable metric
Sql string `json:"sql"`
JSON customerListBillableMetricsResponseJSON `json:"-"`
}
// customerListBillableMetricsResponseJSON contains the JSON metadata for the
// struct [CustomerListBillableMetricsResponse]
type customerListBillableMetricsResponseJSON struct {
ID apijson.Field
Name apijson.Field
Aggregate apijson.Field
AggregateKeys apijson.Field
AggregationKey apijson.Field
AggregationType apijson.Field
ArchivedAt apijson.Field
CustomFields apijson.Field
EventTypeFilter apijson.Field
Filter apijson.Field
GroupBy apijson.Field
GroupKeys apijson.Field
PropertyFilters apijson.Field
Sql apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerListBillableMetricsResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerListBillableMetricsResponseJSON) RawJSON() string {
return r.raw
}
// Specifies the type of aggregation performed on matching events.
type CustomerListBillableMetricsResponseAggregationType string
const (
CustomerListBillableMetricsResponseAggregationTypeCount CustomerListBillableMetricsResponseAggregationType = "COUNT"
CustomerListBillableMetricsResponseAggregationTypeLatest CustomerListBillableMetricsResponseAggregationType = "LATEST"
CustomerListBillableMetricsResponseAggregationTypeMax CustomerListBillableMetricsResponseAggregationType = "MAX"
CustomerListBillableMetricsResponseAggregationTypeSum CustomerListBillableMetricsResponseAggregationType = "SUM"
CustomerListBillableMetricsResponseAggregationTypeUnique CustomerListBillableMetricsResponseAggregationType = "UNIQUE"
)
func (r CustomerListBillableMetricsResponseAggregationType) IsKnown() bool {
switch r {
case CustomerListBillableMetricsResponseAggregationTypeCount, CustomerListBillableMetricsResponseAggregationTypeLatest, CustomerListBillableMetricsResponseAggregationTypeMax, CustomerListBillableMetricsResponseAggregationTypeSum, CustomerListBillableMetricsResponseAggregationTypeUnique:
return true
}
return false
}
type CustomerListCostsResponse struct {
CreditTypes map[string]CustomerListCostsResponseCreditType `json:"credit_types,required"`
EndTimestamp time.Time `json:"end_timestamp,required" format:"date-time"`
StartTimestamp time.Time `json:"start_timestamp,required" format:"date-time"`
JSON customerListCostsResponseJSON `json:"-"`
}
// customerListCostsResponseJSON contains the JSON metadata for the struct
// [CustomerListCostsResponse]
type customerListCostsResponseJSON struct {
CreditTypes apijson.Field
EndTimestamp apijson.Field
StartTimestamp apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerListCostsResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerListCostsResponseJSON) RawJSON() string {
return r.raw
}
type CustomerListCostsResponseCreditType struct {
Cost float64 `json:"cost"`
LineItemBreakdown []CustomerListCostsResponseCreditTypesLineItemBreakdown `json:"line_item_breakdown"`
Name string `json:"name"`
JSON customerListCostsResponseCreditTypeJSON `json:"-"`
}
// customerListCostsResponseCreditTypeJSON contains the JSON metadata for the
// struct [CustomerListCostsResponseCreditType]
type customerListCostsResponseCreditTypeJSON struct {
Cost apijson.Field
LineItemBreakdown apijson.Field
Name apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerListCostsResponseCreditType) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerListCostsResponseCreditTypeJSON) RawJSON() string {
return r.raw
}
type CustomerListCostsResponseCreditTypesLineItemBreakdown struct {
Cost float64 `json:"cost,required"`
Name string `json:"name,required"`
GroupKey string `json:"group_key"`
GroupValue string `json:"group_value,nullable"`
JSON customerListCostsResponseCreditTypesLineItemBreakdownJSON `json:"-"`
}
// customerListCostsResponseCreditTypesLineItemBreakdownJSON contains the JSON
// metadata for the struct [CustomerListCostsResponseCreditTypesLineItemBreakdown]
type customerListCostsResponseCreditTypesLineItemBreakdownJSON struct {
Cost apijson.Field
Name apijson.Field
GroupKey apijson.Field
GroupValue apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerListCostsResponseCreditTypesLineItemBreakdown) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerListCostsResponseCreditTypesLineItemBreakdownJSON) RawJSON() string {
return r.raw
}
type CustomerSetNameResponse struct {
Data Customer `json:"data,required"`
JSON customerSetNameResponseJSON `json:"-"`
}
// customerSetNameResponseJSON contains the JSON metadata for the struct
// [CustomerSetNameResponse]
type customerSetNameResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CustomerSetNameResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r customerSetNameResponseJSON) RawJSON() string {
return r.raw
}
type CustomerNewParams struct {
// This will be truncated to 160 characters if the provided name is longer.
Name param.Field[string] `json:"name,required"`
BillingConfig param.Field[CustomerNewParamsBillingConfig] `json:"billing_config"`
CustomFields param.Field[map[string]string] `json:"custom_fields"`
CustomerBillingProviderConfigurations param.Field[[]CustomerNewParamsCustomerBillingProviderConfiguration] `json:"customer_billing_provider_configurations"`
// (deprecated, use ingest_aliases instead) an alias that can be used to refer to
// this customer in usage events
ExternalID param.Field[string] `json:"external_id"`
// Aliases that can be used to refer to this customer in usage events
IngestAliases param.Field[[]string] `json:"ingest_aliases"`
}
func (r CustomerNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type CustomerNewParamsBillingConfig struct {
BillingProviderCustomerID param.Field[string] `json:"billing_provider_customer_id,required"`
BillingProviderType param.Field[CustomerNewParamsBillingConfigBillingProviderType] `json:"billing_provider_type,required"`
// True if the aws_product_code is a SAAS subscription product, false otherwise.
AwsIsSubscriptionProduct param.Field[bool] `json:"aws_is_subscription_product"`
AwsProductCode param.Field[string] `json:"aws_product_code"`
AwsRegion param.Field[CustomerNewParamsBillingConfigAwsRegion] `json:"aws_region"`
StripeCollectionMethod param.Field[CustomerNewParamsBillingConfigStripeCollectionMethod] `json:"stripe_collection_method"`
}
func (r CustomerNewParamsBillingConfig) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type CustomerNewParamsBillingConfigBillingProviderType string
const (
CustomerNewParamsBillingConfigBillingProviderTypeAwsMarketplace CustomerNewParamsBillingConfigBillingProviderType = "aws_marketplace"
CustomerNewParamsBillingConfigBillingProviderTypeStripe CustomerNewParamsBillingConfigBillingProviderType = "stripe"
CustomerNewParamsBillingConfigBillingProviderTypeNetsuite CustomerNewParamsBillingConfigBillingProviderType = "netsuite"
CustomerNewParamsBillingConfigBillingProviderTypeCustom CustomerNewParamsBillingConfigBillingProviderType = "custom"
CustomerNewParamsBillingConfigBillingProviderTypeAzureMarketplace CustomerNewParamsBillingConfigBillingProviderType = "azure_marketplace"
CustomerNewParamsBillingConfigBillingProviderTypeQuickbooksOnline CustomerNewParamsBillingConfigBillingProviderType = "quickbooks_online"
CustomerNewParamsBillingConfigBillingProviderTypeWorkday CustomerNewParamsBillingConfigBillingProviderType = "workday"
CustomerNewParamsBillingConfigBillingProviderTypeGcpMarketplace CustomerNewParamsBillingConfigBillingProviderType = "gcp_marketplace"
)
func (r CustomerNewParamsBillingConfigBillingProviderType) IsKnown() bool {
switch r {
case CustomerNewParamsBillingConfigBillingProviderTypeAwsMarketplace, CustomerNewParamsBillingConfigBillingProviderTypeStripe, CustomerNewParamsBillingConfigBillingProviderTypeNetsuite, CustomerNewParamsBillingConfigBillingProviderTypeCustom, CustomerNewParamsBillingConfigBillingProviderTypeAzureMarketplace, CustomerNewParamsBillingConfigBillingProviderTypeQuickbooksOnline, CustomerNewParamsBillingConfigBillingProviderTypeWorkday, CustomerNewParamsBillingConfigBillingProviderTypeGcpMarketplace:
return true
}
return false
}
type CustomerNewParamsBillingConfigAwsRegion string
const (
CustomerNewParamsBillingConfigAwsRegionAfSouth1 CustomerNewParamsBillingConfigAwsRegion = "af-south-1"
CustomerNewParamsBillingConfigAwsRegionApEast1 CustomerNewParamsBillingConfigAwsRegion = "ap-east-1"
CustomerNewParamsBillingConfigAwsRegionApNortheast1 CustomerNewParamsBillingConfigAwsRegion = "ap-northeast-1"
CustomerNewParamsBillingConfigAwsRegionApNortheast2 CustomerNewParamsBillingConfigAwsRegion = "ap-northeast-2"
CustomerNewParamsBillingConfigAwsRegionApNortheast3 CustomerNewParamsBillingConfigAwsRegion = "ap-northeast-3"
CustomerNewParamsBillingConfigAwsRegionApSouth1 CustomerNewParamsBillingConfigAwsRegion = "ap-south-1"
CustomerNewParamsBillingConfigAwsRegionApSoutheast1 CustomerNewParamsBillingConfigAwsRegion = "ap-southeast-1"
CustomerNewParamsBillingConfigAwsRegionApSoutheast2 CustomerNewParamsBillingConfigAwsRegion = "ap-southeast-2"
CustomerNewParamsBillingConfigAwsRegionCaCentral1 CustomerNewParamsBillingConfigAwsRegion = "ca-central-1"
CustomerNewParamsBillingConfigAwsRegionCnNorth1 CustomerNewParamsBillingConfigAwsRegion = "cn-north-1"
CustomerNewParamsBillingConfigAwsRegionCnNorthwest1 CustomerNewParamsBillingConfigAwsRegion = "cn-northwest-1"
CustomerNewParamsBillingConfigAwsRegionEuCentral1 CustomerNewParamsBillingConfigAwsRegion = "eu-central-1"
CustomerNewParamsBillingConfigAwsRegionEuNorth1 CustomerNewParamsBillingConfigAwsRegion = "eu-north-1"
CustomerNewParamsBillingConfigAwsRegionEuSouth1 CustomerNewParamsBillingConfigAwsRegion = "eu-south-1"
CustomerNewParamsBillingConfigAwsRegionEuWest1 CustomerNewParamsBillingConfigAwsRegion = "eu-west-1"
CustomerNewParamsBillingConfigAwsRegionEuWest2 CustomerNewParamsBillingConfigAwsRegion = "eu-west-2"
CustomerNewParamsBillingConfigAwsRegionEuWest3 CustomerNewParamsBillingConfigAwsRegion = "eu-west-3"
CustomerNewParamsBillingConfigAwsRegionMeSouth1 CustomerNewParamsBillingConfigAwsRegion = "me-south-1"
CustomerNewParamsBillingConfigAwsRegionSaEast1 CustomerNewParamsBillingConfigAwsRegion = "sa-east-1"
CustomerNewParamsBillingConfigAwsRegionUsEast1 CustomerNewParamsBillingConfigAwsRegion = "us-east-1"
CustomerNewParamsBillingConfigAwsRegionUsEast2 CustomerNewParamsBillingConfigAwsRegion = "us-east-2"
CustomerNewParamsBillingConfigAwsRegionUsGovEast1 CustomerNewParamsBillingConfigAwsRegion = "us-gov-east-1"
CustomerNewParamsBillingConfigAwsRegionUsGovWest1 CustomerNewParamsBillingConfigAwsRegion = "us-gov-west-1"
CustomerNewParamsBillingConfigAwsRegionUsWest1 CustomerNewParamsBillingConfigAwsRegion = "us-west-1"
CustomerNewParamsBillingConfigAwsRegionUsWest2 CustomerNewParamsBillingConfigAwsRegion = "us-west-2"
)
func (r CustomerNewParamsBillingConfigAwsRegion) IsKnown() bool {
switch r {
case CustomerNewParamsBillingConfigAwsRegionAfSouth1, CustomerNewParamsBillingConfigAwsRegionApEast1, CustomerNewParamsBillingConfigAwsRegionApNortheast1, CustomerNewParamsBillingConfigAwsRegionApNortheast2, CustomerNewParamsBillingConfigAwsRegionApNortheast3, CustomerNewParamsBillingConfigAwsRegionApSouth1, CustomerNewParamsBillingConfigAwsRegionApSoutheast1, CustomerNewParamsBillingConfigAwsRegionApSoutheast2, CustomerNewParamsBillingConfigAwsRegionCaCentral1, CustomerNewParamsBillingConfigAwsRegionCnNorth1, CustomerNewParamsBillingConfigAwsRegionCnNorthwest1, CustomerNewParamsBillingConfigAwsRegionEuCentral1, CustomerNewParamsBillingConfigAwsRegionEuNorth1, CustomerNewParamsBillingConfigAwsRegionEuSouth1, CustomerNewParamsBillingConfigAwsRegionEuWest1, CustomerNewParamsBillingConfigAwsRegionEuWest2, CustomerNewParamsBillingConfigAwsRegionEuWest3, CustomerNewParamsBillingConfigAwsRegionMeSouth1, CustomerNewParamsBillingConfigAwsRegionSaEast1, CustomerNewParamsBillingConfigAwsRegionUsEast1, CustomerNewParamsBillingConfigAwsRegionUsEast2, CustomerNewParamsBillingConfigAwsRegionUsGovEast1, CustomerNewParamsBillingConfigAwsRegionUsGovWest1, CustomerNewParamsBillingConfigAwsRegionUsWest1, CustomerNewParamsBillingConfigAwsRegionUsWest2:
return true
}
return false
}
type CustomerNewParamsBillingConfigStripeCollectionMethod string
const (
CustomerNewParamsBillingConfigStripeCollectionMethodChargeAutomatically CustomerNewParamsBillingConfigStripeCollectionMethod = "charge_automatically"
CustomerNewParamsBillingConfigStripeCollectionMethodSendInvoice CustomerNewParamsBillingConfigStripeCollectionMethod = "send_invoice"
)
func (r CustomerNewParamsBillingConfigStripeCollectionMethod) IsKnown() bool {
switch r {
case CustomerNewParamsBillingConfigStripeCollectionMethodChargeAutomatically, CustomerNewParamsBillingConfigStripeCollectionMethodSendInvoice:
return true
}
return false
}
type CustomerNewParamsCustomerBillingProviderConfiguration struct {
// The billing provider set for this configuration.
BillingProvider param.Field[CustomerNewParamsCustomerBillingProviderConfigurationsBillingProvider] `json:"billing_provider,required"`
// Configuration for the billing provider. The structure of this object is specific
// to the billing provider and delivery provider combination. Defaults to an empty
// object, however, for most billing provider + delivery method combinations, it
// will not be a valid configuration.
Configuration param.Field[map[string]interface{}] `json:"configuration"`
// The method to use for delivering invoices to this customer. If not provided, the
// `delivery_method_id` must be provided.
DeliveryMethod param.Field[CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethod] `json:"delivery_method"`
// ID of the delivery method to use for this customer. If not provided, the
// `delivery_method` must be provided.
DeliveryMethodID param.Field[string] `json:"delivery_method_id" format:"uuid"`
}
func (r CustomerNewParamsCustomerBillingProviderConfiguration) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The billing provider set for this configuration.
type CustomerNewParamsCustomerBillingProviderConfigurationsBillingProvider string
const (
CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderAwsMarketplace CustomerNewParamsCustomerBillingProviderConfigurationsBillingProvider = "aws_marketplace"
CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderAzureMarketplace CustomerNewParamsCustomerBillingProviderConfigurationsBillingProvider = "azure_marketplace"
CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderGcpMarketplace CustomerNewParamsCustomerBillingProviderConfigurationsBillingProvider = "gcp_marketplace"
CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderStripe CustomerNewParamsCustomerBillingProviderConfigurationsBillingProvider = "stripe"
CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderNetsuite CustomerNewParamsCustomerBillingProviderConfigurationsBillingProvider = "netsuite"
)
func (r CustomerNewParamsCustomerBillingProviderConfigurationsBillingProvider) IsKnown() bool {
switch r {
case CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderAwsMarketplace, CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderAzureMarketplace, CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderGcpMarketplace, CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderStripe, CustomerNewParamsCustomerBillingProviderConfigurationsBillingProviderNetsuite:
return true
}
return false
}
// The method to use for delivering invoices to this customer. If not provided, the
// `delivery_method_id` must be provided.
type CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethod string
const (
CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethodDirectToBillingProvider CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethod = "direct_to_billing_provider"
CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethodAwsSqs CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethod = "aws_sqs"
CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethodTackle CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethod = "tackle"
CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethodAwsSns CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethod = "aws_sns"
)
func (r CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethod) IsKnown() bool {
switch r {
case CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethodDirectToBillingProvider, CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethodAwsSqs, CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethodTackle, CustomerNewParamsCustomerBillingProviderConfigurationsDeliveryMethodAwsSns:
return true
}
return false
}
type CustomerGetParams struct {
CustomerID param.Field[string] `path:"customer_id,required" format:"uuid"`
}
type CustomerListParams struct {
// Filter the customer list by customer_id. Up to 100 ids can be provided.
CustomerIDs param.Field[[]string] `query:"customer_ids"`
// Filter the customer list by ingest_alias
IngestAlias param.Field[string] `query:"ingest_alias"`
// 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 the customer list by only archived customers.
OnlyArchived param.Field[bool] `query:"only_archived"`
// Filter the customer list by salesforce_account_id. Up to 100 ids can be
// provided.
SalesforceAccountIDs param.Field[[]string] `query:"salesforce_account_ids"`
}
// URLQuery serializes [CustomerListParams]'s query parameters as `url.Values`.
func (r CustomerListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type CustomerArchiveParams struct {
ID shared.IDParam `json:"id,required"`
}
func (r CustomerArchiveParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r.ID)
}
type CustomerListBillableMetricsParams struct {
CustomerID param.Field[string] `path:"customer_id,required" format:"uuid"`
// If true, the list of returned metrics will include archived metrics
IncludeArchived param.Field[bool] `query:"include_archived"`
// 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"`
// If true, the list of metrics will be filtered to just ones that are on the
// customer's current plan
OnCurrentPlan param.Field[bool] `query:"on_current_plan"`
}
// URLQuery serializes [CustomerListBillableMetricsParams]'s query parameters as
// `url.Values`.
func (r CustomerListBillableMetricsParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type CustomerListCostsParams struct {
CustomerID param.Field[string] `path:"customer_id,required" format:"uuid"`
// RFC 3339 timestamp (exclusive)
EndingBefore param.Field[time.Time] `query:"ending_before,required" format:"date-time"`
// RFC 3339 timestamp (inclusive)
StartingOn param.Field[time.Time] `query:"starting_on,required" format:"date-time"`
// 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"`
}
// URLQuery serializes [CustomerListCostsParams]'s query parameters as
// `url.Values`.
func (r CustomerListCostsParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type CustomerSetIngestAliasesParams struct {
CustomerID param.Field[string] `path:"customer_id,required" format:"uuid"`
IngestAliases param.Field[[]string] `json:"ingest_aliases,required"`
}
func (r CustomerSetIngestAliasesParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type CustomerSetNameParams struct {
CustomerID param.Field[string] `path:"customer_id,required" format:"uuid"`
// The new name for the customer. This will be truncated to 160 characters if the
// provided name is longer.
Name param.Field[string] `json:"name,required"`
}
func (r CustomerSetNameParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type CustomerUpdateConfigParams struct {
CustomerID param.Field[string] `path:"customer_id,required" format:"uuid"`
// Leave in draft or set to auto-advance on invoices sent to Stripe. Falls back to
// the client-level config if unset, which defaults to true if unset.
LeaveStripeInvoicesInDraft param.Field[bool] `json:"leave_stripe_invoices_in_draft"`
// The Salesforce account ID for the customer
SalesforceAccountID param.Field[string] `json:"salesforce_account_id"`
}
func (r CustomerUpdateConfigParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}