geniebox-shared-lib 2.1.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2088 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.7.7
5
+ // protoc v5.28.2
6
+ // source: billing.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.BillingServiceService = exports.BILLING_SERVICE_NAME = exports.ProcessWebhookResponse = exports.GetPaymentsByUserResponse = exports.GetPaymentResponse = exports.CreatePaymentResponse = exports.ProcessWebhookRequest = exports.GetPaymentsByUserRequest = exports.GetPaymentRequest = exports.CreatePaymentRequest = exports.GetUsageByUserResponse = exports.GetUsageByKeyResponse = exports.GetUsageStatsResponse = exports.RecordUsageResponse = exports.GetUsageByUserRequest = exports.GetUsageByKeyRequest = exports.GetUsageStatsRequest = exports.RecordUsageRequest = exports.GetTransactionResponse = exports.GetTransactionsResponse = exports.CreateTransactionResponse = exports.GetTransactionRequest = exports.GetTransactionsRequest = exports.CreateTransactionRequest = exports.DepositResponse = exports.ChargeResponse = exports.GetBalanceResponse = exports.DepositRequest = exports.ChargeRequest = exports.GetBalanceRequest = exports.UsageStats = exports.Payment = exports.Usage = exports.Transaction = exports.Balance = exports.BILLING_PACKAGE_NAME = exports.protobufPackage = void 0;
9
+ exports.BillingServiceControllerMethods = BillingServiceControllerMethods;
10
+ /* eslint-disable */
11
+ const wire_1 = require("@bufbuild/protobuf/wire");
12
+ const microservices_1 = require("@nestjs/microservices");
13
+ exports.protobufPackage = "billing";
14
+ exports.BILLING_PACKAGE_NAME = "billing";
15
+ function createBaseBalance() {
16
+ return { userId: "", balance: 0, currency: "", updatedAt: "" };
17
+ }
18
+ exports.Balance = {
19
+ encode(message, writer = new wire_1.BinaryWriter()) {
20
+ if (message.userId !== "") {
21
+ writer.uint32(10).string(message.userId);
22
+ }
23
+ if (message.balance !== 0) {
24
+ writer.uint32(17).double(message.balance);
25
+ }
26
+ if (message.currency !== "") {
27
+ writer.uint32(26).string(message.currency);
28
+ }
29
+ if (message.updatedAt !== "") {
30
+ writer.uint32(34).string(message.updatedAt);
31
+ }
32
+ return writer;
33
+ },
34
+ decode(input, length) {
35
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
36
+ const end = length === undefined ? reader.len : reader.pos + length;
37
+ const message = createBaseBalance();
38
+ while (reader.pos < end) {
39
+ const tag = reader.uint32();
40
+ switch (tag >>> 3) {
41
+ case 1: {
42
+ if (tag !== 10) {
43
+ break;
44
+ }
45
+ message.userId = reader.string();
46
+ continue;
47
+ }
48
+ case 2: {
49
+ if (tag !== 17) {
50
+ break;
51
+ }
52
+ message.balance = reader.double();
53
+ continue;
54
+ }
55
+ case 3: {
56
+ if (tag !== 26) {
57
+ break;
58
+ }
59
+ message.currency = reader.string();
60
+ continue;
61
+ }
62
+ case 4: {
63
+ if (tag !== 34) {
64
+ break;
65
+ }
66
+ message.updatedAt = reader.string();
67
+ continue;
68
+ }
69
+ }
70
+ if ((tag & 7) === 4 || tag === 0) {
71
+ break;
72
+ }
73
+ reader.skip(tag & 7);
74
+ }
75
+ return message;
76
+ },
77
+ };
78
+ function createBaseTransaction() {
79
+ return {
80
+ id: "",
81
+ userId: "",
82
+ type: "",
83
+ amount: 0,
84
+ currency: "",
85
+ status: "",
86
+ description: "",
87
+ metadata: "",
88
+ createdAt: "",
89
+ };
90
+ }
91
+ exports.Transaction = {
92
+ encode(message, writer = new wire_1.BinaryWriter()) {
93
+ if (message.id !== "") {
94
+ writer.uint32(10).string(message.id);
95
+ }
96
+ if (message.userId !== "") {
97
+ writer.uint32(18).string(message.userId);
98
+ }
99
+ if (message.type !== "") {
100
+ writer.uint32(26).string(message.type);
101
+ }
102
+ if (message.amount !== 0) {
103
+ writer.uint32(33).double(message.amount);
104
+ }
105
+ if (message.currency !== "") {
106
+ writer.uint32(42).string(message.currency);
107
+ }
108
+ if (message.status !== "") {
109
+ writer.uint32(50).string(message.status);
110
+ }
111
+ if (message.description !== "") {
112
+ writer.uint32(58).string(message.description);
113
+ }
114
+ if (message.metadata !== "") {
115
+ writer.uint32(66).string(message.metadata);
116
+ }
117
+ if (message.createdAt !== "") {
118
+ writer.uint32(74).string(message.createdAt);
119
+ }
120
+ return writer;
121
+ },
122
+ decode(input, length) {
123
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
124
+ const end = length === undefined ? reader.len : reader.pos + length;
125
+ const message = createBaseTransaction();
126
+ while (reader.pos < end) {
127
+ const tag = reader.uint32();
128
+ switch (tag >>> 3) {
129
+ case 1: {
130
+ if (tag !== 10) {
131
+ break;
132
+ }
133
+ message.id = reader.string();
134
+ continue;
135
+ }
136
+ case 2: {
137
+ if (tag !== 18) {
138
+ break;
139
+ }
140
+ message.userId = reader.string();
141
+ continue;
142
+ }
143
+ case 3: {
144
+ if (tag !== 26) {
145
+ break;
146
+ }
147
+ message.type = reader.string();
148
+ continue;
149
+ }
150
+ case 4: {
151
+ if (tag !== 33) {
152
+ break;
153
+ }
154
+ message.amount = reader.double();
155
+ continue;
156
+ }
157
+ case 5: {
158
+ if (tag !== 42) {
159
+ break;
160
+ }
161
+ message.currency = reader.string();
162
+ continue;
163
+ }
164
+ case 6: {
165
+ if (tag !== 50) {
166
+ break;
167
+ }
168
+ message.status = reader.string();
169
+ continue;
170
+ }
171
+ case 7: {
172
+ if (tag !== 58) {
173
+ break;
174
+ }
175
+ message.description = reader.string();
176
+ continue;
177
+ }
178
+ case 8: {
179
+ if (tag !== 66) {
180
+ break;
181
+ }
182
+ message.metadata = reader.string();
183
+ continue;
184
+ }
185
+ case 9: {
186
+ if (tag !== 74) {
187
+ break;
188
+ }
189
+ message.createdAt = reader.string();
190
+ continue;
191
+ }
192
+ }
193
+ if ((tag & 7) === 4 || tag === 0) {
194
+ break;
195
+ }
196
+ reader.skip(tag & 7);
197
+ }
198
+ return message;
199
+ },
200
+ };
201
+ function createBaseUsage() {
202
+ return {
203
+ id: "",
204
+ keyId: "",
205
+ requestId: "",
206
+ userId: "",
207
+ tokensInput: 0,
208
+ tokensOutput: 0,
209
+ cost: 0,
210
+ endpointId: "",
211
+ modelId: "",
212
+ status: "",
213
+ createdAt: "",
214
+ };
215
+ }
216
+ exports.Usage = {
217
+ encode(message, writer = new wire_1.BinaryWriter()) {
218
+ if (message.id !== "") {
219
+ writer.uint32(10).string(message.id);
220
+ }
221
+ if (message.keyId !== "") {
222
+ writer.uint32(18).string(message.keyId);
223
+ }
224
+ if (message.requestId !== "") {
225
+ writer.uint32(26).string(message.requestId);
226
+ }
227
+ if (message.userId !== "") {
228
+ writer.uint32(34).string(message.userId);
229
+ }
230
+ if (message.tokensInput !== 0) {
231
+ writer.uint32(40).int32(message.tokensInput);
232
+ }
233
+ if (message.tokensOutput !== 0) {
234
+ writer.uint32(48).int32(message.tokensOutput);
235
+ }
236
+ if (message.cost !== 0) {
237
+ writer.uint32(57).double(message.cost);
238
+ }
239
+ if (message.endpointId !== "") {
240
+ writer.uint32(66).string(message.endpointId);
241
+ }
242
+ if (message.modelId !== "") {
243
+ writer.uint32(74).string(message.modelId);
244
+ }
245
+ if (message.status !== "") {
246
+ writer.uint32(82).string(message.status);
247
+ }
248
+ if (message.createdAt !== "") {
249
+ writer.uint32(90).string(message.createdAt);
250
+ }
251
+ return writer;
252
+ },
253
+ decode(input, length) {
254
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
255
+ const end = length === undefined ? reader.len : reader.pos + length;
256
+ const message = createBaseUsage();
257
+ while (reader.pos < end) {
258
+ const tag = reader.uint32();
259
+ switch (tag >>> 3) {
260
+ case 1: {
261
+ if (tag !== 10) {
262
+ break;
263
+ }
264
+ message.id = reader.string();
265
+ continue;
266
+ }
267
+ case 2: {
268
+ if (tag !== 18) {
269
+ break;
270
+ }
271
+ message.keyId = reader.string();
272
+ continue;
273
+ }
274
+ case 3: {
275
+ if (tag !== 26) {
276
+ break;
277
+ }
278
+ message.requestId = reader.string();
279
+ continue;
280
+ }
281
+ case 4: {
282
+ if (tag !== 34) {
283
+ break;
284
+ }
285
+ message.userId = reader.string();
286
+ continue;
287
+ }
288
+ case 5: {
289
+ if (tag !== 40) {
290
+ break;
291
+ }
292
+ message.tokensInput = reader.int32();
293
+ continue;
294
+ }
295
+ case 6: {
296
+ if (tag !== 48) {
297
+ break;
298
+ }
299
+ message.tokensOutput = reader.int32();
300
+ continue;
301
+ }
302
+ case 7: {
303
+ if (tag !== 57) {
304
+ break;
305
+ }
306
+ message.cost = reader.double();
307
+ continue;
308
+ }
309
+ case 8: {
310
+ if (tag !== 66) {
311
+ break;
312
+ }
313
+ message.endpointId = reader.string();
314
+ continue;
315
+ }
316
+ case 9: {
317
+ if (tag !== 74) {
318
+ break;
319
+ }
320
+ message.modelId = reader.string();
321
+ continue;
322
+ }
323
+ case 10: {
324
+ if (tag !== 82) {
325
+ break;
326
+ }
327
+ message.status = reader.string();
328
+ continue;
329
+ }
330
+ case 11: {
331
+ if (tag !== 90) {
332
+ break;
333
+ }
334
+ message.createdAt = reader.string();
335
+ continue;
336
+ }
337
+ }
338
+ if ((tag & 7) === 4 || tag === 0) {
339
+ break;
340
+ }
341
+ reader.skip(tag & 7);
342
+ }
343
+ return message;
344
+ },
345
+ };
346
+ function createBasePayment() {
347
+ return {
348
+ id: "",
349
+ userId: "",
350
+ transactionId: "",
351
+ provider: "",
352
+ providerPaymentId: "",
353
+ amount: 0,
354
+ currency: "",
355
+ status: "",
356
+ metadata: "",
357
+ createdAt: "",
358
+ };
359
+ }
360
+ exports.Payment = {
361
+ encode(message, writer = new wire_1.BinaryWriter()) {
362
+ if (message.id !== "") {
363
+ writer.uint32(10).string(message.id);
364
+ }
365
+ if (message.userId !== "") {
366
+ writer.uint32(18).string(message.userId);
367
+ }
368
+ if (message.transactionId !== "") {
369
+ writer.uint32(26).string(message.transactionId);
370
+ }
371
+ if (message.provider !== "") {
372
+ writer.uint32(34).string(message.provider);
373
+ }
374
+ if (message.providerPaymentId !== "") {
375
+ writer.uint32(42).string(message.providerPaymentId);
376
+ }
377
+ if (message.amount !== 0) {
378
+ writer.uint32(49).double(message.amount);
379
+ }
380
+ if (message.currency !== "") {
381
+ writer.uint32(58).string(message.currency);
382
+ }
383
+ if (message.status !== "") {
384
+ writer.uint32(66).string(message.status);
385
+ }
386
+ if (message.metadata !== "") {
387
+ writer.uint32(74).string(message.metadata);
388
+ }
389
+ if (message.createdAt !== "") {
390
+ writer.uint32(82).string(message.createdAt);
391
+ }
392
+ return writer;
393
+ },
394
+ decode(input, length) {
395
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
396
+ const end = length === undefined ? reader.len : reader.pos + length;
397
+ const message = createBasePayment();
398
+ while (reader.pos < end) {
399
+ const tag = reader.uint32();
400
+ switch (tag >>> 3) {
401
+ case 1: {
402
+ if (tag !== 10) {
403
+ break;
404
+ }
405
+ message.id = reader.string();
406
+ continue;
407
+ }
408
+ case 2: {
409
+ if (tag !== 18) {
410
+ break;
411
+ }
412
+ message.userId = reader.string();
413
+ continue;
414
+ }
415
+ case 3: {
416
+ if (tag !== 26) {
417
+ break;
418
+ }
419
+ message.transactionId = reader.string();
420
+ continue;
421
+ }
422
+ case 4: {
423
+ if (tag !== 34) {
424
+ break;
425
+ }
426
+ message.provider = reader.string();
427
+ continue;
428
+ }
429
+ case 5: {
430
+ if (tag !== 42) {
431
+ break;
432
+ }
433
+ message.providerPaymentId = reader.string();
434
+ continue;
435
+ }
436
+ case 6: {
437
+ if (tag !== 49) {
438
+ break;
439
+ }
440
+ message.amount = reader.double();
441
+ continue;
442
+ }
443
+ case 7: {
444
+ if (tag !== 58) {
445
+ break;
446
+ }
447
+ message.currency = reader.string();
448
+ continue;
449
+ }
450
+ case 8: {
451
+ if (tag !== 66) {
452
+ break;
453
+ }
454
+ message.status = reader.string();
455
+ continue;
456
+ }
457
+ case 9: {
458
+ if (tag !== 74) {
459
+ break;
460
+ }
461
+ message.metadata = reader.string();
462
+ continue;
463
+ }
464
+ case 10: {
465
+ if (tag !== 82) {
466
+ break;
467
+ }
468
+ message.createdAt = reader.string();
469
+ continue;
470
+ }
471
+ }
472
+ if ((tag & 7) === 4 || tag === 0) {
473
+ break;
474
+ }
475
+ reader.skip(tag & 7);
476
+ }
477
+ return message;
478
+ },
479
+ };
480
+ function createBaseUsageStats() {
481
+ return { totalTokensInput: 0, totalTokensOutput: 0, totalCost: 0, requestCount: 0, records: [] };
482
+ }
483
+ exports.UsageStats = {
484
+ encode(message, writer = new wire_1.BinaryWriter()) {
485
+ if (message.totalTokensInput !== 0) {
486
+ writer.uint32(8).int32(message.totalTokensInput);
487
+ }
488
+ if (message.totalTokensOutput !== 0) {
489
+ writer.uint32(16).int32(message.totalTokensOutput);
490
+ }
491
+ if (message.totalCost !== 0) {
492
+ writer.uint32(25).double(message.totalCost);
493
+ }
494
+ if (message.requestCount !== 0) {
495
+ writer.uint32(32).int32(message.requestCount);
496
+ }
497
+ for (const v of message.records) {
498
+ exports.Usage.encode(v, writer.uint32(42).fork()).join();
499
+ }
500
+ return writer;
501
+ },
502
+ decode(input, length) {
503
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
504
+ const end = length === undefined ? reader.len : reader.pos + length;
505
+ const message = createBaseUsageStats();
506
+ while (reader.pos < end) {
507
+ const tag = reader.uint32();
508
+ switch (tag >>> 3) {
509
+ case 1: {
510
+ if (tag !== 8) {
511
+ break;
512
+ }
513
+ message.totalTokensInput = reader.int32();
514
+ continue;
515
+ }
516
+ case 2: {
517
+ if (tag !== 16) {
518
+ break;
519
+ }
520
+ message.totalTokensOutput = reader.int32();
521
+ continue;
522
+ }
523
+ case 3: {
524
+ if (tag !== 25) {
525
+ break;
526
+ }
527
+ message.totalCost = reader.double();
528
+ continue;
529
+ }
530
+ case 4: {
531
+ if (tag !== 32) {
532
+ break;
533
+ }
534
+ message.requestCount = reader.int32();
535
+ continue;
536
+ }
537
+ case 5: {
538
+ if (tag !== 42) {
539
+ break;
540
+ }
541
+ message.records.push(exports.Usage.decode(reader, reader.uint32()));
542
+ continue;
543
+ }
544
+ }
545
+ if ((tag & 7) === 4 || tag === 0) {
546
+ break;
547
+ }
548
+ reader.skip(tag & 7);
549
+ }
550
+ return message;
551
+ },
552
+ };
553
+ function createBaseGetBalanceRequest() {
554
+ return { userId: "" };
555
+ }
556
+ exports.GetBalanceRequest = {
557
+ encode(message, writer = new wire_1.BinaryWriter()) {
558
+ if (message.userId !== "") {
559
+ writer.uint32(10).string(message.userId);
560
+ }
561
+ return writer;
562
+ },
563
+ decode(input, length) {
564
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
565
+ const end = length === undefined ? reader.len : reader.pos + length;
566
+ const message = createBaseGetBalanceRequest();
567
+ while (reader.pos < end) {
568
+ const tag = reader.uint32();
569
+ switch (tag >>> 3) {
570
+ case 1: {
571
+ if (tag !== 10) {
572
+ break;
573
+ }
574
+ message.userId = reader.string();
575
+ continue;
576
+ }
577
+ }
578
+ if ((tag & 7) === 4 || tag === 0) {
579
+ break;
580
+ }
581
+ reader.skip(tag & 7);
582
+ }
583
+ return message;
584
+ },
585
+ };
586
+ function createBaseChargeRequest() {
587
+ return { userId: "", amount: 0, description: "", metadata: "" };
588
+ }
589
+ exports.ChargeRequest = {
590
+ encode(message, writer = new wire_1.BinaryWriter()) {
591
+ if (message.userId !== "") {
592
+ writer.uint32(10).string(message.userId);
593
+ }
594
+ if (message.amount !== 0) {
595
+ writer.uint32(17).double(message.amount);
596
+ }
597
+ if (message.description !== "") {
598
+ writer.uint32(26).string(message.description);
599
+ }
600
+ if (message.metadata !== "") {
601
+ writer.uint32(34).string(message.metadata);
602
+ }
603
+ return writer;
604
+ },
605
+ decode(input, length) {
606
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
607
+ const end = length === undefined ? reader.len : reader.pos + length;
608
+ const message = createBaseChargeRequest();
609
+ while (reader.pos < end) {
610
+ const tag = reader.uint32();
611
+ switch (tag >>> 3) {
612
+ case 1: {
613
+ if (tag !== 10) {
614
+ break;
615
+ }
616
+ message.userId = reader.string();
617
+ continue;
618
+ }
619
+ case 2: {
620
+ if (tag !== 17) {
621
+ break;
622
+ }
623
+ message.amount = reader.double();
624
+ continue;
625
+ }
626
+ case 3: {
627
+ if (tag !== 26) {
628
+ break;
629
+ }
630
+ message.description = reader.string();
631
+ continue;
632
+ }
633
+ case 4: {
634
+ if (tag !== 34) {
635
+ break;
636
+ }
637
+ message.metadata = reader.string();
638
+ continue;
639
+ }
640
+ }
641
+ if ((tag & 7) === 4 || tag === 0) {
642
+ break;
643
+ }
644
+ reader.skip(tag & 7);
645
+ }
646
+ return message;
647
+ },
648
+ };
649
+ function createBaseDepositRequest() {
650
+ return { userId: "", amount: 0, description: "", metadata: "" };
651
+ }
652
+ exports.DepositRequest = {
653
+ encode(message, writer = new wire_1.BinaryWriter()) {
654
+ if (message.userId !== "") {
655
+ writer.uint32(10).string(message.userId);
656
+ }
657
+ if (message.amount !== 0) {
658
+ writer.uint32(17).double(message.amount);
659
+ }
660
+ if (message.description !== "") {
661
+ writer.uint32(26).string(message.description);
662
+ }
663
+ if (message.metadata !== "") {
664
+ writer.uint32(34).string(message.metadata);
665
+ }
666
+ return writer;
667
+ },
668
+ decode(input, length) {
669
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
670
+ const end = length === undefined ? reader.len : reader.pos + length;
671
+ const message = createBaseDepositRequest();
672
+ while (reader.pos < end) {
673
+ const tag = reader.uint32();
674
+ switch (tag >>> 3) {
675
+ case 1: {
676
+ if (tag !== 10) {
677
+ break;
678
+ }
679
+ message.userId = reader.string();
680
+ continue;
681
+ }
682
+ case 2: {
683
+ if (tag !== 17) {
684
+ break;
685
+ }
686
+ message.amount = reader.double();
687
+ continue;
688
+ }
689
+ case 3: {
690
+ if (tag !== 26) {
691
+ break;
692
+ }
693
+ message.description = reader.string();
694
+ continue;
695
+ }
696
+ case 4: {
697
+ if (tag !== 34) {
698
+ break;
699
+ }
700
+ message.metadata = reader.string();
701
+ continue;
702
+ }
703
+ }
704
+ if ((tag & 7) === 4 || tag === 0) {
705
+ break;
706
+ }
707
+ reader.skip(tag & 7);
708
+ }
709
+ return message;
710
+ },
711
+ };
712
+ function createBaseGetBalanceResponse() {
713
+ return {};
714
+ }
715
+ exports.GetBalanceResponse = {
716
+ encode(message, writer = new wire_1.BinaryWriter()) {
717
+ if (message.balance !== undefined) {
718
+ exports.Balance.encode(message.balance, writer.uint32(10).fork()).join();
719
+ }
720
+ return writer;
721
+ },
722
+ decode(input, length) {
723
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
724
+ const end = length === undefined ? reader.len : reader.pos + length;
725
+ const message = createBaseGetBalanceResponse();
726
+ while (reader.pos < end) {
727
+ const tag = reader.uint32();
728
+ switch (tag >>> 3) {
729
+ case 1: {
730
+ if (tag !== 10) {
731
+ break;
732
+ }
733
+ message.balance = exports.Balance.decode(reader, reader.uint32());
734
+ continue;
735
+ }
736
+ }
737
+ if ((tag & 7) === 4 || tag === 0) {
738
+ break;
739
+ }
740
+ reader.skip(tag & 7);
741
+ }
742
+ return message;
743
+ },
744
+ };
745
+ function createBaseChargeResponse() {
746
+ return {};
747
+ }
748
+ exports.ChargeResponse = {
749
+ encode(message, writer = new wire_1.BinaryWriter()) {
750
+ if (message.transaction !== undefined) {
751
+ exports.Transaction.encode(message.transaction, writer.uint32(10).fork()).join();
752
+ }
753
+ if (message.balance !== undefined) {
754
+ exports.Balance.encode(message.balance, writer.uint32(18).fork()).join();
755
+ }
756
+ return writer;
757
+ },
758
+ decode(input, length) {
759
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
760
+ const end = length === undefined ? reader.len : reader.pos + length;
761
+ const message = createBaseChargeResponse();
762
+ while (reader.pos < end) {
763
+ const tag = reader.uint32();
764
+ switch (tag >>> 3) {
765
+ case 1: {
766
+ if (tag !== 10) {
767
+ break;
768
+ }
769
+ message.transaction = exports.Transaction.decode(reader, reader.uint32());
770
+ continue;
771
+ }
772
+ case 2: {
773
+ if (tag !== 18) {
774
+ break;
775
+ }
776
+ message.balance = exports.Balance.decode(reader, reader.uint32());
777
+ continue;
778
+ }
779
+ }
780
+ if ((tag & 7) === 4 || tag === 0) {
781
+ break;
782
+ }
783
+ reader.skip(tag & 7);
784
+ }
785
+ return message;
786
+ },
787
+ };
788
+ function createBaseDepositResponse() {
789
+ return {};
790
+ }
791
+ exports.DepositResponse = {
792
+ encode(message, writer = new wire_1.BinaryWriter()) {
793
+ if (message.transaction !== undefined) {
794
+ exports.Transaction.encode(message.transaction, writer.uint32(10).fork()).join();
795
+ }
796
+ if (message.balance !== undefined) {
797
+ exports.Balance.encode(message.balance, writer.uint32(18).fork()).join();
798
+ }
799
+ return writer;
800
+ },
801
+ decode(input, length) {
802
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
803
+ const end = length === undefined ? reader.len : reader.pos + length;
804
+ const message = createBaseDepositResponse();
805
+ while (reader.pos < end) {
806
+ const tag = reader.uint32();
807
+ switch (tag >>> 3) {
808
+ case 1: {
809
+ if (tag !== 10) {
810
+ break;
811
+ }
812
+ message.transaction = exports.Transaction.decode(reader, reader.uint32());
813
+ continue;
814
+ }
815
+ case 2: {
816
+ if (tag !== 18) {
817
+ break;
818
+ }
819
+ message.balance = exports.Balance.decode(reader, reader.uint32());
820
+ continue;
821
+ }
822
+ }
823
+ if ((tag & 7) === 4 || tag === 0) {
824
+ break;
825
+ }
826
+ reader.skip(tag & 7);
827
+ }
828
+ return message;
829
+ },
830
+ };
831
+ function createBaseCreateTransactionRequest() {
832
+ return { userId: "", type: "", amount: 0, description: "", metadata: "" };
833
+ }
834
+ exports.CreateTransactionRequest = {
835
+ encode(message, writer = new wire_1.BinaryWriter()) {
836
+ if (message.userId !== "") {
837
+ writer.uint32(10).string(message.userId);
838
+ }
839
+ if (message.type !== "") {
840
+ writer.uint32(18).string(message.type);
841
+ }
842
+ if (message.amount !== 0) {
843
+ writer.uint32(25).double(message.amount);
844
+ }
845
+ if (message.description !== "") {
846
+ writer.uint32(34).string(message.description);
847
+ }
848
+ if (message.metadata !== "") {
849
+ writer.uint32(42).string(message.metadata);
850
+ }
851
+ return writer;
852
+ },
853
+ decode(input, length) {
854
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
855
+ const end = length === undefined ? reader.len : reader.pos + length;
856
+ const message = createBaseCreateTransactionRequest();
857
+ while (reader.pos < end) {
858
+ const tag = reader.uint32();
859
+ switch (tag >>> 3) {
860
+ case 1: {
861
+ if (tag !== 10) {
862
+ break;
863
+ }
864
+ message.userId = reader.string();
865
+ continue;
866
+ }
867
+ case 2: {
868
+ if (tag !== 18) {
869
+ break;
870
+ }
871
+ message.type = reader.string();
872
+ continue;
873
+ }
874
+ case 3: {
875
+ if (tag !== 25) {
876
+ break;
877
+ }
878
+ message.amount = reader.double();
879
+ continue;
880
+ }
881
+ case 4: {
882
+ if (tag !== 34) {
883
+ break;
884
+ }
885
+ message.description = reader.string();
886
+ continue;
887
+ }
888
+ case 5: {
889
+ if (tag !== 42) {
890
+ break;
891
+ }
892
+ message.metadata = reader.string();
893
+ continue;
894
+ }
895
+ }
896
+ if ((tag & 7) === 4 || tag === 0) {
897
+ break;
898
+ }
899
+ reader.skip(tag & 7);
900
+ }
901
+ return message;
902
+ },
903
+ };
904
+ function createBaseGetTransactionsRequest() {
905
+ return { userId: "", startDate: "", endDate: "", type: "", limit: 0, offset: 0 };
906
+ }
907
+ exports.GetTransactionsRequest = {
908
+ encode(message, writer = new wire_1.BinaryWriter()) {
909
+ if (message.userId !== "") {
910
+ writer.uint32(10).string(message.userId);
911
+ }
912
+ if (message.startDate !== "") {
913
+ writer.uint32(18).string(message.startDate);
914
+ }
915
+ if (message.endDate !== "") {
916
+ writer.uint32(26).string(message.endDate);
917
+ }
918
+ if (message.type !== "") {
919
+ writer.uint32(34).string(message.type);
920
+ }
921
+ if (message.limit !== 0) {
922
+ writer.uint32(40).int32(message.limit);
923
+ }
924
+ if (message.offset !== 0) {
925
+ writer.uint32(48).int32(message.offset);
926
+ }
927
+ return writer;
928
+ },
929
+ decode(input, length) {
930
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
931
+ const end = length === undefined ? reader.len : reader.pos + length;
932
+ const message = createBaseGetTransactionsRequest();
933
+ while (reader.pos < end) {
934
+ const tag = reader.uint32();
935
+ switch (tag >>> 3) {
936
+ case 1: {
937
+ if (tag !== 10) {
938
+ break;
939
+ }
940
+ message.userId = reader.string();
941
+ continue;
942
+ }
943
+ case 2: {
944
+ if (tag !== 18) {
945
+ break;
946
+ }
947
+ message.startDate = reader.string();
948
+ continue;
949
+ }
950
+ case 3: {
951
+ if (tag !== 26) {
952
+ break;
953
+ }
954
+ message.endDate = reader.string();
955
+ continue;
956
+ }
957
+ case 4: {
958
+ if (tag !== 34) {
959
+ break;
960
+ }
961
+ message.type = reader.string();
962
+ continue;
963
+ }
964
+ case 5: {
965
+ if (tag !== 40) {
966
+ break;
967
+ }
968
+ message.limit = reader.int32();
969
+ continue;
970
+ }
971
+ case 6: {
972
+ if (tag !== 48) {
973
+ break;
974
+ }
975
+ message.offset = reader.int32();
976
+ continue;
977
+ }
978
+ }
979
+ if ((tag & 7) === 4 || tag === 0) {
980
+ break;
981
+ }
982
+ reader.skip(tag & 7);
983
+ }
984
+ return message;
985
+ },
986
+ };
987
+ function createBaseGetTransactionRequest() {
988
+ return { id: "" };
989
+ }
990
+ exports.GetTransactionRequest = {
991
+ encode(message, writer = new wire_1.BinaryWriter()) {
992
+ if (message.id !== "") {
993
+ writer.uint32(10).string(message.id);
994
+ }
995
+ return writer;
996
+ },
997
+ decode(input, length) {
998
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
999
+ const end = length === undefined ? reader.len : reader.pos + length;
1000
+ const message = createBaseGetTransactionRequest();
1001
+ while (reader.pos < end) {
1002
+ const tag = reader.uint32();
1003
+ switch (tag >>> 3) {
1004
+ case 1: {
1005
+ if (tag !== 10) {
1006
+ break;
1007
+ }
1008
+ message.id = reader.string();
1009
+ continue;
1010
+ }
1011
+ }
1012
+ if ((tag & 7) === 4 || tag === 0) {
1013
+ break;
1014
+ }
1015
+ reader.skip(tag & 7);
1016
+ }
1017
+ return message;
1018
+ },
1019
+ };
1020
+ function createBaseCreateTransactionResponse() {
1021
+ return {};
1022
+ }
1023
+ exports.CreateTransactionResponse = {
1024
+ encode(message, writer = new wire_1.BinaryWriter()) {
1025
+ if (message.transaction !== undefined) {
1026
+ exports.Transaction.encode(message.transaction, writer.uint32(10).fork()).join();
1027
+ }
1028
+ return writer;
1029
+ },
1030
+ decode(input, length) {
1031
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1032
+ const end = length === undefined ? reader.len : reader.pos + length;
1033
+ const message = createBaseCreateTransactionResponse();
1034
+ while (reader.pos < end) {
1035
+ const tag = reader.uint32();
1036
+ switch (tag >>> 3) {
1037
+ case 1: {
1038
+ if (tag !== 10) {
1039
+ break;
1040
+ }
1041
+ message.transaction = exports.Transaction.decode(reader, reader.uint32());
1042
+ continue;
1043
+ }
1044
+ }
1045
+ if ((tag & 7) === 4 || tag === 0) {
1046
+ break;
1047
+ }
1048
+ reader.skip(tag & 7);
1049
+ }
1050
+ return message;
1051
+ },
1052
+ };
1053
+ function createBaseGetTransactionsResponse() {
1054
+ return { transactions: [], total: 0 };
1055
+ }
1056
+ exports.GetTransactionsResponse = {
1057
+ encode(message, writer = new wire_1.BinaryWriter()) {
1058
+ for (const v of message.transactions) {
1059
+ exports.Transaction.encode(v, writer.uint32(10).fork()).join();
1060
+ }
1061
+ if (message.total !== 0) {
1062
+ writer.uint32(16).int32(message.total);
1063
+ }
1064
+ return writer;
1065
+ },
1066
+ decode(input, length) {
1067
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1068
+ const end = length === undefined ? reader.len : reader.pos + length;
1069
+ const message = createBaseGetTransactionsResponse();
1070
+ while (reader.pos < end) {
1071
+ const tag = reader.uint32();
1072
+ switch (tag >>> 3) {
1073
+ case 1: {
1074
+ if (tag !== 10) {
1075
+ break;
1076
+ }
1077
+ message.transactions.push(exports.Transaction.decode(reader, reader.uint32()));
1078
+ continue;
1079
+ }
1080
+ case 2: {
1081
+ if (tag !== 16) {
1082
+ break;
1083
+ }
1084
+ message.total = reader.int32();
1085
+ continue;
1086
+ }
1087
+ }
1088
+ if ((tag & 7) === 4 || tag === 0) {
1089
+ break;
1090
+ }
1091
+ reader.skip(tag & 7);
1092
+ }
1093
+ return message;
1094
+ },
1095
+ };
1096
+ function createBaseGetTransactionResponse() {
1097
+ return {};
1098
+ }
1099
+ exports.GetTransactionResponse = {
1100
+ encode(message, writer = new wire_1.BinaryWriter()) {
1101
+ if (message.transaction !== undefined) {
1102
+ exports.Transaction.encode(message.transaction, writer.uint32(10).fork()).join();
1103
+ }
1104
+ return writer;
1105
+ },
1106
+ decode(input, length) {
1107
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1108
+ const end = length === undefined ? reader.len : reader.pos + length;
1109
+ const message = createBaseGetTransactionResponse();
1110
+ while (reader.pos < end) {
1111
+ const tag = reader.uint32();
1112
+ switch (tag >>> 3) {
1113
+ case 1: {
1114
+ if (tag !== 10) {
1115
+ break;
1116
+ }
1117
+ message.transaction = exports.Transaction.decode(reader, reader.uint32());
1118
+ continue;
1119
+ }
1120
+ }
1121
+ if ((tag & 7) === 4 || tag === 0) {
1122
+ break;
1123
+ }
1124
+ reader.skip(tag & 7);
1125
+ }
1126
+ return message;
1127
+ },
1128
+ };
1129
+ function createBaseRecordUsageRequest() {
1130
+ return {
1131
+ keyId: "",
1132
+ requestId: "",
1133
+ userId: "",
1134
+ tokensInput: 0,
1135
+ tokensOutput: 0,
1136
+ cost: 0,
1137
+ endpointId: "",
1138
+ modelId: "",
1139
+ status: "",
1140
+ };
1141
+ }
1142
+ exports.RecordUsageRequest = {
1143
+ encode(message, writer = new wire_1.BinaryWriter()) {
1144
+ if (message.keyId !== "") {
1145
+ writer.uint32(10).string(message.keyId);
1146
+ }
1147
+ if (message.requestId !== "") {
1148
+ writer.uint32(18).string(message.requestId);
1149
+ }
1150
+ if (message.userId !== "") {
1151
+ writer.uint32(26).string(message.userId);
1152
+ }
1153
+ if (message.tokensInput !== 0) {
1154
+ writer.uint32(32).int32(message.tokensInput);
1155
+ }
1156
+ if (message.tokensOutput !== 0) {
1157
+ writer.uint32(40).int32(message.tokensOutput);
1158
+ }
1159
+ if (message.cost !== 0) {
1160
+ writer.uint32(49).double(message.cost);
1161
+ }
1162
+ if (message.endpointId !== "") {
1163
+ writer.uint32(58).string(message.endpointId);
1164
+ }
1165
+ if (message.modelId !== "") {
1166
+ writer.uint32(66).string(message.modelId);
1167
+ }
1168
+ if (message.status !== "") {
1169
+ writer.uint32(74).string(message.status);
1170
+ }
1171
+ return writer;
1172
+ },
1173
+ decode(input, length) {
1174
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1175
+ const end = length === undefined ? reader.len : reader.pos + length;
1176
+ const message = createBaseRecordUsageRequest();
1177
+ while (reader.pos < end) {
1178
+ const tag = reader.uint32();
1179
+ switch (tag >>> 3) {
1180
+ case 1: {
1181
+ if (tag !== 10) {
1182
+ break;
1183
+ }
1184
+ message.keyId = reader.string();
1185
+ continue;
1186
+ }
1187
+ case 2: {
1188
+ if (tag !== 18) {
1189
+ break;
1190
+ }
1191
+ message.requestId = reader.string();
1192
+ continue;
1193
+ }
1194
+ case 3: {
1195
+ if (tag !== 26) {
1196
+ break;
1197
+ }
1198
+ message.userId = reader.string();
1199
+ continue;
1200
+ }
1201
+ case 4: {
1202
+ if (tag !== 32) {
1203
+ break;
1204
+ }
1205
+ message.tokensInput = reader.int32();
1206
+ continue;
1207
+ }
1208
+ case 5: {
1209
+ if (tag !== 40) {
1210
+ break;
1211
+ }
1212
+ message.tokensOutput = reader.int32();
1213
+ continue;
1214
+ }
1215
+ case 6: {
1216
+ if (tag !== 49) {
1217
+ break;
1218
+ }
1219
+ message.cost = reader.double();
1220
+ continue;
1221
+ }
1222
+ case 7: {
1223
+ if (tag !== 58) {
1224
+ break;
1225
+ }
1226
+ message.endpointId = reader.string();
1227
+ continue;
1228
+ }
1229
+ case 8: {
1230
+ if (tag !== 66) {
1231
+ break;
1232
+ }
1233
+ message.modelId = reader.string();
1234
+ continue;
1235
+ }
1236
+ case 9: {
1237
+ if (tag !== 74) {
1238
+ break;
1239
+ }
1240
+ message.status = reader.string();
1241
+ continue;
1242
+ }
1243
+ }
1244
+ if ((tag & 7) === 4 || tag === 0) {
1245
+ break;
1246
+ }
1247
+ reader.skip(tag & 7);
1248
+ }
1249
+ return message;
1250
+ },
1251
+ };
1252
+ function createBaseGetUsageStatsRequest() {
1253
+ return { keyId: "", startDate: "", endDate: "" };
1254
+ }
1255
+ exports.GetUsageStatsRequest = {
1256
+ encode(message, writer = new wire_1.BinaryWriter()) {
1257
+ if (message.keyId !== "") {
1258
+ writer.uint32(10).string(message.keyId);
1259
+ }
1260
+ if (message.startDate !== "") {
1261
+ writer.uint32(18).string(message.startDate);
1262
+ }
1263
+ if (message.endDate !== "") {
1264
+ writer.uint32(26).string(message.endDate);
1265
+ }
1266
+ return writer;
1267
+ },
1268
+ decode(input, length) {
1269
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1270
+ const end = length === undefined ? reader.len : reader.pos + length;
1271
+ const message = createBaseGetUsageStatsRequest();
1272
+ while (reader.pos < end) {
1273
+ const tag = reader.uint32();
1274
+ switch (tag >>> 3) {
1275
+ case 1: {
1276
+ if (tag !== 10) {
1277
+ break;
1278
+ }
1279
+ message.keyId = reader.string();
1280
+ continue;
1281
+ }
1282
+ case 2: {
1283
+ if (tag !== 18) {
1284
+ break;
1285
+ }
1286
+ message.startDate = reader.string();
1287
+ continue;
1288
+ }
1289
+ case 3: {
1290
+ if (tag !== 26) {
1291
+ break;
1292
+ }
1293
+ message.endDate = reader.string();
1294
+ continue;
1295
+ }
1296
+ }
1297
+ if ((tag & 7) === 4 || tag === 0) {
1298
+ break;
1299
+ }
1300
+ reader.skip(tag & 7);
1301
+ }
1302
+ return message;
1303
+ },
1304
+ };
1305
+ function createBaseGetUsageByKeyRequest() {
1306
+ return { keyId: "", limit: 0, offset: 0 };
1307
+ }
1308
+ exports.GetUsageByKeyRequest = {
1309
+ encode(message, writer = new wire_1.BinaryWriter()) {
1310
+ if (message.keyId !== "") {
1311
+ writer.uint32(10).string(message.keyId);
1312
+ }
1313
+ if (message.limit !== 0) {
1314
+ writer.uint32(16).int32(message.limit);
1315
+ }
1316
+ if (message.offset !== 0) {
1317
+ writer.uint32(24).int32(message.offset);
1318
+ }
1319
+ return writer;
1320
+ },
1321
+ decode(input, length) {
1322
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1323
+ const end = length === undefined ? reader.len : reader.pos + length;
1324
+ const message = createBaseGetUsageByKeyRequest();
1325
+ while (reader.pos < end) {
1326
+ const tag = reader.uint32();
1327
+ switch (tag >>> 3) {
1328
+ case 1: {
1329
+ if (tag !== 10) {
1330
+ break;
1331
+ }
1332
+ message.keyId = reader.string();
1333
+ continue;
1334
+ }
1335
+ case 2: {
1336
+ if (tag !== 16) {
1337
+ break;
1338
+ }
1339
+ message.limit = reader.int32();
1340
+ continue;
1341
+ }
1342
+ case 3: {
1343
+ if (tag !== 24) {
1344
+ break;
1345
+ }
1346
+ message.offset = reader.int32();
1347
+ continue;
1348
+ }
1349
+ }
1350
+ if ((tag & 7) === 4 || tag === 0) {
1351
+ break;
1352
+ }
1353
+ reader.skip(tag & 7);
1354
+ }
1355
+ return message;
1356
+ },
1357
+ };
1358
+ function createBaseGetUsageByUserRequest() {
1359
+ return { userId: "", limit: 0, offset: 0 };
1360
+ }
1361
+ exports.GetUsageByUserRequest = {
1362
+ encode(message, writer = new wire_1.BinaryWriter()) {
1363
+ if (message.userId !== "") {
1364
+ writer.uint32(10).string(message.userId);
1365
+ }
1366
+ if (message.limit !== 0) {
1367
+ writer.uint32(16).int32(message.limit);
1368
+ }
1369
+ if (message.offset !== 0) {
1370
+ writer.uint32(24).int32(message.offset);
1371
+ }
1372
+ return writer;
1373
+ },
1374
+ decode(input, length) {
1375
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1376
+ const end = length === undefined ? reader.len : reader.pos + length;
1377
+ const message = createBaseGetUsageByUserRequest();
1378
+ while (reader.pos < end) {
1379
+ const tag = reader.uint32();
1380
+ switch (tag >>> 3) {
1381
+ case 1: {
1382
+ if (tag !== 10) {
1383
+ break;
1384
+ }
1385
+ message.userId = reader.string();
1386
+ continue;
1387
+ }
1388
+ case 2: {
1389
+ if (tag !== 16) {
1390
+ break;
1391
+ }
1392
+ message.limit = reader.int32();
1393
+ continue;
1394
+ }
1395
+ case 3: {
1396
+ if (tag !== 24) {
1397
+ break;
1398
+ }
1399
+ message.offset = reader.int32();
1400
+ continue;
1401
+ }
1402
+ }
1403
+ if ((tag & 7) === 4 || tag === 0) {
1404
+ break;
1405
+ }
1406
+ reader.skip(tag & 7);
1407
+ }
1408
+ return message;
1409
+ },
1410
+ };
1411
+ function createBaseRecordUsageResponse() {
1412
+ return {};
1413
+ }
1414
+ exports.RecordUsageResponse = {
1415
+ encode(message, writer = new wire_1.BinaryWriter()) {
1416
+ if (message.usage !== undefined) {
1417
+ exports.Usage.encode(message.usage, writer.uint32(10).fork()).join();
1418
+ }
1419
+ return writer;
1420
+ },
1421
+ decode(input, length) {
1422
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1423
+ const end = length === undefined ? reader.len : reader.pos + length;
1424
+ const message = createBaseRecordUsageResponse();
1425
+ while (reader.pos < end) {
1426
+ const tag = reader.uint32();
1427
+ switch (tag >>> 3) {
1428
+ case 1: {
1429
+ if (tag !== 10) {
1430
+ break;
1431
+ }
1432
+ message.usage = exports.Usage.decode(reader, reader.uint32());
1433
+ continue;
1434
+ }
1435
+ }
1436
+ if ((tag & 7) === 4 || tag === 0) {
1437
+ break;
1438
+ }
1439
+ reader.skip(tag & 7);
1440
+ }
1441
+ return message;
1442
+ },
1443
+ };
1444
+ function createBaseGetUsageStatsResponse() {
1445
+ return {};
1446
+ }
1447
+ exports.GetUsageStatsResponse = {
1448
+ encode(message, writer = new wire_1.BinaryWriter()) {
1449
+ if (message.stats !== undefined) {
1450
+ exports.UsageStats.encode(message.stats, writer.uint32(10).fork()).join();
1451
+ }
1452
+ return writer;
1453
+ },
1454
+ decode(input, length) {
1455
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1456
+ const end = length === undefined ? reader.len : reader.pos + length;
1457
+ const message = createBaseGetUsageStatsResponse();
1458
+ while (reader.pos < end) {
1459
+ const tag = reader.uint32();
1460
+ switch (tag >>> 3) {
1461
+ case 1: {
1462
+ if (tag !== 10) {
1463
+ break;
1464
+ }
1465
+ message.stats = exports.UsageStats.decode(reader, reader.uint32());
1466
+ continue;
1467
+ }
1468
+ }
1469
+ if ((tag & 7) === 4 || tag === 0) {
1470
+ break;
1471
+ }
1472
+ reader.skip(tag & 7);
1473
+ }
1474
+ return message;
1475
+ },
1476
+ };
1477
+ function createBaseGetUsageByKeyResponse() {
1478
+ return { usages: [], total: 0 };
1479
+ }
1480
+ exports.GetUsageByKeyResponse = {
1481
+ encode(message, writer = new wire_1.BinaryWriter()) {
1482
+ for (const v of message.usages) {
1483
+ exports.Usage.encode(v, writer.uint32(10).fork()).join();
1484
+ }
1485
+ if (message.total !== 0) {
1486
+ writer.uint32(16).int32(message.total);
1487
+ }
1488
+ return writer;
1489
+ },
1490
+ decode(input, length) {
1491
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1492
+ const end = length === undefined ? reader.len : reader.pos + length;
1493
+ const message = createBaseGetUsageByKeyResponse();
1494
+ while (reader.pos < end) {
1495
+ const tag = reader.uint32();
1496
+ switch (tag >>> 3) {
1497
+ case 1: {
1498
+ if (tag !== 10) {
1499
+ break;
1500
+ }
1501
+ message.usages.push(exports.Usage.decode(reader, reader.uint32()));
1502
+ continue;
1503
+ }
1504
+ case 2: {
1505
+ if (tag !== 16) {
1506
+ break;
1507
+ }
1508
+ message.total = reader.int32();
1509
+ continue;
1510
+ }
1511
+ }
1512
+ if ((tag & 7) === 4 || tag === 0) {
1513
+ break;
1514
+ }
1515
+ reader.skip(tag & 7);
1516
+ }
1517
+ return message;
1518
+ },
1519
+ };
1520
+ function createBaseGetUsageByUserResponse() {
1521
+ return { usages: [], total: 0 };
1522
+ }
1523
+ exports.GetUsageByUserResponse = {
1524
+ encode(message, writer = new wire_1.BinaryWriter()) {
1525
+ for (const v of message.usages) {
1526
+ exports.Usage.encode(v, writer.uint32(10).fork()).join();
1527
+ }
1528
+ if (message.total !== 0) {
1529
+ writer.uint32(16).int32(message.total);
1530
+ }
1531
+ return writer;
1532
+ },
1533
+ decode(input, length) {
1534
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1535
+ const end = length === undefined ? reader.len : reader.pos + length;
1536
+ const message = createBaseGetUsageByUserResponse();
1537
+ while (reader.pos < end) {
1538
+ const tag = reader.uint32();
1539
+ switch (tag >>> 3) {
1540
+ case 1: {
1541
+ if (tag !== 10) {
1542
+ break;
1543
+ }
1544
+ message.usages.push(exports.Usage.decode(reader, reader.uint32()));
1545
+ continue;
1546
+ }
1547
+ case 2: {
1548
+ if (tag !== 16) {
1549
+ break;
1550
+ }
1551
+ message.total = reader.int32();
1552
+ continue;
1553
+ }
1554
+ }
1555
+ if ((tag & 7) === 4 || tag === 0) {
1556
+ break;
1557
+ }
1558
+ reader.skip(tag & 7);
1559
+ }
1560
+ return message;
1561
+ },
1562
+ };
1563
+ function createBaseCreatePaymentRequest() {
1564
+ return { userId: "", amount: 0, currency: "", description: "", returnUrl: "", metadata: "" };
1565
+ }
1566
+ exports.CreatePaymentRequest = {
1567
+ encode(message, writer = new wire_1.BinaryWriter()) {
1568
+ if (message.userId !== "") {
1569
+ writer.uint32(10).string(message.userId);
1570
+ }
1571
+ if (message.amount !== 0) {
1572
+ writer.uint32(17).double(message.amount);
1573
+ }
1574
+ if (message.currency !== "") {
1575
+ writer.uint32(26).string(message.currency);
1576
+ }
1577
+ if (message.description !== "") {
1578
+ writer.uint32(34).string(message.description);
1579
+ }
1580
+ if (message.returnUrl !== "") {
1581
+ writer.uint32(42).string(message.returnUrl);
1582
+ }
1583
+ if (message.metadata !== "") {
1584
+ writer.uint32(50).string(message.metadata);
1585
+ }
1586
+ return writer;
1587
+ },
1588
+ decode(input, length) {
1589
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1590
+ const end = length === undefined ? reader.len : reader.pos + length;
1591
+ const message = createBaseCreatePaymentRequest();
1592
+ while (reader.pos < end) {
1593
+ const tag = reader.uint32();
1594
+ switch (tag >>> 3) {
1595
+ case 1: {
1596
+ if (tag !== 10) {
1597
+ break;
1598
+ }
1599
+ message.userId = reader.string();
1600
+ continue;
1601
+ }
1602
+ case 2: {
1603
+ if (tag !== 17) {
1604
+ break;
1605
+ }
1606
+ message.amount = reader.double();
1607
+ continue;
1608
+ }
1609
+ case 3: {
1610
+ if (tag !== 26) {
1611
+ break;
1612
+ }
1613
+ message.currency = reader.string();
1614
+ continue;
1615
+ }
1616
+ case 4: {
1617
+ if (tag !== 34) {
1618
+ break;
1619
+ }
1620
+ message.description = reader.string();
1621
+ continue;
1622
+ }
1623
+ case 5: {
1624
+ if (tag !== 42) {
1625
+ break;
1626
+ }
1627
+ message.returnUrl = reader.string();
1628
+ continue;
1629
+ }
1630
+ case 6: {
1631
+ if (tag !== 50) {
1632
+ break;
1633
+ }
1634
+ message.metadata = reader.string();
1635
+ continue;
1636
+ }
1637
+ }
1638
+ if ((tag & 7) === 4 || tag === 0) {
1639
+ break;
1640
+ }
1641
+ reader.skip(tag & 7);
1642
+ }
1643
+ return message;
1644
+ },
1645
+ };
1646
+ function createBaseGetPaymentRequest() {
1647
+ return { id: "" };
1648
+ }
1649
+ exports.GetPaymentRequest = {
1650
+ encode(message, writer = new wire_1.BinaryWriter()) {
1651
+ if (message.id !== "") {
1652
+ writer.uint32(10).string(message.id);
1653
+ }
1654
+ return writer;
1655
+ },
1656
+ decode(input, length) {
1657
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1658
+ const end = length === undefined ? reader.len : reader.pos + length;
1659
+ const message = createBaseGetPaymentRequest();
1660
+ while (reader.pos < end) {
1661
+ const tag = reader.uint32();
1662
+ switch (tag >>> 3) {
1663
+ case 1: {
1664
+ if (tag !== 10) {
1665
+ break;
1666
+ }
1667
+ message.id = reader.string();
1668
+ continue;
1669
+ }
1670
+ }
1671
+ if ((tag & 7) === 4 || tag === 0) {
1672
+ break;
1673
+ }
1674
+ reader.skip(tag & 7);
1675
+ }
1676
+ return message;
1677
+ },
1678
+ };
1679
+ function createBaseGetPaymentsByUserRequest() {
1680
+ return { userId: "", limit: 0, offset: 0 };
1681
+ }
1682
+ exports.GetPaymentsByUserRequest = {
1683
+ encode(message, writer = new wire_1.BinaryWriter()) {
1684
+ if (message.userId !== "") {
1685
+ writer.uint32(10).string(message.userId);
1686
+ }
1687
+ if (message.limit !== 0) {
1688
+ writer.uint32(16).int32(message.limit);
1689
+ }
1690
+ if (message.offset !== 0) {
1691
+ writer.uint32(24).int32(message.offset);
1692
+ }
1693
+ return writer;
1694
+ },
1695
+ decode(input, length) {
1696
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1697
+ const end = length === undefined ? reader.len : reader.pos + length;
1698
+ const message = createBaseGetPaymentsByUserRequest();
1699
+ while (reader.pos < end) {
1700
+ const tag = reader.uint32();
1701
+ switch (tag >>> 3) {
1702
+ case 1: {
1703
+ if (tag !== 10) {
1704
+ break;
1705
+ }
1706
+ message.userId = reader.string();
1707
+ continue;
1708
+ }
1709
+ case 2: {
1710
+ if (tag !== 16) {
1711
+ break;
1712
+ }
1713
+ message.limit = reader.int32();
1714
+ continue;
1715
+ }
1716
+ case 3: {
1717
+ if (tag !== 24) {
1718
+ break;
1719
+ }
1720
+ message.offset = reader.int32();
1721
+ continue;
1722
+ }
1723
+ }
1724
+ if ((tag & 7) === 4 || tag === 0) {
1725
+ break;
1726
+ }
1727
+ reader.skip(tag & 7);
1728
+ }
1729
+ return message;
1730
+ },
1731
+ };
1732
+ function createBaseProcessWebhookRequest() {
1733
+ return { event: "", data: "" };
1734
+ }
1735
+ exports.ProcessWebhookRequest = {
1736
+ encode(message, writer = new wire_1.BinaryWriter()) {
1737
+ if (message.event !== "") {
1738
+ writer.uint32(10).string(message.event);
1739
+ }
1740
+ if (message.data !== "") {
1741
+ writer.uint32(18).string(message.data);
1742
+ }
1743
+ return writer;
1744
+ },
1745
+ decode(input, length) {
1746
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1747
+ const end = length === undefined ? reader.len : reader.pos + length;
1748
+ const message = createBaseProcessWebhookRequest();
1749
+ while (reader.pos < end) {
1750
+ const tag = reader.uint32();
1751
+ switch (tag >>> 3) {
1752
+ case 1: {
1753
+ if (tag !== 10) {
1754
+ break;
1755
+ }
1756
+ message.event = reader.string();
1757
+ continue;
1758
+ }
1759
+ case 2: {
1760
+ if (tag !== 18) {
1761
+ break;
1762
+ }
1763
+ message.data = reader.string();
1764
+ continue;
1765
+ }
1766
+ }
1767
+ if ((tag & 7) === 4 || tag === 0) {
1768
+ break;
1769
+ }
1770
+ reader.skip(tag & 7);
1771
+ }
1772
+ return message;
1773
+ },
1774
+ };
1775
+ function createBaseCreatePaymentResponse() {
1776
+ return { paymentUrl: "" };
1777
+ }
1778
+ exports.CreatePaymentResponse = {
1779
+ encode(message, writer = new wire_1.BinaryWriter()) {
1780
+ if (message.payment !== undefined) {
1781
+ exports.Payment.encode(message.payment, writer.uint32(10).fork()).join();
1782
+ }
1783
+ if (message.paymentUrl !== "") {
1784
+ writer.uint32(18).string(message.paymentUrl);
1785
+ }
1786
+ return writer;
1787
+ },
1788
+ decode(input, length) {
1789
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1790
+ const end = length === undefined ? reader.len : reader.pos + length;
1791
+ const message = createBaseCreatePaymentResponse();
1792
+ while (reader.pos < end) {
1793
+ const tag = reader.uint32();
1794
+ switch (tag >>> 3) {
1795
+ case 1: {
1796
+ if (tag !== 10) {
1797
+ break;
1798
+ }
1799
+ message.payment = exports.Payment.decode(reader, reader.uint32());
1800
+ continue;
1801
+ }
1802
+ case 2: {
1803
+ if (tag !== 18) {
1804
+ break;
1805
+ }
1806
+ message.paymentUrl = reader.string();
1807
+ continue;
1808
+ }
1809
+ }
1810
+ if ((tag & 7) === 4 || tag === 0) {
1811
+ break;
1812
+ }
1813
+ reader.skip(tag & 7);
1814
+ }
1815
+ return message;
1816
+ },
1817
+ };
1818
+ function createBaseGetPaymentResponse() {
1819
+ return {};
1820
+ }
1821
+ exports.GetPaymentResponse = {
1822
+ encode(message, writer = new wire_1.BinaryWriter()) {
1823
+ if (message.payment !== undefined) {
1824
+ exports.Payment.encode(message.payment, writer.uint32(10).fork()).join();
1825
+ }
1826
+ return writer;
1827
+ },
1828
+ decode(input, length) {
1829
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1830
+ const end = length === undefined ? reader.len : reader.pos + length;
1831
+ const message = createBaseGetPaymentResponse();
1832
+ while (reader.pos < end) {
1833
+ const tag = reader.uint32();
1834
+ switch (tag >>> 3) {
1835
+ case 1: {
1836
+ if (tag !== 10) {
1837
+ break;
1838
+ }
1839
+ message.payment = exports.Payment.decode(reader, reader.uint32());
1840
+ continue;
1841
+ }
1842
+ }
1843
+ if ((tag & 7) === 4 || tag === 0) {
1844
+ break;
1845
+ }
1846
+ reader.skip(tag & 7);
1847
+ }
1848
+ return message;
1849
+ },
1850
+ };
1851
+ function createBaseGetPaymentsByUserResponse() {
1852
+ return { payments: [], total: 0 };
1853
+ }
1854
+ exports.GetPaymentsByUserResponse = {
1855
+ encode(message, writer = new wire_1.BinaryWriter()) {
1856
+ for (const v of message.payments) {
1857
+ exports.Payment.encode(v, writer.uint32(10).fork()).join();
1858
+ }
1859
+ if (message.total !== 0) {
1860
+ writer.uint32(16).int32(message.total);
1861
+ }
1862
+ return writer;
1863
+ },
1864
+ decode(input, length) {
1865
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1866
+ const end = length === undefined ? reader.len : reader.pos + length;
1867
+ const message = createBaseGetPaymentsByUserResponse();
1868
+ while (reader.pos < end) {
1869
+ const tag = reader.uint32();
1870
+ switch (tag >>> 3) {
1871
+ case 1: {
1872
+ if (tag !== 10) {
1873
+ break;
1874
+ }
1875
+ message.payments.push(exports.Payment.decode(reader, reader.uint32()));
1876
+ continue;
1877
+ }
1878
+ case 2: {
1879
+ if (tag !== 16) {
1880
+ break;
1881
+ }
1882
+ message.total = reader.int32();
1883
+ continue;
1884
+ }
1885
+ }
1886
+ if ((tag & 7) === 4 || tag === 0) {
1887
+ break;
1888
+ }
1889
+ reader.skip(tag & 7);
1890
+ }
1891
+ return message;
1892
+ },
1893
+ };
1894
+ function createBaseProcessWebhookResponse() {
1895
+ return { success: false, message: "" };
1896
+ }
1897
+ exports.ProcessWebhookResponse = {
1898
+ encode(message, writer = new wire_1.BinaryWriter()) {
1899
+ if (message.success !== false) {
1900
+ writer.uint32(8).bool(message.success);
1901
+ }
1902
+ if (message.message !== "") {
1903
+ writer.uint32(18).string(message.message);
1904
+ }
1905
+ return writer;
1906
+ },
1907
+ decode(input, length) {
1908
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1909
+ const end = length === undefined ? reader.len : reader.pos + length;
1910
+ const message = createBaseProcessWebhookResponse();
1911
+ while (reader.pos < end) {
1912
+ const tag = reader.uint32();
1913
+ switch (tag >>> 3) {
1914
+ case 1: {
1915
+ if (tag !== 8) {
1916
+ break;
1917
+ }
1918
+ message.success = reader.bool();
1919
+ continue;
1920
+ }
1921
+ case 2: {
1922
+ if (tag !== 18) {
1923
+ break;
1924
+ }
1925
+ message.message = reader.string();
1926
+ continue;
1927
+ }
1928
+ }
1929
+ if ((tag & 7) === 4 || tag === 0) {
1930
+ break;
1931
+ }
1932
+ reader.skip(tag & 7);
1933
+ }
1934
+ return message;
1935
+ },
1936
+ };
1937
+ function BillingServiceControllerMethods() {
1938
+ return function (constructor) {
1939
+ const grpcMethods = [
1940
+ "getBalance",
1941
+ "charge",
1942
+ "deposit",
1943
+ "createTransaction",
1944
+ "getTransactions",
1945
+ "getTransaction",
1946
+ "recordUsage",
1947
+ "getUsageStats",
1948
+ "getUsageByKey",
1949
+ "getUsageByUser",
1950
+ "createPayment",
1951
+ "getPayment",
1952
+ "getPaymentsByUser",
1953
+ ];
1954
+ for (const method of grpcMethods) {
1955
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
1956
+ (0, microservices_1.GrpcMethod)("BillingService", method)(constructor.prototype[method], method, descriptor);
1957
+ }
1958
+ const grpcStreamMethods = [];
1959
+ for (const method of grpcStreamMethods) {
1960
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
1961
+ (0, microservices_1.GrpcStreamMethod)("BillingService", method)(constructor.prototype[method], method, descriptor);
1962
+ }
1963
+ };
1964
+ }
1965
+ exports.BILLING_SERVICE_NAME = "BillingService";
1966
+ exports.BillingServiceService = {
1967
+ /** Balance operations */
1968
+ getBalance: {
1969
+ path: "/billing.BillingService/GetBalance",
1970
+ requestStream: false,
1971
+ responseStream: false,
1972
+ requestSerialize: (value) => Buffer.from(exports.GetBalanceRequest.encode(value).finish()),
1973
+ requestDeserialize: (value) => exports.GetBalanceRequest.decode(value),
1974
+ responseSerialize: (value) => Buffer.from(exports.GetBalanceResponse.encode(value).finish()),
1975
+ responseDeserialize: (value) => exports.GetBalanceResponse.decode(value),
1976
+ },
1977
+ charge: {
1978
+ path: "/billing.BillingService/Charge",
1979
+ requestStream: false,
1980
+ responseStream: false,
1981
+ requestSerialize: (value) => Buffer.from(exports.ChargeRequest.encode(value).finish()),
1982
+ requestDeserialize: (value) => exports.ChargeRequest.decode(value),
1983
+ responseSerialize: (value) => Buffer.from(exports.ChargeResponse.encode(value).finish()),
1984
+ responseDeserialize: (value) => exports.ChargeResponse.decode(value),
1985
+ },
1986
+ deposit: {
1987
+ path: "/billing.BillingService/Deposit",
1988
+ requestStream: false,
1989
+ responseStream: false,
1990
+ requestSerialize: (value) => Buffer.from(exports.DepositRequest.encode(value).finish()),
1991
+ requestDeserialize: (value) => exports.DepositRequest.decode(value),
1992
+ responseSerialize: (value) => Buffer.from(exports.DepositResponse.encode(value).finish()),
1993
+ responseDeserialize: (value) => exports.DepositResponse.decode(value),
1994
+ },
1995
+ /** Transaction operations */
1996
+ createTransaction: {
1997
+ path: "/billing.BillingService/CreateTransaction",
1998
+ requestStream: false,
1999
+ responseStream: false,
2000
+ requestSerialize: (value) => Buffer.from(exports.CreateTransactionRequest.encode(value).finish()),
2001
+ requestDeserialize: (value) => exports.CreateTransactionRequest.decode(value),
2002
+ responseSerialize: (value) => Buffer.from(exports.CreateTransactionResponse.encode(value).finish()),
2003
+ responseDeserialize: (value) => exports.CreateTransactionResponse.decode(value),
2004
+ },
2005
+ getTransactions: {
2006
+ path: "/billing.BillingService/GetTransactions",
2007
+ requestStream: false,
2008
+ responseStream: false,
2009
+ requestSerialize: (value) => Buffer.from(exports.GetTransactionsRequest.encode(value).finish()),
2010
+ requestDeserialize: (value) => exports.GetTransactionsRequest.decode(value),
2011
+ responseSerialize: (value) => Buffer.from(exports.GetTransactionsResponse.encode(value).finish()),
2012
+ responseDeserialize: (value) => exports.GetTransactionsResponse.decode(value),
2013
+ },
2014
+ getTransaction: {
2015
+ path: "/billing.BillingService/GetTransaction",
2016
+ requestStream: false,
2017
+ responseStream: false,
2018
+ requestSerialize: (value) => Buffer.from(exports.GetTransactionRequest.encode(value).finish()),
2019
+ requestDeserialize: (value) => exports.GetTransactionRequest.decode(value),
2020
+ responseSerialize: (value) => Buffer.from(exports.GetTransactionResponse.encode(value).finish()),
2021
+ responseDeserialize: (value) => exports.GetTransactionResponse.decode(value),
2022
+ },
2023
+ /** Usage operations */
2024
+ recordUsage: {
2025
+ path: "/billing.BillingService/RecordUsage",
2026
+ requestStream: false,
2027
+ responseStream: false,
2028
+ requestSerialize: (value) => Buffer.from(exports.RecordUsageRequest.encode(value).finish()),
2029
+ requestDeserialize: (value) => exports.RecordUsageRequest.decode(value),
2030
+ responseSerialize: (value) => Buffer.from(exports.RecordUsageResponse.encode(value).finish()),
2031
+ responseDeserialize: (value) => exports.RecordUsageResponse.decode(value),
2032
+ },
2033
+ getUsageStats: {
2034
+ path: "/billing.BillingService/GetUsageStats",
2035
+ requestStream: false,
2036
+ responseStream: false,
2037
+ requestSerialize: (value) => Buffer.from(exports.GetUsageStatsRequest.encode(value).finish()),
2038
+ requestDeserialize: (value) => exports.GetUsageStatsRequest.decode(value),
2039
+ responseSerialize: (value) => Buffer.from(exports.GetUsageStatsResponse.encode(value).finish()),
2040
+ responseDeserialize: (value) => exports.GetUsageStatsResponse.decode(value),
2041
+ },
2042
+ getUsageByKey: {
2043
+ path: "/billing.BillingService/GetUsageByKey",
2044
+ requestStream: false,
2045
+ responseStream: false,
2046
+ requestSerialize: (value) => Buffer.from(exports.GetUsageByKeyRequest.encode(value).finish()),
2047
+ requestDeserialize: (value) => exports.GetUsageByKeyRequest.decode(value),
2048
+ responseSerialize: (value) => Buffer.from(exports.GetUsageByKeyResponse.encode(value).finish()),
2049
+ responseDeserialize: (value) => exports.GetUsageByKeyResponse.decode(value),
2050
+ },
2051
+ getUsageByUser: {
2052
+ path: "/billing.BillingService/GetUsageByUser",
2053
+ requestStream: false,
2054
+ responseStream: false,
2055
+ requestSerialize: (value) => Buffer.from(exports.GetUsageByUserRequest.encode(value).finish()),
2056
+ requestDeserialize: (value) => exports.GetUsageByUserRequest.decode(value),
2057
+ responseSerialize: (value) => Buffer.from(exports.GetUsageByUserResponse.encode(value).finish()),
2058
+ responseDeserialize: (value) => exports.GetUsageByUserResponse.decode(value),
2059
+ },
2060
+ /** Payment operations */
2061
+ createPayment: {
2062
+ path: "/billing.BillingService/CreatePayment",
2063
+ requestStream: false,
2064
+ responseStream: false,
2065
+ requestSerialize: (value) => Buffer.from(exports.CreatePaymentRequest.encode(value).finish()),
2066
+ requestDeserialize: (value) => exports.CreatePaymentRequest.decode(value),
2067
+ responseSerialize: (value) => Buffer.from(exports.CreatePaymentResponse.encode(value).finish()),
2068
+ responseDeserialize: (value) => exports.CreatePaymentResponse.decode(value),
2069
+ },
2070
+ getPayment: {
2071
+ path: "/billing.BillingService/GetPayment",
2072
+ requestStream: false,
2073
+ responseStream: false,
2074
+ requestSerialize: (value) => Buffer.from(exports.GetPaymentRequest.encode(value).finish()),
2075
+ requestDeserialize: (value) => exports.GetPaymentRequest.decode(value),
2076
+ responseSerialize: (value) => Buffer.from(exports.GetPaymentResponse.encode(value).finish()),
2077
+ responseDeserialize: (value) => exports.GetPaymentResponse.decode(value),
2078
+ },
2079
+ getPaymentsByUser: {
2080
+ path: "/billing.BillingService/GetPaymentsByUser",
2081
+ requestStream: false,
2082
+ responseStream: false,
2083
+ requestSerialize: (value) => Buffer.from(exports.GetPaymentsByUserRequest.encode(value).finish()),
2084
+ requestDeserialize: (value) => exports.GetPaymentsByUserRequest.decode(value),
2085
+ responseSerialize: (value) => Buffer.from(exports.GetPaymentsByUserResponse.encode(value).finish()),
2086
+ responseDeserialize: (value) => exports.GetPaymentsByUserResponse.decode(value),
2087
+ },
2088
+ };