0
Post reporting report runs
One script reply has been approved by the moderators Verified

Creates a new object and begin running the report. (Certain report types require a live-mode API key.)

Created by hugo697 450 days ago Viewed 12020 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 450 days ago
1
type Stripe = {
2
  token: string;
3
};
4
/**
5
 * Post reporting report runs
6
 * Creates a new object and begin running the report. (Certain report types require a live-mode API key.)
7
 */
8
export async function main(
9
  auth: Stripe,
10
  body: {
11
    expand?: string[];
12
    parameters?: {
13
      columns?: string[];
14
      connected_account?: string;
15
      currency?: string;
16
      interval_end?: number;
17
      interval_start?: number;
18
      payout?: string;
19
      reporting_category?:
20
        | "advance"
21
        | "advance_funding"
22
        | "anticipation_repayment"
23
        | "charge"
24
        | "charge_failure"
25
        | "climate_order_purchase"
26
        | "climate_order_refund"
27
        | "connect_collection_transfer"
28
        | "connect_reserved_funds"
29
        | "contribution"
30
        | "dispute"
31
        | "dispute_reversal"
32
        | "fee"
33
        | "financing_paydown"
34
        | "financing_paydown_reversal"
35
        | "financing_payout"
36
        | "financing_payout_reversal"
37
        | "issuing_authorization_hold"
38
        | "issuing_authorization_release"
39
        | "issuing_dispute"
40
        | "issuing_transaction"
41
        | "network_cost"
42
        | "other_adjustment"
43
        | "partial_capture_reversal"
44
        | "payout"
45
        | "payout_reversal"
46
        | "platform_earning"
47
        | "platform_earning_refund"
48
        | "refund"
49
        | "refund_failure"
50
        | "risk_reserved_funds"
51
        | "tax"
52
        | "topup"
53
        | "topup_reversal"
54
        | "transfer"
55
        | "transfer_reversal"
56
        | "unreconciled_customer_funds";
57
      timezone?:
58
        | "Africa/Abidjan"
59
        | "Africa/Accra"
60
        | "Africa/Addis_Ababa"
61
        | "Africa/Algiers"
62
        | "Africa/Asmara"
63
        | "Africa/Asmera"
64
        | "Africa/Bamako"
65
        | "Africa/Bangui"
66
        | "Africa/Banjul"
67
        | "Africa/Bissau"
68
        | "Africa/Blantyre"
69
        | "Africa/Brazzaville"
70
        | "Africa/Bujumbura"
71
        | "Africa/Cairo"
72
        | "Africa/Casablanca"
73
        | "Africa/Ceuta"
74
        | "Africa/Conakry"
75
        | "Africa/Dakar"
76
        | "Africa/Dar_es_Salaam"
77
        | "Africa/Djibouti"
78
        | "Africa/Douala"
79
        | "Africa/El_Aaiun"
80
        | "Africa/Freetown"
81
        | "Africa/Gaborone"
82
        | "Africa/Harare"
83
        | "Africa/Johannesburg"
84
        | "Africa/Juba"
85
        | "Africa/Kampala"
86
        | "Africa/Khartoum"
87
        | "Africa/Kigali"
88
        | "Africa/Kinshasa"
89
        | "Africa/Lagos"
90
        | "Africa/Libreville"
91
        | "Africa/Lome"
92
        | "Africa/Luanda"
93
        | "Africa/Lubumbashi"
94
        | "Africa/Lusaka"
95
        | "Africa/Malabo"
96
        | "Africa/Maputo"
97
        | "Africa/Maseru"
98
        | "Africa/Mbabane"
99
        | "Africa/Mogadishu"
100
        | "Africa/Monrovia"
101
        | "Africa/Nairobi"
102
        | "Africa/Ndjamena"
103
        | "Africa/Niamey"
104
        | "Africa/Nouakchott"
105
        | "Africa/Ouagadougou"
106
        | "Africa/Porto-Novo"
107
        | "Africa/Sao_Tome"
108
        | "Africa/Timbuktu"
109
        | "Africa/Tripoli"
110
        | "Africa/Tunis"
111
        | "Africa/Windhoek"
112
        | "America/Adak"
113
        | "America/Anchorage"
114
        | "America/Anguilla"
115
        | "America/Antigua"
116
        | "America/Araguaina"
117
        | "America/Argentina/Buenos_Aires"
118
        | "America/Argentina/Catamarca"
119
        | "America/Argentina/ComodRivadavia"
120
        | "America/Argentina/Cordoba"
121
        | "America/Argentina/Jujuy"
122
        | "America/Argentina/La_Rioja"
123
        | "America/Argentina/Mendoza"
124
        | "America/Argentina/Rio_Gallegos"
125
        | "America/Argentina/Salta"
126
        | "America/Argentina/San_Juan"
127
        | "America/Argentina/San_Luis"
128
        | "America/Argentina/Tucuman"
129
        | "America/Argentina/Ushuaia"
130
        | "America/Aruba"
131
        | "America/Asuncion"
132
        | "America/Atikokan"
133
        | "America/Atka"
134
        | "America/Bahia"
135
        | "America/Bahia_Banderas"
136
        | "America/Barbados"
137
        | "America/Belem"
138
        | "America/Belize"
139
        | "America/Blanc-Sablon"
140
        | "America/Boa_Vista"
141
        | "America/Bogota"
142
        | "America/Boise"
143
        | "America/Buenos_Aires"
144
        | "America/Cambridge_Bay"
145
        | "America/Campo_Grande"
146
        | "America/Cancun"
147
        | "America/Caracas"
148
        | "America/Catamarca"
149
        | "America/Cayenne"
150
        | "America/Cayman"
151
        | "America/Chicago"
152
        | "America/Chihuahua"
153
        | "America/Ciudad_Juarez"
154
        | "America/Coral_Harbour"
155
        | "America/Cordoba"
156
        | "America/Costa_Rica"
157
        | "America/Creston"
158
        | "America/Cuiaba"
159
        | "America/Curacao"
160
        | "America/Danmarkshavn"
161
        | "America/Dawson"
162
        | "America/Dawson_Creek"
163
        | "America/Denver"
164
        | "America/Detroit"
165
        | "America/Dominica"
166
        | "America/Edmonton"
167
        | "America/Eirunepe"
168
        | "America/El_Salvador"
169
        | "America/Ensenada"
170
        | "America/Fort_Nelson"
171
        | "America/Fort_Wayne"
172
        | "America/Fortaleza"
173
        | "America/Glace_Bay"
174
        | "America/Godthab"
175
        | "America/Goose_Bay"
176
        | "America/Grand_Turk"
177
        | "America/Grenada"
178
        | "America/Guadeloupe"
179
        | "America/Guatemala"
180
        | "America/Guayaquil"
181
        | "America/Guyana"
182
        | "America/Halifax"
183
        | "America/Havana"
184
        | "America/Hermosillo"
185
        | "America/Indiana/Indianapolis"
186
        | "America/Indiana/Knox"
187
        | "America/Indiana/Marengo"
188
        | "America/Indiana/Petersburg"
189
        | "America/Indiana/Tell_City"
190
        | "America/Indiana/Vevay"
191
        | "America/Indiana/Vincennes"
192
        | "America/Indiana/Winamac"
193
        | "America/Indianapolis"
194
        | "America/Inuvik"
195
        | "America/Iqaluit"
196
        | "America/Jamaica"
197
        | "America/Jujuy"
198
        | "America/Juneau"
199
        | "America/Kentucky/Louisville"
200
        | "America/Kentucky/Monticello"
201
        | "America/Knox_IN"
202
        | "America/Kralendijk"
203
        | "America/La_Paz"
204
        | "America/Lima"
205
        | "America/Los_Angeles"
206
        | "America/Louisville"
207
        | "America/Lower_Princes"
208
        | "America/Maceio"
209
        | "America/Managua"
210
        | "America/Manaus"
211
        | "America/Marigot"
212
        | "America/Martinique"
213
        | "America/Matamoros"
214
        | "America/Mazatlan"
215
        | "America/Mendoza"
216
        | "America/Menominee"
217
        | "America/Merida"
218
        | "America/Metlakatla"
219
        | "America/Mexico_City"
220
        | "America/Miquelon"
221
        | "America/Moncton"
222
        | "America/Monterrey"
223
        | "America/Montevideo"
224
        | "America/Montreal"
225
        | "America/Montserrat"
226
        | "America/Nassau"
227
        | "America/New_York"
228
        | "America/Nipigon"
229
        | "America/Nome"
230
        | "America/Noronha"
231
        | "America/North_Dakota/Beulah"
232
        | "America/North_Dakota/Center"
233
        | "America/North_Dakota/New_Salem"
234
        | "America/Nuuk"
235
        | "America/Ojinaga"
236
        | "America/Panama"
237
        | "America/Pangnirtung"
238
        | "America/Paramaribo"
239
        | "America/Phoenix"
240
        | "America/Port-au-Prince"
241
        | "America/Port_of_Spain"
242
        | "America/Porto_Acre"
243
        | "America/Porto_Velho"
244
        | "America/Puerto_Rico"
245
        | "America/Punta_Arenas"
246
        | "America/Rainy_River"
247
        | "America/Rankin_Inlet"
248
        | "America/Recife"
249
        | "America/Regina"
250
        | "America/Resolute"
251
        | "America/Rio_Branco"
252
        | "America/Rosario"
253
        | "America/Santa_Isabel"
254
        | "America/Santarem"
255
        | "America/Santiago"
256
        | "America/Santo_Domingo"
257
        | "America/Sao_Paulo"
258
        | "America/Scoresbysund"
259
        | "America/Shiprock"
260
        | "America/Sitka"
261
        | "America/St_Barthelemy"
262
        | "America/St_Johns"
263
        | "America/St_Kitts"
264
        | "America/St_Lucia"
265
        | "America/St_Thomas"
266
        | "America/St_Vincent"
267
        | "America/Swift_Current"
268
        | "America/Tegucigalpa"
269
        | "America/Thule"
270
        | "America/Thunder_Bay"
271
        | "America/Tijuana"
272
        | "America/Toronto"
273
        | "America/Tortola"
274
        | "America/Vancouver"
275
        | "America/Virgin"
276
        | "America/Whitehorse"
277
        | "America/Winnipeg"
278
        | "America/Yakutat"
279
        | "America/Yellowknife"
280
        | "Antarctica/Casey"
281
        | "Antarctica/Davis"
282
        | "Antarctica/DumontDUrville"
283
        | "Antarctica/Macquarie"
284
        | "Antarctica/Mawson"
285
        | "Antarctica/McMurdo"
286
        | "Antarctica/Palmer"
287
        | "Antarctica/Rothera"
288
        | "Antarctica/South_Pole"
289
        | "Antarctica/Syowa"
290
        | "Antarctica/Troll"
291
        | "Antarctica/Vostok"
292
        | "Arctic/Longyearbyen"
293
        | "Asia/Aden"
294
        | "Asia/Almaty"
295
        | "Asia/Amman"
296
        | "Asia/Anadyr"
297
        | "Asia/Aqtau"
298
        | "Asia/Aqtobe"
299
        | "Asia/Ashgabat"
300
        | "Asia/Ashkhabad"
301
        | "Asia/Atyrau"
302
        | "Asia/Baghdad"
303
        | "Asia/Bahrain"
304
        | "Asia/Baku"
305
        | "Asia/Bangkok"
306
        | "Asia/Barnaul"
307
        | "Asia/Beirut"
308
        | "Asia/Bishkek"
309
        | "Asia/Brunei"
310
        | "Asia/Calcutta"
311
        | "Asia/Chita"
312
        | "Asia/Choibalsan"
313
        | "Asia/Chongqing"
314
        | "Asia/Chungking"
315
        | "Asia/Colombo"
316
        | "Asia/Dacca"
317
        | "Asia/Damascus"
318
        | "Asia/Dhaka"
319
        | "Asia/Dili"
320
        | "Asia/Dubai"
321
        | "Asia/Dushanbe"
322
        | "Asia/Famagusta"
323
        | "Asia/Gaza"
324
        | "Asia/Harbin"
325
        | "Asia/Hebron"
326
        | "Asia/Ho_Chi_Minh"
327
        | "Asia/Hong_Kong"
328
        | "Asia/Hovd"
329
        | "Asia/Irkutsk"
330
        | "Asia/Istanbul"
331
        | "Asia/Jakarta"
332
        | "Asia/Jayapura"
333
        | "Asia/Jerusalem"
334
        | "Asia/Kabul"
335
        | "Asia/Kamchatka"
336
        | "Asia/Karachi"
337
        | "Asia/Kashgar"
338
        | "Asia/Kathmandu"
339
        | "Asia/Katmandu"
340
        | "Asia/Khandyga"
341
        | "Asia/Kolkata"
342
        | "Asia/Krasnoyarsk"
343
        | "Asia/Kuala_Lumpur"
344
        | "Asia/Kuching"
345
        | "Asia/Kuwait"
346
        | "Asia/Macao"
347
        | "Asia/Macau"
348
        | "Asia/Magadan"
349
        | "Asia/Makassar"
350
        | "Asia/Manila"
351
        | "Asia/Muscat"
352
        | "Asia/Nicosia"
353
        | "Asia/Novokuznetsk"
354
        | "Asia/Novosibirsk"
355
        | "Asia/Omsk"
356
        | "Asia/Oral"
357
        | "Asia/Phnom_Penh"
358
        | "Asia/Pontianak"
359
        | "Asia/Pyongyang"
360
        | "Asia/Qatar"
361
        | "Asia/Qostanay"
362
        | "Asia/Qyzylorda"
363
        | "Asia/Rangoon"
364
        | "Asia/Riyadh"
365
        | "Asia/Saigon"
366
        | "Asia/Sakhalin"
367
        | "Asia/Samarkand"
368
        | "Asia/Seoul"
369
        | "Asia/Shanghai"
370
        | "Asia/Singapore"
371
        | "Asia/Srednekolymsk"
372
        | "Asia/Taipei"
373
        | "Asia/Tashkent"
374
        | "Asia/Tbilisi"
375
        | "Asia/Tehran"
376
        | "Asia/Tel_Aviv"
377
        | "Asia/Thimbu"
378
        | "Asia/Thimphu"
379
        | "Asia/Tokyo"
380
        | "Asia/Tomsk"
381
        | "Asia/Ujung_Pandang"
382
        | "Asia/Ulaanbaatar"
383
        | "Asia/Ulan_Bator"
384
        | "Asia/Urumqi"
385
        | "Asia/Ust-Nera"
386
        | "Asia/Vientiane"
387
        | "Asia/Vladivostok"
388
        | "Asia/Yakutsk"
389
        | "Asia/Yangon"
390
        | "Asia/Yekaterinburg"
391
        | "Asia/Yerevan"
392
        | "Atlantic/Azores"
393
        | "Atlantic/Bermuda"
394
        | "Atlantic/Canary"
395
        | "Atlantic/Cape_Verde"
396
        | "Atlantic/Faeroe"
397
        | "Atlantic/Faroe"
398
        | "Atlantic/Jan_Mayen"
399
        | "Atlantic/Madeira"
400
        | "Atlantic/Reykjavik"
401
        | "Atlantic/South_Georgia"
402
        | "Atlantic/St_Helena"
403
        | "Atlantic/Stanley"
404
        | "Australia/ACT"
405
        | "Australia/Adelaide"
406
        | "Australia/Brisbane"
407
        | "Australia/Broken_Hill"
408
        | "Australia/Canberra"
409
        | "Australia/Currie"
410
        | "Australia/Darwin"
411
        | "Australia/Eucla"
412
        | "Australia/Hobart"
413
        | "Australia/LHI"
414
        | "Australia/Lindeman"
415
        | "Australia/Lord_Howe"
416
        | "Australia/Melbourne"
417
        | "Australia/NSW"
418
        | "Australia/North"
419
        | "Australia/Perth"
420
        | "Australia/Queensland"
421
        | "Australia/South"
422
        | "Australia/Sydney"
423
        | "Australia/Tasmania"
424
        | "Australia/Victoria"
425
        | "Australia/West"
426
        | "Australia/Yancowinna"
427
        | "Brazil/Acre"
428
        | "Brazil/DeNoronha"
429
        | "Brazil/East"
430
        | "Brazil/West"
431
        | "CET"
432
        | "CST6CDT"
433
        | "Canada/Atlantic"
434
        | "Canada/Central"
435
        | "Canada/Eastern"
436
        | "Canada/Mountain"
437
        | "Canada/Newfoundland"
438
        | "Canada/Pacific"
439
        | "Canada/Saskatchewan"
440
        | "Canada/Yukon"
441
        | "Chile/Continental"
442
        | "Chile/EasterIsland"
443
        | "Cuba"
444
        | "EET"
445
        | "EST"
446
        | "EST5EDT"
447
        | "Egypt"
448
        | "Eire"
449
        | "Etc/GMT"
450
        | "Etc/GMT+0"
451
        | "Etc/GMT+1"
452
        | "Etc/GMT+10"
453
        | "Etc/GMT+11"
454
        | "Etc/GMT+12"
455
        | "Etc/GMT+2"
456
        | "Etc/GMT+3"
457
        | "Etc/GMT+4"
458
        | "Etc/GMT+5"
459
        | "Etc/GMT+6"
460
        | "Etc/GMT+7"
461
        | "Etc/GMT+8"
462
        | "Etc/GMT+9"
463
        | "Etc/GMT-0"
464
        | "Etc/GMT-1"
465
        | "Etc/GMT-10"
466
        | "Etc/GMT-11"
467
        | "Etc/GMT-12"
468
        | "Etc/GMT-13"
469
        | "Etc/GMT-14"
470
        | "Etc/GMT-2"
471
        | "Etc/GMT-3"
472
        | "Etc/GMT-4"
473
        | "Etc/GMT-5"
474
        | "Etc/GMT-6"
475
        | "Etc/GMT-7"
476
        | "Etc/GMT-8"
477
        | "Etc/GMT-9"
478
        | "Etc/GMT0"
479
        | "Etc/Greenwich"
480
        | "Etc/UCT"
481
        | "Etc/UTC"
482
        | "Etc/Universal"
483
        | "Etc/Zulu"
484
        | "Europe/Amsterdam"
485
        | "Europe/Andorra"
486
        | "Europe/Astrakhan"
487
        | "Europe/Athens"
488
        | "Europe/Belfast"
489
        | "Europe/Belgrade"
490
        | "Europe/Berlin"
491
        | "Europe/Bratislava"
492
        | "Europe/Brussels"
493
        | "Europe/Bucharest"
494
        | "Europe/Budapest"
495
        | "Europe/Busingen"
496
        | "Europe/Chisinau"
497
        | "Europe/Copenhagen"
498
        | "Europe/Dublin"
499
        | "Europe/Gibraltar"
500
        | "Europe/Guernsey"
501
        | "Europe/Helsinki"
502
        | "Europe/Isle_of_Man"
503
        | "Europe/Istanbul"
504
        | "Europe/Jersey"
505
        | "Europe/Kaliningrad"
506
        | "Europe/Kiev"
507
        | "Europe/Kirov"
508
        | "Europe/Kyiv"
509
        | "Europe/Lisbon"
510
        | "Europe/Ljubljana"
511
        | "Europe/London"
512
        | "Europe/Luxembourg"
513
        | "Europe/Madrid"
514
        | "Europe/Malta"
515
        | "Europe/Mariehamn"
516
        | "Europe/Minsk"
517
        | "Europe/Monaco"
518
        | "Europe/Moscow"
519
        | "Europe/Nicosia"
520
        | "Europe/Oslo"
521
        | "Europe/Paris"
522
        | "Europe/Podgorica"
523
        | "Europe/Prague"
524
        | "Europe/Riga"
525
        | "Europe/Rome"
526
        | "Europe/Samara"
527
        | "Europe/San_Marino"
528
        | "Europe/Sarajevo"
529
        | "Europe/Saratov"
530
        | "Europe/Simferopol"
531
        | "Europe/Skopje"
532
        | "Europe/Sofia"
533
        | "Europe/Stockholm"
534
        | "Europe/Tallinn"
535
        | "Europe/Tirane"
536
        | "Europe/Tiraspol"
537
        | "Europe/Ulyanovsk"
538
        | "Europe/Uzhgorod"
539
        | "Europe/Vaduz"
540
        | "Europe/Vatican"
541
        | "Europe/Vienna"
542
        | "Europe/Vilnius"
543
        | "Europe/Volgograd"
544
        | "Europe/Warsaw"
545
        | "Europe/Zagreb"
546
        | "Europe/Zaporozhye"
547
        | "Europe/Zurich"
548
        | "Factory"
549
        | "GB"
550
        | "GB-Eire"
551
        | "GMT"
552
        | "GMT+0"
553
        | "GMT-0"
554
        | "GMT0"
555
        | "Greenwich"
556
        | "HST"
557
        | "Hongkong"
558
        | "Iceland"
559
        | "Indian/Antananarivo"
560
        | "Indian/Chagos"
561
        | "Indian/Christmas"
562
        | "Indian/Cocos"
563
        | "Indian/Comoro"
564
        | "Indian/Kerguelen"
565
        | "Indian/Mahe"
566
        | "Indian/Maldives"
567
        | "Indian/Mauritius"
568
        | "Indian/Mayotte"
569
        | "Indian/Reunion"
570
        | "Iran"
571
        | "Israel"
572
        | "Jamaica"
573
        | "Japan"
574
        | "Kwajalein"
575
        | "Libya"
576
        | "MET"
577
        | "MST"
578
        | "MST7MDT"
579
        | "Mexico/BajaNorte"
580
        | "Mexico/BajaSur"
581
        | "Mexico/General"
582
        | "NZ"
583
        | "NZ-CHAT"
584
        | "Navajo"
585
        | "PRC"
586
        | "PST8PDT"
587
        | "Pacific/Apia"
588
        | "Pacific/Auckland"
589
        | "Pacific/Bougainville"
590
        | "Pacific/Chatham"
591
        | "Pacific/Chuuk"
592
        | "Pacific/Easter"
593
        | "Pacific/Efate"
594
        | "Pacific/Enderbury"
595
        | "Pacific/Fakaofo"
596
        | "Pacific/Fiji"
597
        | "Pacific/Funafuti"
598
        | "Pacific/Galapagos"
599
        | "Pacific/Gambier"
600
        | "Pacific/Guadalcanal"
601
        | "Pacific/Guam"
602
        | "Pacific/Honolulu"
603
        | "Pacific/Johnston"
604
        | "Pacific/Kanton"
605
        | "Pacific/Kiritimati"
606
        | "Pacific/Kosrae"
607
        | "Pacific/Kwajalein"
608
        | "Pacific/Majuro"
609
        | "Pacific/Marquesas"
610
        | "Pacific/Midway"
611
        | "Pacific/Nauru"
612
        | "Pacific/Niue"
613
        | "Pacific/Norfolk"
614
        | "Pacific/Noumea"
615
        | "Pacific/Pago_Pago"
616
        | "Pacific/Palau"
617
        | "Pacific/Pitcairn"
618
        | "Pacific/Pohnpei"
619
        | "Pacific/Ponape"
620
        | "Pacific/Port_Moresby"
621
        | "Pacific/Rarotonga"
622
        | "Pacific/Saipan"
623
        | "Pacific/Samoa"
624
        | "Pacific/Tahiti"
625
        | "Pacific/Tarawa"
626
        | "Pacific/Tongatapu"
627
        | "Pacific/Truk"
628
        | "Pacific/Wake"
629
        | "Pacific/Wallis"
630
        | "Pacific/Yap"
631
        | "Poland"
632
        | "Portugal"
633
        | "ROC"
634
        | "ROK"
635
        | "Singapore"
636
        | "Turkey"
637
        | "UCT"
638
        | "US/Alaska"
639
        | "US/Aleutian"
640
        | "US/Arizona"
641
        | "US/Central"
642
        | "US/East-Indiana"
643
        | "US/Eastern"
644
        | "US/Hawaii"
645
        | "US/Indiana-Starke"
646
        | "US/Michigan"
647
        | "US/Mountain"
648
        | "US/Pacific"
649
        | "US/Pacific-New"
650
        | "US/Samoa"
651
        | "UTC"
652
        | "Universal"
653
        | "W-SU"
654
        | "WET"
655
        | "Zulu";
656
      [k: string]: unknown;
657
    };
658
    report_type: string;
659
  }
660
) {
661
  const url = new URL(`https://api.stripe.com/v1/reporting/report_runs`);
662

663
  const response = await fetch(url, {
664
    method: "POST",
665
    headers: {
666
      "Content-Type": "application/x-www-form-urlencoded",
667
      Authorization: "Bearer " + auth.token,
668
    },
669
    body: encodeParams(body),
670
  });
671
  if (!response.ok) {
672
    const text = await response.text();
673
    throw new Error(`${response.status} ${text}`);
674
  }
675
  return await response.json();
676
}
677

678
function encodeParams(o: any) {
679
  function iter(o: any, path: string) {
680
    if (Array.isArray(o)) {
681
      o.forEach(function (a) {
682
        iter(a, path + "[]");
683
      });
684
      return;
685
    }
686
    if (o !== null && typeof o === "object") {
687
      Object.keys(o).forEach(function (k) {
688
        iter(o[k], path + "[" + k + "]");
689
      });
690
      return;
691
    }
692
    data.push(path + "=" + o);
693
  }
694
  const data: string[] = [];
695
  Object.keys(o).forEach(function (k) {
696
    if (o[k] !== undefined) {
697
      iter(o[k], k);
698
    }
699
  });
700
  return new URLSearchParams(data.join("&"));
701
}
702