weave-typescript 0.4.5 → 0.5.1

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,4153 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.6.1
5
+ // protoc unknown
6
+ // source: weaveapi/payment/v1/service.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.PaymentClient = exports.PaymentService = exports.DownloadInvoiceResponse = exports.DownloadInvoiceRequest = exports.TaxInfo = exports.UpdateTaxInfoResponse = exports.UpdateTaxInfoRequest = exports.CreditTransaction = exports.GetCreditBalanceResponse = exports.GetCreditBalanceRequest = exports.UsageLimits = exports.UsagePeriod_RequestsByApiKeyEntry = exports.UsagePeriod_RequestsByEndpointEntry = exports.UsagePeriod = exports.GetUsageSummaryResponse = exports.GetUsageSummaryRequest = exports.HandleStripeWebhookResponse = exports.HandleStripeWebhookRequest = exports.ApplyPromoCodeResponse = exports.ApplyPromoCodeRequest = exports.GetPricingPlansResponse = exports.GetPricingPlansRequest = exports.CreatePortalSessionResponse = exports.CreatePortalSessionRequest = exports.RemovePaymentMethodResponse = exports.RemovePaymentMethodRequest = exports.SetDefaultPaymentMethodResponse = exports.SetDefaultPaymentMethodRequest = exports.AddPaymentMethodResponse = exports.AddPaymentMethodRequest = exports.ListPaymentMethodsResponse = exports.ListPaymentMethodsRequest = exports.GetUpcomingInvoiceResponse = exports.GetUpcomingInvoiceRequest = exports.GetBillingHistoryResponse = exports.GetBillingHistoryRequest = exports.ResumeSubscriptionResponse = exports.ResumeSubscriptionRequest = exports.CancelSubscriptionResponse = exports.CancelSubscriptionRequest = exports.UpdateSubscriptionResponse = exports.UpdateSubscriptionRequest_MetadataEntry = exports.UpdateSubscriptionRequest = exports.GetSubscriptionStatusResponse = exports.GetSubscriptionStatusRequest = exports.CreateCheckoutSessionResponse = exports.CreateCheckoutSessionRequest_MetadataEntry = exports.CreateCheckoutSessionRequest = exports.protobufPackage = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ const grpc_js_1 = require("@grpc/grpc-js");
12
+ const timestamp_pb_1 = require("../../../google/protobuf/timestamp.pb");
13
+ const invoice_pb_1 = require("./invoice.pb");
14
+ const subscription_pb_1 = require("./subscription.pb");
15
+ exports.protobufPackage = "weaveapi.payment.v1";
16
+ function createBaseCreateCheckoutSessionRequest() {
17
+ return {
18
+ priceId: "",
19
+ successUrl: "",
20
+ cancelUrl: "",
21
+ promoCode: "",
22
+ allowPromotionCodes: false,
23
+ trialDays: 0,
24
+ metadata: {},
25
+ customerEmail: "",
26
+ automaticTax: false,
27
+ taxIdCollection: [],
28
+ };
29
+ }
30
+ exports.CreateCheckoutSessionRequest = {
31
+ encode(message, writer = new wire_1.BinaryWriter()) {
32
+ if (message.priceId !== "") {
33
+ writer.uint32(10).string(message.priceId);
34
+ }
35
+ if (message.successUrl !== "") {
36
+ writer.uint32(18).string(message.successUrl);
37
+ }
38
+ if (message.cancelUrl !== "") {
39
+ writer.uint32(26).string(message.cancelUrl);
40
+ }
41
+ if (message.promoCode !== "") {
42
+ writer.uint32(34).string(message.promoCode);
43
+ }
44
+ if (message.allowPromotionCodes !== false) {
45
+ writer.uint32(40).bool(message.allowPromotionCodes);
46
+ }
47
+ if (message.trialDays !== 0) {
48
+ writer.uint32(48).int32(message.trialDays);
49
+ }
50
+ Object.entries(message.metadata).forEach(([key, value]) => {
51
+ exports.CreateCheckoutSessionRequest_MetadataEntry.encode({ key: key, value }, writer.uint32(58).fork()).join();
52
+ });
53
+ if (message.customerEmail !== "") {
54
+ writer.uint32(66).string(message.customerEmail);
55
+ }
56
+ if (message.automaticTax !== false) {
57
+ writer.uint32(72).bool(message.automaticTax);
58
+ }
59
+ for (const v of message.taxIdCollection) {
60
+ writer.uint32(82).string(v);
61
+ }
62
+ return writer;
63
+ },
64
+ decode(input, length) {
65
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
66
+ let end = length === undefined ? reader.len : reader.pos + length;
67
+ const message = createBaseCreateCheckoutSessionRequest();
68
+ while (reader.pos < end) {
69
+ const tag = reader.uint32();
70
+ switch (tag >>> 3) {
71
+ case 1: {
72
+ if (tag !== 10) {
73
+ break;
74
+ }
75
+ message.priceId = reader.string();
76
+ continue;
77
+ }
78
+ case 2: {
79
+ if (tag !== 18) {
80
+ break;
81
+ }
82
+ message.successUrl = reader.string();
83
+ continue;
84
+ }
85
+ case 3: {
86
+ if (tag !== 26) {
87
+ break;
88
+ }
89
+ message.cancelUrl = reader.string();
90
+ continue;
91
+ }
92
+ case 4: {
93
+ if (tag !== 34) {
94
+ break;
95
+ }
96
+ message.promoCode = reader.string();
97
+ continue;
98
+ }
99
+ case 5: {
100
+ if (tag !== 40) {
101
+ break;
102
+ }
103
+ message.allowPromotionCodes = reader.bool();
104
+ continue;
105
+ }
106
+ case 6: {
107
+ if (tag !== 48) {
108
+ break;
109
+ }
110
+ message.trialDays = reader.int32();
111
+ continue;
112
+ }
113
+ case 7: {
114
+ if (tag !== 58) {
115
+ break;
116
+ }
117
+ const entry7 = exports.CreateCheckoutSessionRequest_MetadataEntry.decode(reader, reader.uint32());
118
+ if (entry7.value !== undefined) {
119
+ message.metadata[entry7.key] = entry7.value;
120
+ }
121
+ continue;
122
+ }
123
+ case 8: {
124
+ if (tag !== 66) {
125
+ break;
126
+ }
127
+ message.customerEmail = reader.string();
128
+ continue;
129
+ }
130
+ case 9: {
131
+ if (tag !== 72) {
132
+ break;
133
+ }
134
+ message.automaticTax = reader.bool();
135
+ continue;
136
+ }
137
+ case 10: {
138
+ if (tag !== 82) {
139
+ break;
140
+ }
141
+ message.taxIdCollection.push(reader.string());
142
+ continue;
143
+ }
144
+ }
145
+ if ((tag & 7) === 4 || tag === 0) {
146
+ break;
147
+ }
148
+ reader.skip(tag & 7);
149
+ }
150
+ return message;
151
+ },
152
+ fromJSON(object) {
153
+ return {
154
+ priceId: isSet(object.priceId) ? globalThis.String(object.priceId) : "",
155
+ successUrl: isSet(object.successUrl) ? globalThis.String(object.successUrl) : "",
156
+ cancelUrl: isSet(object.cancelUrl) ? globalThis.String(object.cancelUrl) : "",
157
+ promoCode: isSet(object.promoCode) ? globalThis.String(object.promoCode) : "",
158
+ allowPromotionCodes: isSet(object.allowPromotionCodes) ? globalThis.Boolean(object.allowPromotionCodes) : false,
159
+ trialDays: isSet(object.trialDays) ? globalThis.Number(object.trialDays) : 0,
160
+ metadata: isObject(object.metadata)
161
+ ? Object.entries(object.metadata).reduce((acc, [key, value]) => {
162
+ acc[key] = String(value);
163
+ return acc;
164
+ }, {})
165
+ : {},
166
+ customerEmail: isSet(object.customerEmail) ? globalThis.String(object.customerEmail) : "",
167
+ automaticTax: isSet(object.automaticTax) ? globalThis.Boolean(object.automaticTax) : false,
168
+ taxIdCollection: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.taxIdCollection)
169
+ ? object.taxIdCollection.map((e) => globalThis.String(e))
170
+ : [],
171
+ };
172
+ },
173
+ toJSON(message) {
174
+ var _a;
175
+ const obj = {};
176
+ if (message.priceId !== "") {
177
+ obj.priceId = message.priceId;
178
+ }
179
+ if (message.successUrl !== "") {
180
+ obj.successUrl = message.successUrl;
181
+ }
182
+ if (message.cancelUrl !== "") {
183
+ obj.cancelUrl = message.cancelUrl;
184
+ }
185
+ if (message.promoCode !== "") {
186
+ obj.promoCode = message.promoCode;
187
+ }
188
+ if (message.allowPromotionCodes !== false) {
189
+ obj.allowPromotionCodes = message.allowPromotionCodes;
190
+ }
191
+ if (message.trialDays !== 0) {
192
+ obj.trialDays = Math.round(message.trialDays);
193
+ }
194
+ if (message.metadata) {
195
+ const entries = Object.entries(message.metadata);
196
+ if (entries.length > 0) {
197
+ obj.metadata = {};
198
+ entries.forEach(([k, v]) => {
199
+ obj.metadata[k] = v;
200
+ });
201
+ }
202
+ }
203
+ if (message.customerEmail !== "") {
204
+ obj.customerEmail = message.customerEmail;
205
+ }
206
+ if (message.automaticTax !== false) {
207
+ obj.automaticTax = message.automaticTax;
208
+ }
209
+ if ((_a = message.taxIdCollection) === null || _a === void 0 ? void 0 : _a.length) {
210
+ obj.taxIdCollection = message.taxIdCollection;
211
+ }
212
+ return obj;
213
+ },
214
+ create(base) {
215
+ return exports.CreateCheckoutSessionRequest.fromPartial(base !== null && base !== void 0 ? base : {});
216
+ },
217
+ fromPartial(object) {
218
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
219
+ const message = createBaseCreateCheckoutSessionRequest();
220
+ message.priceId = (_a = object.priceId) !== null && _a !== void 0 ? _a : "";
221
+ message.successUrl = (_b = object.successUrl) !== null && _b !== void 0 ? _b : "";
222
+ message.cancelUrl = (_c = object.cancelUrl) !== null && _c !== void 0 ? _c : "";
223
+ message.promoCode = (_d = object.promoCode) !== null && _d !== void 0 ? _d : "";
224
+ message.allowPromotionCodes = (_e = object.allowPromotionCodes) !== null && _e !== void 0 ? _e : false;
225
+ message.trialDays = (_f = object.trialDays) !== null && _f !== void 0 ? _f : 0;
226
+ message.metadata = Object.entries((_g = object.metadata) !== null && _g !== void 0 ? _g : {}).reduce((acc, [key, value]) => {
227
+ if (value !== undefined) {
228
+ acc[key] = globalThis.String(value);
229
+ }
230
+ return acc;
231
+ }, {});
232
+ message.customerEmail = (_h = object.customerEmail) !== null && _h !== void 0 ? _h : "";
233
+ message.automaticTax = (_j = object.automaticTax) !== null && _j !== void 0 ? _j : false;
234
+ message.taxIdCollection = ((_k = object.taxIdCollection) === null || _k === void 0 ? void 0 : _k.map((e) => e)) || [];
235
+ return message;
236
+ },
237
+ };
238
+ function createBaseCreateCheckoutSessionRequest_MetadataEntry() {
239
+ return { key: "", value: "" };
240
+ }
241
+ exports.CreateCheckoutSessionRequest_MetadataEntry = {
242
+ encode(message, writer = new wire_1.BinaryWriter()) {
243
+ if (message.key !== "") {
244
+ writer.uint32(10).string(message.key);
245
+ }
246
+ if (message.value !== "") {
247
+ writer.uint32(18).string(message.value);
248
+ }
249
+ return writer;
250
+ },
251
+ decode(input, length) {
252
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
253
+ let end = length === undefined ? reader.len : reader.pos + length;
254
+ const message = createBaseCreateCheckoutSessionRequest_MetadataEntry();
255
+ while (reader.pos < end) {
256
+ const tag = reader.uint32();
257
+ switch (tag >>> 3) {
258
+ case 1: {
259
+ if (tag !== 10) {
260
+ break;
261
+ }
262
+ message.key = reader.string();
263
+ continue;
264
+ }
265
+ case 2: {
266
+ if (tag !== 18) {
267
+ break;
268
+ }
269
+ message.value = reader.string();
270
+ continue;
271
+ }
272
+ }
273
+ if ((tag & 7) === 4 || tag === 0) {
274
+ break;
275
+ }
276
+ reader.skip(tag & 7);
277
+ }
278
+ return message;
279
+ },
280
+ fromJSON(object) {
281
+ return {
282
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
283
+ value: isSet(object.value) ? globalThis.String(object.value) : "",
284
+ };
285
+ },
286
+ toJSON(message) {
287
+ const obj = {};
288
+ if (message.key !== "") {
289
+ obj.key = message.key;
290
+ }
291
+ if (message.value !== "") {
292
+ obj.value = message.value;
293
+ }
294
+ return obj;
295
+ },
296
+ create(base) {
297
+ return exports.CreateCheckoutSessionRequest_MetadataEntry.fromPartial(base !== null && base !== void 0 ? base : {});
298
+ },
299
+ fromPartial(object) {
300
+ var _a, _b;
301
+ const message = createBaseCreateCheckoutSessionRequest_MetadataEntry();
302
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
303
+ message.value = (_b = object.value) !== null && _b !== void 0 ? _b : "";
304
+ return message;
305
+ },
306
+ };
307
+ function createBaseCreateCheckoutSessionResponse() {
308
+ return { sessionId: "", checkoutUrl: "", expiresAt: undefined };
309
+ }
310
+ exports.CreateCheckoutSessionResponse = {
311
+ encode(message, writer = new wire_1.BinaryWriter()) {
312
+ if (message.sessionId !== "") {
313
+ writer.uint32(10).string(message.sessionId);
314
+ }
315
+ if (message.checkoutUrl !== "") {
316
+ writer.uint32(18).string(message.checkoutUrl);
317
+ }
318
+ if (message.expiresAt !== undefined) {
319
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(26).fork()).join();
320
+ }
321
+ return writer;
322
+ },
323
+ decode(input, length) {
324
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
325
+ let end = length === undefined ? reader.len : reader.pos + length;
326
+ const message = createBaseCreateCheckoutSessionResponse();
327
+ while (reader.pos < end) {
328
+ const tag = reader.uint32();
329
+ switch (tag >>> 3) {
330
+ case 1: {
331
+ if (tag !== 10) {
332
+ break;
333
+ }
334
+ message.sessionId = reader.string();
335
+ continue;
336
+ }
337
+ case 2: {
338
+ if (tag !== 18) {
339
+ break;
340
+ }
341
+ message.checkoutUrl = reader.string();
342
+ continue;
343
+ }
344
+ case 3: {
345
+ if (tag !== 26) {
346
+ break;
347
+ }
348
+ message.expiresAt = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
349
+ continue;
350
+ }
351
+ }
352
+ if ((tag & 7) === 4 || tag === 0) {
353
+ break;
354
+ }
355
+ reader.skip(tag & 7);
356
+ }
357
+ return message;
358
+ },
359
+ fromJSON(object) {
360
+ return {
361
+ sessionId: isSet(object.sessionId) ? globalThis.String(object.sessionId) : "",
362
+ checkoutUrl: isSet(object.checkoutUrl) ? globalThis.String(object.checkoutUrl) : "",
363
+ expiresAt: isSet(object.expiresAt) ? fromJsonTimestamp(object.expiresAt) : undefined,
364
+ };
365
+ },
366
+ toJSON(message) {
367
+ const obj = {};
368
+ if (message.sessionId !== "") {
369
+ obj.sessionId = message.sessionId;
370
+ }
371
+ if (message.checkoutUrl !== "") {
372
+ obj.checkoutUrl = message.checkoutUrl;
373
+ }
374
+ if (message.expiresAt !== undefined) {
375
+ obj.expiresAt = message.expiresAt.toISOString();
376
+ }
377
+ return obj;
378
+ },
379
+ create(base) {
380
+ return exports.CreateCheckoutSessionResponse.fromPartial(base !== null && base !== void 0 ? base : {});
381
+ },
382
+ fromPartial(object) {
383
+ var _a, _b, _c;
384
+ const message = createBaseCreateCheckoutSessionResponse();
385
+ message.sessionId = (_a = object.sessionId) !== null && _a !== void 0 ? _a : "";
386
+ message.checkoutUrl = (_b = object.checkoutUrl) !== null && _b !== void 0 ? _b : "";
387
+ message.expiresAt = (_c = object.expiresAt) !== null && _c !== void 0 ? _c : undefined;
388
+ return message;
389
+ },
390
+ };
391
+ function createBaseGetSubscriptionStatusRequest() {
392
+ return {};
393
+ }
394
+ exports.GetSubscriptionStatusRequest = {
395
+ encode(_, writer = new wire_1.BinaryWriter()) {
396
+ return writer;
397
+ },
398
+ decode(input, length) {
399
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
400
+ let end = length === undefined ? reader.len : reader.pos + length;
401
+ const message = createBaseGetSubscriptionStatusRequest();
402
+ while (reader.pos < end) {
403
+ const tag = reader.uint32();
404
+ switch (tag >>> 3) {
405
+ }
406
+ if ((tag & 7) === 4 || tag === 0) {
407
+ break;
408
+ }
409
+ reader.skip(tag & 7);
410
+ }
411
+ return message;
412
+ },
413
+ fromJSON(_) {
414
+ return {};
415
+ },
416
+ toJSON(_) {
417
+ const obj = {};
418
+ return obj;
419
+ },
420
+ create(base) {
421
+ return exports.GetSubscriptionStatusRequest.fromPartial(base !== null && base !== void 0 ? base : {});
422
+ },
423
+ fromPartial(_) {
424
+ const message = createBaseGetSubscriptionStatusRequest();
425
+ return message;
426
+ },
427
+ };
428
+ function createBaseGetSubscriptionStatusResponse() {
429
+ return { subscription: undefined };
430
+ }
431
+ exports.GetSubscriptionStatusResponse = {
432
+ encode(message, writer = new wire_1.BinaryWriter()) {
433
+ if (message.subscription !== undefined) {
434
+ subscription_pb_1.SubscriptionStatus.encode(message.subscription, writer.uint32(10).fork()).join();
435
+ }
436
+ return writer;
437
+ },
438
+ decode(input, length) {
439
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
440
+ let end = length === undefined ? reader.len : reader.pos + length;
441
+ const message = createBaseGetSubscriptionStatusResponse();
442
+ while (reader.pos < end) {
443
+ const tag = reader.uint32();
444
+ switch (tag >>> 3) {
445
+ case 1: {
446
+ if (tag !== 10) {
447
+ break;
448
+ }
449
+ message.subscription = subscription_pb_1.SubscriptionStatus.decode(reader, reader.uint32());
450
+ continue;
451
+ }
452
+ }
453
+ if ((tag & 7) === 4 || tag === 0) {
454
+ break;
455
+ }
456
+ reader.skip(tag & 7);
457
+ }
458
+ return message;
459
+ },
460
+ fromJSON(object) {
461
+ return { subscription: isSet(object.subscription) ? subscription_pb_1.SubscriptionStatus.fromJSON(object.subscription) : undefined };
462
+ },
463
+ toJSON(message) {
464
+ const obj = {};
465
+ if (message.subscription !== undefined) {
466
+ obj.subscription = subscription_pb_1.SubscriptionStatus.toJSON(message.subscription);
467
+ }
468
+ return obj;
469
+ },
470
+ create(base) {
471
+ return exports.GetSubscriptionStatusResponse.fromPartial(base !== null && base !== void 0 ? base : {});
472
+ },
473
+ fromPartial(object) {
474
+ const message = createBaseGetSubscriptionStatusResponse();
475
+ message.subscription = (object.subscription !== undefined && object.subscription !== null)
476
+ ? subscription_pb_1.SubscriptionStatus.fromPartial(object.subscription)
477
+ : undefined;
478
+ return message;
479
+ },
480
+ };
481
+ function createBaseUpdateSubscriptionRequest() {
482
+ return { paymentMethodId: "", promoCode: "", cancelAtPeriodEnd: false, metadata: {} };
483
+ }
484
+ exports.UpdateSubscriptionRequest = {
485
+ encode(message, writer = new wire_1.BinaryWriter()) {
486
+ if (message.paymentMethodId !== "") {
487
+ writer.uint32(10).string(message.paymentMethodId);
488
+ }
489
+ if (message.promoCode !== "") {
490
+ writer.uint32(18).string(message.promoCode);
491
+ }
492
+ if (message.cancelAtPeriodEnd !== false) {
493
+ writer.uint32(24).bool(message.cancelAtPeriodEnd);
494
+ }
495
+ Object.entries(message.metadata).forEach(([key, value]) => {
496
+ exports.UpdateSubscriptionRequest_MetadataEntry.encode({ key: key, value }, writer.uint32(34).fork()).join();
497
+ });
498
+ return writer;
499
+ },
500
+ decode(input, length) {
501
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
502
+ let end = length === undefined ? reader.len : reader.pos + length;
503
+ const message = createBaseUpdateSubscriptionRequest();
504
+ while (reader.pos < end) {
505
+ const tag = reader.uint32();
506
+ switch (tag >>> 3) {
507
+ case 1: {
508
+ if (tag !== 10) {
509
+ break;
510
+ }
511
+ message.paymentMethodId = reader.string();
512
+ continue;
513
+ }
514
+ case 2: {
515
+ if (tag !== 18) {
516
+ break;
517
+ }
518
+ message.promoCode = reader.string();
519
+ continue;
520
+ }
521
+ case 3: {
522
+ if (tag !== 24) {
523
+ break;
524
+ }
525
+ message.cancelAtPeriodEnd = reader.bool();
526
+ continue;
527
+ }
528
+ case 4: {
529
+ if (tag !== 34) {
530
+ break;
531
+ }
532
+ const entry4 = exports.UpdateSubscriptionRequest_MetadataEntry.decode(reader, reader.uint32());
533
+ if (entry4.value !== undefined) {
534
+ message.metadata[entry4.key] = entry4.value;
535
+ }
536
+ continue;
537
+ }
538
+ }
539
+ if ((tag & 7) === 4 || tag === 0) {
540
+ break;
541
+ }
542
+ reader.skip(tag & 7);
543
+ }
544
+ return message;
545
+ },
546
+ fromJSON(object) {
547
+ return {
548
+ paymentMethodId: isSet(object.paymentMethodId) ? globalThis.String(object.paymentMethodId) : "",
549
+ promoCode: isSet(object.promoCode) ? globalThis.String(object.promoCode) : "",
550
+ cancelAtPeriodEnd: isSet(object.cancelAtPeriodEnd) ? globalThis.Boolean(object.cancelAtPeriodEnd) : false,
551
+ metadata: isObject(object.metadata)
552
+ ? Object.entries(object.metadata).reduce((acc, [key, value]) => {
553
+ acc[key] = String(value);
554
+ return acc;
555
+ }, {})
556
+ : {},
557
+ };
558
+ },
559
+ toJSON(message) {
560
+ const obj = {};
561
+ if (message.paymentMethodId !== "") {
562
+ obj.paymentMethodId = message.paymentMethodId;
563
+ }
564
+ if (message.promoCode !== "") {
565
+ obj.promoCode = message.promoCode;
566
+ }
567
+ if (message.cancelAtPeriodEnd !== false) {
568
+ obj.cancelAtPeriodEnd = message.cancelAtPeriodEnd;
569
+ }
570
+ if (message.metadata) {
571
+ const entries = Object.entries(message.metadata);
572
+ if (entries.length > 0) {
573
+ obj.metadata = {};
574
+ entries.forEach(([k, v]) => {
575
+ obj.metadata[k] = v;
576
+ });
577
+ }
578
+ }
579
+ return obj;
580
+ },
581
+ create(base) {
582
+ return exports.UpdateSubscriptionRequest.fromPartial(base !== null && base !== void 0 ? base : {});
583
+ },
584
+ fromPartial(object) {
585
+ var _a, _b, _c, _d;
586
+ const message = createBaseUpdateSubscriptionRequest();
587
+ message.paymentMethodId = (_a = object.paymentMethodId) !== null && _a !== void 0 ? _a : "";
588
+ message.promoCode = (_b = object.promoCode) !== null && _b !== void 0 ? _b : "";
589
+ message.cancelAtPeriodEnd = (_c = object.cancelAtPeriodEnd) !== null && _c !== void 0 ? _c : false;
590
+ message.metadata = Object.entries((_d = object.metadata) !== null && _d !== void 0 ? _d : {}).reduce((acc, [key, value]) => {
591
+ if (value !== undefined) {
592
+ acc[key] = globalThis.String(value);
593
+ }
594
+ return acc;
595
+ }, {});
596
+ return message;
597
+ },
598
+ };
599
+ function createBaseUpdateSubscriptionRequest_MetadataEntry() {
600
+ return { key: "", value: "" };
601
+ }
602
+ exports.UpdateSubscriptionRequest_MetadataEntry = {
603
+ encode(message, writer = new wire_1.BinaryWriter()) {
604
+ if (message.key !== "") {
605
+ writer.uint32(10).string(message.key);
606
+ }
607
+ if (message.value !== "") {
608
+ writer.uint32(18).string(message.value);
609
+ }
610
+ return writer;
611
+ },
612
+ decode(input, length) {
613
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
614
+ let end = length === undefined ? reader.len : reader.pos + length;
615
+ const message = createBaseUpdateSubscriptionRequest_MetadataEntry();
616
+ while (reader.pos < end) {
617
+ const tag = reader.uint32();
618
+ switch (tag >>> 3) {
619
+ case 1: {
620
+ if (tag !== 10) {
621
+ break;
622
+ }
623
+ message.key = reader.string();
624
+ continue;
625
+ }
626
+ case 2: {
627
+ if (tag !== 18) {
628
+ break;
629
+ }
630
+ message.value = reader.string();
631
+ continue;
632
+ }
633
+ }
634
+ if ((tag & 7) === 4 || tag === 0) {
635
+ break;
636
+ }
637
+ reader.skip(tag & 7);
638
+ }
639
+ return message;
640
+ },
641
+ fromJSON(object) {
642
+ return {
643
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
644
+ value: isSet(object.value) ? globalThis.String(object.value) : "",
645
+ };
646
+ },
647
+ toJSON(message) {
648
+ const obj = {};
649
+ if (message.key !== "") {
650
+ obj.key = message.key;
651
+ }
652
+ if (message.value !== "") {
653
+ obj.value = message.value;
654
+ }
655
+ return obj;
656
+ },
657
+ create(base) {
658
+ return exports.UpdateSubscriptionRequest_MetadataEntry.fromPartial(base !== null && base !== void 0 ? base : {});
659
+ },
660
+ fromPartial(object) {
661
+ var _a, _b;
662
+ const message = createBaseUpdateSubscriptionRequest_MetadataEntry();
663
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
664
+ message.value = (_b = object.value) !== null && _b !== void 0 ? _b : "";
665
+ return message;
666
+ },
667
+ };
668
+ function createBaseUpdateSubscriptionResponse() {
669
+ return { subscription: undefined, message: "" };
670
+ }
671
+ exports.UpdateSubscriptionResponse = {
672
+ encode(message, writer = new wire_1.BinaryWriter()) {
673
+ if (message.subscription !== undefined) {
674
+ subscription_pb_1.SubscriptionStatus.encode(message.subscription, writer.uint32(10).fork()).join();
675
+ }
676
+ if (message.message !== "") {
677
+ writer.uint32(18).string(message.message);
678
+ }
679
+ return writer;
680
+ },
681
+ decode(input, length) {
682
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
683
+ let end = length === undefined ? reader.len : reader.pos + length;
684
+ const message = createBaseUpdateSubscriptionResponse();
685
+ while (reader.pos < end) {
686
+ const tag = reader.uint32();
687
+ switch (tag >>> 3) {
688
+ case 1: {
689
+ if (tag !== 10) {
690
+ break;
691
+ }
692
+ message.subscription = subscription_pb_1.SubscriptionStatus.decode(reader, reader.uint32());
693
+ continue;
694
+ }
695
+ case 2: {
696
+ if (tag !== 18) {
697
+ break;
698
+ }
699
+ message.message = reader.string();
700
+ continue;
701
+ }
702
+ }
703
+ if ((tag & 7) === 4 || tag === 0) {
704
+ break;
705
+ }
706
+ reader.skip(tag & 7);
707
+ }
708
+ return message;
709
+ },
710
+ fromJSON(object) {
711
+ return {
712
+ subscription: isSet(object.subscription) ? subscription_pb_1.SubscriptionStatus.fromJSON(object.subscription) : undefined,
713
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
714
+ };
715
+ },
716
+ toJSON(message) {
717
+ const obj = {};
718
+ if (message.subscription !== undefined) {
719
+ obj.subscription = subscription_pb_1.SubscriptionStatus.toJSON(message.subscription);
720
+ }
721
+ if (message.message !== "") {
722
+ obj.message = message.message;
723
+ }
724
+ return obj;
725
+ },
726
+ create(base) {
727
+ return exports.UpdateSubscriptionResponse.fromPartial(base !== null && base !== void 0 ? base : {});
728
+ },
729
+ fromPartial(object) {
730
+ var _a;
731
+ const message = createBaseUpdateSubscriptionResponse();
732
+ message.subscription = (object.subscription !== undefined && object.subscription !== null)
733
+ ? subscription_pb_1.SubscriptionStatus.fromPartial(object.subscription)
734
+ : undefined;
735
+ message.message = (_a = object.message) !== null && _a !== void 0 ? _a : "";
736
+ return message;
737
+ },
738
+ };
739
+ function createBaseCancelSubscriptionRequest() {
740
+ return { immediately: false, reason: "", feedback: "" };
741
+ }
742
+ exports.CancelSubscriptionRequest = {
743
+ encode(message, writer = new wire_1.BinaryWriter()) {
744
+ if (message.immediately !== false) {
745
+ writer.uint32(8).bool(message.immediately);
746
+ }
747
+ if (message.reason !== "") {
748
+ writer.uint32(18).string(message.reason);
749
+ }
750
+ if (message.feedback !== "") {
751
+ writer.uint32(26).string(message.feedback);
752
+ }
753
+ return writer;
754
+ },
755
+ decode(input, length) {
756
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
757
+ let end = length === undefined ? reader.len : reader.pos + length;
758
+ const message = createBaseCancelSubscriptionRequest();
759
+ while (reader.pos < end) {
760
+ const tag = reader.uint32();
761
+ switch (tag >>> 3) {
762
+ case 1: {
763
+ if (tag !== 8) {
764
+ break;
765
+ }
766
+ message.immediately = reader.bool();
767
+ continue;
768
+ }
769
+ case 2: {
770
+ if (tag !== 18) {
771
+ break;
772
+ }
773
+ message.reason = reader.string();
774
+ continue;
775
+ }
776
+ case 3: {
777
+ if (tag !== 26) {
778
+ break;
779
+ }
780
+ message.feedback = reader.string();
781
+ continue;
782
+ }
783
+ }
784
+ if ((tag & 7) === 4 || tag === 0) {
785
+ break;
786
+ }
787
+ reader.skip(tag & 7);
788
+ }
789
+ return message;
790
+ },
791
+ fromJSON(object) {
792
+ return {
793
+ immediately: isSet(object.immediately) ? globalThis.Boolean(object.immediately) : false,
794
+ reason: isSet(object.reason) ? globalThis.String(object.reason) : "",
795
+ feedback: isSet(object.feedback) ? globalThis.String(object.feedback) : "",
796
+ };
797
+ },
798
+ toJSON(message) {
799
+ const obj = {};
800
+ if (message.immediately !== false) {
801
+ obj.immediately = message.immediately;
802
+ }
803
+ if (message.reason !== "") {
804
+ obj.reason = message.reason;
805
+ }
806
+ if (message.feedback !== "") {
807
+ obj.feedback = message.feedback;
808
+ }
809
+ return obj;
810
+ },
811
+ create(base) {
812
+ return exports.CancelSubscriptionRequest.fromPartial(base !== null && base !== void 0 ? base : {});
813
+ },
814
+ fromPartial(object) {
815
+ var _a, _b, _c;
816
+ const message = createBaseCancelSubscriptionRequest();
817
+ message.immediately = (_a = object.immediately) !== null && _a !== void 0 ? _a : false;
818
+ message.reason = (_b = object.reason) !== null && _b !== void 0 ? _b : "";
819
+ message.feedback = (_c = object.feedback) !== null && _c !== void 0 ? _c : "";
820
+ return message;
821
+ },
822
+ };
823
+ function createBaseCancelSubscriptionResponse() {
824
+ return { subscription: undefined, effectiveDate: undefined, confirmation: "" };
825
+ }
826
+ exports.CancelSubscriptionResponse = {
827
+ encode(message, writer = new wire_1.BinaryWriter()) {
828
+ if (message.subscription !== undefined) {
829
+ subscription_pb_1.SubscriptionStatus.encode(message.subscription, writer.uint32(10).fork()).join();
830
+ }
831
+ if (message.effectiveDate !== undefined) {
832
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.effectiveDate), writer.uint32(18).fork()).join();
833
+ }
834
+ if (message.confirmation !== "") {
835
+ writer.uint32(26).string(message.confirmation);
836
+ }
837
+ return writer;
838
+ },
839
+ decode(input, length) {
840
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
841
+ let end = length === undefined ? reader.len : reader.pos + length;
842
+ const message = createBaseCancelSubscriptionResponse();
843
+ while (reader.pos < end) {
844
+ const tag = reader.uint32();
845
+ switch (tag >>> 3) {
846
+ case 1: {
847
+ if (tag !== 10) {
848
+ break;
849
+ }
850
+ message.subscription = subscription_pb_1.SubscriptionStatus.decode(reader, reader.uint32());
851
+ continue;
852
+ }
853
+ case 2: {
854
+ if (tag !== 18) {
855
+ break;
856
+ }
857
+ message.effectiveDate = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
858
+ continue;
859
+ }
860
+ case 3: {
861
+ if (tag !== 26) {
862
+ break;
863
+ }
864
+ message.confirmation = reader.string();
865
+ continue;
866
+ }
867
+ }
868
+ if ((tag & 7) === 4 || tag === 0) {
869
+ break;
870
+ }
871
+ reader.skip(tag & 7);
872
+ }
873
+ return message;
874
+ },
875
+ fromJSON(object) {
876
+ return {
877
+ subscription: isSet(object.subscription) ? subscription_pb_1.SubscriptionStatus.fromJSON(object.subscription) : undefined,
878
+ effectiveDate: isSet(object.effectiveDate) ? fromJsonTimestamp(object.effectiveDate) : undefined,
879
+ confirmation: isSet(object.confirmation) ? globalThis.String(object.confirmation) : "",
880
+ };
881
+ },
882
+ toJSON(message) {
883
+ const obj = {};
884
+ if (message.subscription !== undefined) {
885
+ obj.subscription = subscription_pb_1.SubscriptionStatus.toJSON(message.subscription);
886
+ }
887
+ if (message.effectiveDate !== undefined) {
888
+ obj.effectiveDate = message.effectiveDate.toISOString();
889
+ }
890
+ if (message.confirmation !== "") {
891
+ obj.confirmation = message.confirmation;
892
+ }
893
+ return obj;
894
+ },
895
+ create(base) {
896
+ return exports.CancelSubscriptionResponse.fromPartial(base !== null && base !== void 0 ? base : {});
897
+ },
898
+ fromPartial(object) {
899
+ var _a, _b;
900
+ const message = createBaseCancelSubscriptionResponse();
901
+ message.subscription = (object.subscription !== undefined && object.subscription !== null)
902
+ ? subscription_pb_1.SubscriptionStatus.fromPartial(object.subscription)
903
+ : undefined;
904
+ message.effectiveDate = (_a = object.effectiveDate) !== null && _a !== void 0 ? _a : undefined;
905
+ message.confirmation = (_b = object.confirmation) !== null && _b !== void 0 ? _b : "";
906
+ return message;
907
+ },
908
+ };
909
+ function createBaseResumeSubscriptionRequest() {
910
+ return {};
911
+ }
912
+ exports.ResumeSubscriptionRequest = {
913
+ encode(_, writer = new wire_1.BinaryWriter()) {
914
+ return writer;
915
+ },
916
+ decode(input, length) {
917
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
918
+ let end = length === undefined ? reader.len : reader.pos + length;
919
+ const message = createBaseResumeSubscriptionRequest();
920
+ while (reader.pos < end) {
921
+ const tag = reader.uint32();
922
+ switch (tag >>> 3) {
923
+ }
924
+ if ((tag & 7) === 4 || tag === 0) {
925
+ break;
926
+ }
927
+ reader.skip(tag & 7);
928
+ }
929
+ return message;
930
+ },
931
+ fromJSON(_) {
932
+ return {};
933
+ },
934
+ toJSON(_) {
935
+ const obj = {};
936
+ return obj;
937
+ },
938
+ create(base) {
939
+ return exports.ResumeSubscriptionRequest.fromPartial(base !== null && base !== void 0 ? base : {});
940
+ },
941
+ fromPartial(_) {
942
+ const message = createBaseResumeSubscriptionRequest();
943
+ return message;
944
+ },
945
+ };
946
+ function createBaseResumeSubscriptionResponse() {
947
+ return { subscription: undefined, message: "" };
948
+ }
949
+ exports.ResumeSubscriptionResponse = {
950
+ encode(message, writer = new wire_1.BinaryWriter()) {
951
+ if (message.subscription !== undefined) {
952
+ subscription_pb_1.SubscriptionStatus.encode(message.subscription, writer.uint32(10).fork()).join();
953
+ }
954
+ if (message.message !== "") {
955
+ writer.uint32(18).string(message.message);
956
+ }
957
+ return writer;
958
+ },
959
+ decode(input, length) {
960
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
961
+ let end = length === undefined ? reader.len : reader.pos + length;
962
+ const message = createBaseResumeSubscriptionResponse();
963
+ while (reader.pos < end) {
964
+ const tag = reader.uint32();
965
+ switch (tag >>> 3) {
966
+ case 1: {
967
+ if (tag !== 10) {
968
+ break;
969
+ }
970
+ message.subscription = subscription_pb_1.SubscriptionStatus.decode(reader, reader.uint32());
971
+ continue;
972
+ }
973
+ case 2: {
974
+ if (tag !== 18) {
975
+ break;
976
+ }
977
+ message.message = reader.string();
978
+ continue;
979
+ }
980
+ }
981
+ if ((tag & 7) === 4 || tag === 0) {
982
+ break;
983
+ }
984
+ reader.skip(tag & 7);
985
+ }
986
+ return message;
987
+ },
988
+ fromJSON(object) {
989
+ return {
990
+ subscription: isSet(object.subscription) ? subscription_pb_1.SubscriptionStatus.fromJSON(object.subscription) : undefined,
991
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
992
+ };
993
+ },
994
+ toJSON(message) {
995
+ const obj = {};
996
+ if (message.subscription !== undefined) {
997
+ obj.subscription = subscription_pb_1.SubscriptionStatus.toJSON(message.subscription);
998
+ }
999
+ if (message.message !== "") {
1000
+ obj.message = message.message;
1001
+ }
1002
+ return obj;
1003
+ },
1004
+ create(base) {
1005
+ return exports.ResumeSubscriptionResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1006
+ },
1007
+ fromPartial(object) {
1008
+ var _a;
1009
+ const message = createBaseResumeSubscriptionResponse();
1010
+ message.subscription = (object.subscription !== undefined && object.subscription !== null)
1011
+ ? subscription_pb_1.SubscriptionStatus.fromPartial(object.subscription)
1012
+ : undefined;
1013
+ message.message = (_a = object.message) !== null && _a !== void 0 ? _a : "";
1014
+ return message;
1015
+ },
1016
+ };
1017
+ function createBaseGetBillingHistoryRequest() {
1018
+ return {
1019
+ limit: 0,
1020
+ startingAfter: "",
1021
+ endingBefore: "",
1022
+ status: "",
1023
+ createdAfter: undefined,
1024
+ createdBefore: undefined,
1025
+ };
1026
+ }
1027
+ exports.GetBillingHistoryRequest = {
1028
+ encode(message, writer = new wire_1.BinaryWriter()) {
1029
+ if (message.limit !== 0) {
1030
+ writer.uint32(8).int32(message.limit);
1031
+ }
1032
+ if (message.startingAfter !== "") {
1033
+ writer.uint32(18).string(message.startingAfter);
1034
+ }
1035
+ if (message.endingBefore !== "") {
1036
+ writer.uint32(26).string(message.endingBefore);
1037
+ }
1038
+ if (message.status !== "") {
1039
+ writer.uint32(34).string(message.status);
1040
+ }
1041
+ if (message.createdAfter !== undefined) {
1042
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.createdAfter), writer.uint32(42).fork()).join();
1043
+ }
1044
+ if (message.createdBefore !== undefined) {
1045
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.createdBefore), writer.uint32(50).fork()).join();
1046
+ }
1047
+ return writer;
1048
+ },
1049
+ decode(input, length) {
1050
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1051
+ let end = length === undefined ? reader.len : reader.pos + length;
1052
+ const message = createBaseGetBillingHistoryRequest();
1053
+ while (reader.pos < end) {
1054
+ const tag = reader.uint32();
1055
+ switch (tag >>> 3) {
1056
+ case 1: {
1057
+ if (tag !== 8) {
1058
+ break;
1059
+ }
1060
+ message.limit = reader.int32();
1061
+ continue;
1062
+ }
1063
+ case 2: {
1064
+ if (tag !== 18) {
1065
+ break;
1066
+ }
1067
+ message.startingAfter = reader.string();
1068
+ continue;
1069
+ }
1070
+ case 3: {
1071
+ if (tag !== 26) {
1072
+ break;
1073
+ }
1074
+ message.endingBefore = reader.string();
1075
+ continue;
1076
+ }
1077
+ case 4: {
1078
+ if (tag !== 34) {
1079
+ break;
1080
+ }
1081
+ message.status = reader.string();
1082
+ continue;
1083
+ }
1084
+ case 5: {
1085
+ if (tag !== 42) {
1086
+ break;
1087
+ }
1088
+ message.createdAfter = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
1089
+ continue;
1090
+ }
1091
+ case 6: {
1092
+ if (tag !== 50) {
1093
+ break;
1094
+ }
1095
+ message.createdBefore = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
1096
+ continue;
1097
+ }
1098
+ }
1099
+ if ((tag & 7) === 4 || tag === 0) {
1100
+ break;
1101
+ }
1102
+ reader.skip(tag & 7);
1103
+ }
1104
+ return message;
1105
+ },
1106
+ fromJSON(object) {
1107
+ return {
1108
+ limit: isSet(object.limit) ? globalThis.Number(object.limit) : 0,
1109
+ startingAfter: isSet(object.startingAfter) ? globalThis.String(object.startingAfter) : "",
1110
+ endingBefore: isSet(object.endingBefore) ? globalThis.String(object.endingBefore) : "",
1111
+ status: isSet(object.status) ? globalThis.String(object.status) : "",
1112
+ createdAfter: isSet(object.createdAfter) ? fromJsonTimestamp(object.createdAfter) : undefined,
1113
+ createdBefore: isSet(object.createdBefore) ? fromJsonTimestamp(object.createdBefore) : undefined,
1114
+ };
1115
+ },
1116
+ toJSON(message) {
1117
+ const obj = {};
1118
+ if (message.limit !== 0) {
1119
+ obj.limit = Math.round(message.limit);
1120
+ }
1121
+ if (message.startingAfter !== "") {
1122
+ obj.startingAfter = message.startingAfter;
1123
+ }
1124
+ if (message.endingBefore !== "") {
1125
+ obj.endingBefore = message.endingBefore;
1126
+ }
1127
+ if (message.status !== "") {
1128
+ obj.status = message.status;
1129
+ }
1130
+ if (message.createdAfter !== undefined) {
1131
+ obj.createdAfter = message.createdAfter.toISOString();
1132
+ }
1133
+ if (message.createdBefore !== undefined) {
1134
+ obj.createdBefore = message.createdBefore.toISOString();
1135
+ }
1136
+ return obj;
1137
+ },
1138
+ create(base) {
1139
+ return exports.GetBillingHistoryRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1140
+ },
1141
+ fromPartial(object) {
1142
+ var _a, _b, _c, _d, _e, _f;
1143
+ const message = createBaseGetBillingHistoryRequest();
1144
+ message.limit = (_a = object.limit) !== null && _a !== void 0 ? _a : 0;
1145
+ message.startingAfter = (_b = object.startingAfter) !== null && _b !== void 0 ? _b : "";
1146
+ message.endingBefore = (_c = object.endingBefore) !== null && _c !== void 0 ? _c : "";
1147
+ message.status = (_d = object.status) !== null && _d !== void 0 ? _d : "";
1148
+ message.createdAfter = (_e = object.createdAfter) !== null && _e !== void 0 ? _e : undefined;
1149
+ message.createdBefore = (_f = object.createdBefore) !== null && _f !== void 0 ? _f : undefined;
1150
+ return message;
1151
+ },
1152
+ };
1153
+ function createBaseGetBillingHistoryResponse() {
1154
+ return { invoices: [], hasMore: false, nextCursor: "", previousCursor: "" };
1155
+ }
1156
+ exports.GetBillingHistoryResponse = {
1157
+ encode(message, writer = new wire_1.BinaryWriter()) {
1158
+ for (const v of message.invoices) {
1159
+ invoice_pb_1.Invoice.encode(v, writer.uint32(10).fork()).join();
1160
+ }
1161
+ if (message.hasMore !== false) {
1162
+ writer.uint32(16).bool(message.hasMore);
1163
+ }
1164
+ if (message.nextCursor !== "") {
1165
+ writer.uint32(26).string(message.nextCursor);
1166
+ }
1167
+ if (message.previousCursor !== "") {
1168
+ writer.uint32(34).string(message.previousCursor);
1169
+ }
1170
+ return writer;
1171
+ },
1172
+ decode(input, length) {
1173
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1174
+ let end = length === undefined ? reader.len : reader.pos + length;
1175
+ const message = createBaseGetBillingHistoryResponse();
1176
+ while (reader.pos < end) {
1177
+ const tag = reader.uint32();
1178
+ switch (tag >>> 3) {
1179
+ case 1: {
1180
+ if (tag !== 10) {
1181
+ break;
1182
+ }
1183
+ message.invoices.push(invoice_pb_1.Invoice.decode(reader, reader.uint32()));
1184
+ continue;
1185
+ }
1186
+ case 2: {
1187
+ if (tag !== 16) {
1188
+ break;
1189
+ }
1190
+ message.hasMore = reader.bool();
1191
+ continue;
1192
+ }
1193
+ case 3: {
1194
+ if (tag !== 26) {
1195
+ break;
1196
+ }
1197
+ message.nextCursor = reader.string();
1198
+ continue;
1199
+ }
1200
+ case 4: {
1201
+ if (tag !== 34) {
1202
+ break;
1203
+ }
1204
+ message.previousCursor = reader.string();
1205
+ continue;
1206
+ }
1207
+ }
1208
+ if ((tag & 7) === 4 || tag === 0) {
1209
+ break;
1210
+ }
1211
+ reader.skip(tag & 7);
1212
+ }
1213
+ return message;
1214
+ },
1215
+ fromJSON(object) {
1216
+ return {
1217
+ invoices: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.invoices) ? object.invoices.map((e) => invoice_pb_1.Invoice.fromJSON(e)) : [],
1218
+ hasMore: isSet(object.hasMore) ? globalThis.Boolean(object.hasMore) : false,
1219
+ nextCursor: isSet(object.nextCursor) ? globalThis.String(object.nextCursor) : "",
1220
+ previousCursor: isSet(object.previousCursor) ? globalThis.String(object.previousCursor) : "",
1221
+ };
1222
+ },
1223
+ toJSON(message) {
1224
+ var _a;
1225
+ const obj = {};
1226
+ if ((_a = message.invoices) === null || _a === void 0 ? void 0 : _a.length) {
1227
+ obj.invoices = message.invoices.map((e) => invoice_pb_1.Invoice.toJSON(e));
1228
+ }
1229
+ if (message.hasMore !== false) {
1230
+ obj.hasMore = message.hasMore;
1231
+ }
1232
+ if (message.nextCursor !== "") {
1233
+ obj.nextCursor = message.nextCursor;
1234
+ }
1235
+ if (message.previousCursor !== "") {
1236
+ obj.previousCursor = message.previousCursor;
1237
+ }
1238
+ return obj;
1239
+ },
1240
+ create(base) {
1241
+ return exports.GetBillingHistoryResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1242
+ },
1243
+ fromPartial(object) {
1244
+ var _a, _b, _c, _d;
1245
+ const message = createBaseGetBillingHistoryResponse();
1246
+ message.invoices = ((_a = object.invoices) === null || _a === void 0 ? void 0 : _a.map((e) => invoice_pb_1.Invoice.fromPartial(e))) || [];
1247
+ message.hasMore = (_b = object.hasMore) !== null && _b !== void 0 ? _b : false;
1248
+ message.nextCursor = (_c = object.nextCursor) !== null && _c !== void 0 ? _c : "";
1249
+ message.previousCursor = (_d = object.previousCursor) !== null && _d !== void 0 ? _d : "";
1250
+ return message;
1251
+ },
1252
+ };
1253
+ function createBaseGetUpcomingInvoiceRequest() {
1254
+ return {};
1255
+ }
1256
+ exports.GetUpcomingInvoiceRequest = {
1257
+ encode(_, writer = new wire_1.BinaryWriter()) {
1258
+ return writer;
1259
+ },
1260
+ decode(input, length) {
1261
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1262
+ let end = length === undefined ? reader.len : reader.pos + length;
1263
+ const message = createBaseGetUpcomingInvoiceRequest();
1264
+ while (reader.pos < end) {
1265
+ const tag = reader.uint32();
1266
+ switch (tag >>> 3) {
1267
+ }
1268
+ if ((tag & 7) === 4 || tag === 0) {
1269
+ break;
1270
+ }
1271
+ reader.skip(tag & 7);
1272
+ }
1273
+ return message;
1274
+ },
1275
+ fromJSON(_) {
1276
+ return {};
1277
+ },
1278
+ toJSON(_) {
1279
+ const obj = {};
1280
+ return obj;
1281
+ },
1282
+ create(base) {
1283
+ return exports.GetUpcomingInvoiceRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1284
+ },
1285
+ fromPartial(_) {
1286
+ const message = createBaseGetUpcomingInvoiceRequest();
1287
+ return message;
1288
+ },
1289
+ };
1290
+ function createBaseGetUpcomingInvoiceResponse() {
1291
+ return { invoice: undefined };
1292
+ }
1293
+ exports.GetUpcomingInvoiceResponse = {
1294
+ encode(message, writer = new wire_1.BinaryWriter()) {
1295
+ if (message.invoice !== undefined) {
1296
+ invoice_pb_1.Invoice.encode(message.invoice, writer.uint32(10).fork()).join();
1297
+ }
1298
+ return writer;
1299
+ },
1300
+ decode(input, length) {
1301
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1302
+ let end = length === undefined ? reader.len : reader.pos + length;
1303
+ const message = createBaseGetUpcomingInvoiceResponse();
1304
+ while (reader.pos < end) {
1305
+ const tag = reader.uint32();
1306
+ switch (tag >>> 3) {
1307
+ case 1: {
1308
+ if (tag !== 10) {
1309
+ break;
1310
+ }
1311
+ message.invoice = invoice_pb_1.Invoice.decode(reader, reader.uint32());
1312
+ continue;
1313
+ }
1314
+ }
1315
+ if ((tag & 7) === 4 || tag === 0) {
1316
+ break;
1317
+ }
1318
+ reader.skip(tag & 7);
1319
+ }
1320
+ return message;
1321
+ },
1322
+ fromJSON(object) {
1323
+ return { invoice: isSet(object.invoice) ? invoice_pb_1.Invoice.fromJSON(object.invoice) : undefined };
1324
+ },
1325
+ toJSON(message) {
1326
+ const obj = {};
1327
+ if (message.invoice !== undefined) {
1328
+ obj.invoice = invoice_pb_1.Invoice.toJSON(message.invoice);
1329
+ }
1330
+ return obj;
1331
+ },
1332
+ create(base) {
1333
+ return exports.GetUpcomingInvoiceResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1334
+ },
1335
+ fromPartial(object) {
1336
+ const message = createBaseGetUpcomingInvoiceResponse();
1337
+ message.invoice = (object.invoice !== undefined && object.invoice !== null)
1338
+ ? invoice_pb_1.Invoice.fromPartial(object.invoice)
1339
+ : undefined;
1340
+ return message;
1341
+ },
1342
+ };
1343
+ function createBaseListPaymentMethodsRequest() {
1344
+ return { type: "" };
1345
+ }
1346
+ exports.ListPaymentMethodsRequest = {
1347
+ encode(message, writer = new wire_1.BinaryWriter()) {
1348
+ if (message.type !== "") {
1349
+ writer.uint32(10).string(message.type);
1350
+ }
1351
+ return writer;
1352
+ },
1353
+ decode(input, length) {
1354
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1355
+ let end = length === undefined ? reader.len : reader.pos + length;
1356
+ const message = createBaseListPaymentMethodsRequest();
1357
+ while (reader.pos < end) {
1358
+ const tag = reader.uint32();
1359
+ switch (tag >>> 3) {
1360
+ case 1: {
1361
+ if (tag !== 10) {
1362
+ break;
1363
+ }
1364
+ message.type = reader.string();
1365
+ continue;
1366
+ }
1367
+ }
1368
+ if ((tag & 7) === 4 || tag === 0) {
1369
+ break;
1370
+ }
1371
+ reader.skip(tag & 7);
1372
+ }
1373
+ return message;
1374
+ },
1375
+ fromJSON(object) {
1376
+ return { type: isSet(object.type) ? globalThis.String(object.type) : "" };
1377
+ },
1378
+ toJSON(message) {
1379
+ const obj = {};
1380
+ if (message.type !== "") {
1381
+ obj.type = message.type;
1382
+ }
1383
+ return obj;
1384
+ },
1385
+ create(base) {
1386
+ return exports.ListPaymentMethodsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1387
+ },
1388
+ fromPartial(object) {
1389
+ var _a;
1390
+ const message = createBaseListPaymentMethodsRequest();
1391
+ message.type = (_a = object.type) !== null && _a !== void 0 ? _a : "";
1392
+ return message;
1393
+ },
1394
+ };
1395
+ function createBaseListPaymentMethodsResponse() {
1396
+ return { paymentMethods: [], defaultPaymentMethodId: "" };
1397
+ }
1398
+ exports.ListPaymentMethodsResponse = {
1399
+ encode(message, writer = new wire_1.BinaryWriter()) {
1400
+ for (const v of message.paymentMethods) {
1401
+ subscription_pb_1.PaymentMethod.encode(v, writer.uint32(10).fork()).join();
1402
+ }
1403
+ if (message.defaultPaymentMethodId !== "") {
1404
+ writer.uint32(18).string(message.defaultPaymentMethodId);
1405
+ }
1406
+ return writer;
1407
+ },
1408
+ decode(input, length) {
1409
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1410
+ let end = length === undefined ? reader.len : reader.pos + length;
1411
+ const message = createBaseListPaymentMethodsResponse();
1412
+ while (reader.pos < end) {
1413
+ const tag = reader.uint32();
1414
+ switch (tag >>> 3) {
1415
+ case 1: {
1416
+ if (tag !== 10) {
1417
+ break;
1418
+ }
1419
+ message.paymentMethods.push(subscription_pb_1.PaymentMethod.decode(reader, reader.uint32()));
1420
+ continue;
1421
+ }
1422
+ case 2: {
1423
+ if (tag !== 18) {
1424
+ break;
1425
+ }
1426
+ message.defaultPaymentMethodId = reader.string();
1427
+ continue;
1428
+ }
1429
+ }
1430
+ if ((tag & 7) === 4 || tag === 0) {
1431
+ break;
1432
+ }
1433
+ reader.skip(tag & 7);
1434
+ }
1435
+ return message;
1436
+ },
1437
+ fromJSON(object) {
1438
+ return {
1439
+ paymentMethods: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.paymentMethods)
1440
+ ? object.paymentMethods.map((e) => subscription_pb_1.PaymentMethod.fromJSON(e))
1441
+ : [],
1442
+ defaultPaymentMethodId: isSet(object.defaultPaymentMethodId)
1443
+ ? globalThis.String(object.defaultPaymentMethodId)
1444
+ : "",
1445
+ };
1446
+ },
1447
+ toJSON(message) {
1448
+ var _a;
1449
+ const obj = {};
1450
+ if ((_a = message.paymentMethods) === null || _a === void 0 ? void 0 : _a.length) {
1451
+ obj.paymentMethods = message.paymentMethods.map((e) => subscription_pb_1.PaymentMethod.toJSON(e));
1452
+ }
1453
+ if (message.defaultPaymentMethodId !== "") {
1454
+ obj.defaultPaymentMethodId = message.defaultPaymentMethodId;
1455
+ }
1456
+ return obj;
1457
+ },
1458
+ create(base) {
1459
+ return exports.ListPaymentMethodsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1460
+ },
1461
+ fromPartial(object) {
1462
+ var _a, _b;
1463
+ const message = createBaseListPaymentMethodsResponse();
1464
+ message.paymentMethods = ((_a = object.paymentMethods) === null || _a === void 0 ? void 0 : _a.map((e) => subscription_pb_1.PaymentMethod.fromPartial(e))) || [];
1465
+ message.defaultPaymentMethodId = (_b = object.defaultPaymentMethodId) !== null && _b !== void 0 ? _b : "";
1466
+ return message;
1467
+ },
1468
+ };
1469
+ function createBaseAddPaymentMethodRequest() {
1470
+ return { paymentMethodId: "", setAsDefault: false };
1471
+ }
1472
+ exports.AddPaymentMethodRequest = {
1473
+ encode(message, writer = new wire_1.BinaryWriter()) {
1474
+ if (message.paymentMethodId !== "") {
1475
+ writer.uint32(10).string(message.paymentMethodId);
1476
+ }
1477
+ if (message.setAsDefault !== false) {
1478
+ writer.uint32(16).bool(message.setAsDefault);
1479
+ }
1480
+ return writer;
1481
+ },
1482
+ decode(input, length) {
1483
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1484
+ let end = length === undefined ? reader.len : reader.pos + length;
1485
+ const message = createBaseAddPaymentMethodRequest();
1486
+ while (reader.pos < end) {
1487
+ const tag = reader.uint32();
1488
+ switch (tag >>> 3) {
1489
+ case 1: {
1490
+ if (tag !== 10) {
1491
+ break;
1492
+ }
1493
+ message.paymentMethodId = reader.string();
1494
+ continue;
1495
+ }
1496
+ case 2: {
1497
+ if (tag !== 16) {
1498
+ break;
1499
+ }
1500
+ message.setAsDefault = reader.bool();
1501
+ continue;
1502
+ }
1503
+ }
1504
+ if ((tag & 7) === 4 || tag === 0) {
1505
+ break;
1506
+ }
1507
+ reader.skip(tag & 7);
1508
+ }
1509
+ return message;
1510
+ },
1511
+ fromJSON(object) {
1512
+ return {
1513
+ paymentMethodId: isSet(object.paymentMethodId) ? globalThis.String(object.paymentMethodId) : "",
1514
+ setAsDefault: isSet(object.setAsDefault) ? globalThis.Boolean(object.setAsDefault) : false,
1515
+ };
1516
+ },
1517
+ toJSON(message) {
1518
+ const obj = {};
1519
+ if (message.paymentMethodId !== "") {
1520
+ obj.paymentMethodId = message.paymentMethodId;
1521
+ }
1522
+ if (message.setAsDefault !== false) {
1523
+ obj.setAsDefault = message.setAsDefault;
1524
+ }
1525
+ return obj;
1526
+ },
1527
+ create(base) {
1528
+ return exports.AddPaymentMethodRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1529
+ },
1530
+ fromPartial(object) {
1531
+ var _a, _b;
1532
+ const message = createBaseAddPaymentMethodRequest();
1533
+ message.paymentMethodId = (_a = object.paymentMethodId) !== null && _a !== void 0 ? _a : "";
1534
+ message.setAsDefault = (_b = object.setAsDefault) !== null && _b !== void 0 ? _b : false;
1535
+ return message;
1536
+ },
1537
+ };
1538
+ function createBaseAddPaymentMethodResponse() {
1539
+ return { paymentMethod: undefined, isDefault: false };
1540
+ }
1541
+ exports.AddPaymentMethodResponse = {
1542
+ encode(message, writer = new wire_1.BinaryWriter()) {
1543
+ if (message.paymentMethod !== undefined) {
1544
+ subscription_pb_1.PaymentMethod.encode(message.paymentMethod, writer.uint32(10).fork()).join();
1545
+ }
1546
+ if (message.isDefault !== false) {
1547
+ writer.uint32(16).bool(message.isDefault);
1548
+ }
1549
+ return writer;
1550
+ },
1551
+ decode(input, length) {
1552
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1553
+ let end = length === undefined ? reader.len : reader.pos + length;
1554
+ const message = createBaseAddPaymentMethodResponse();
1555
+ while (reader.pos < end) {
1556
+ const tag = reader.uint32();
1557
+ switch (tag >>> 3) {
1558
+ case 1: {
1559
+ if (tag !== 10) {
1560
+ break;
1561
+ }
1562
+ message.paymentMethod = subscription_pb_1.PaymentMethod.decode(reader, reader.uint32());
1563
+ continue;
1564
+ }
1565
+ case 2: {
1566
+ if (tag !== 16) {
1567
+ break;
1568
+ }
1569
+ message.isDefault = reader.bool();
1570
+ continue;
1571
+ }
1572
+ }
1573
+ if ((tag & 7) === 4 || tag === 0) {
1574
+ break;
1575
+ }
1576
+ reader.skip(tag & 7);
1577
+ }
1578
+ return message;
1579
+ },
1580
+ fromJSON(object) {
1581
+ return {
1582
+ paymentMethod: isSet(object.paymentMethod) ? subscription_pb_1.PaymentMethod.fromJSON(object.paymentMethod) : undefined,
1583
+ isDefault: isSet(object.isDefault) ? globalThis.Boolean(object.isDefault) : false,
1584
+ };
1585
+ },
1586
+ toJSON(message) {
1587
+ const obj = {};
1588
+ if (message.paymentMethod !== undefined) {
1589
+ obj.paymentMethod = subscription_pb_1.PaymentMethod.toJSON(message.paymentMethod);
1590
+ }
1591
+ if (message.isDefault !== false) {
1592
+ obj.isDefault = message.isDefault;
1593
+ }
1594
+ return obj;
1595
+ },
1596
+ create(base) {
1597
+ return exports.AddPaymentMethodResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1598
+ },
1599
+ fromPartial(object) {
1600
+ var _a;
1601
+ const message = createBaseAddPaymentMethodResponse();
1602
+ message.paymentMethod = (object.paymentMethod !== undefined && object.paymentMethod !== null)
1603
+ ? subscription_pb_1.PaymentMethod.fromPartial(object.paymentMethod)
1604
+ : undefined;
1605
+ message.isDefault = (_a = object.isDefault) !== null && _a !== void 0 ? _a : false;
1606
+ return message;
1607
+ },
1608
+ };
1609
+ function createBaseSetDefaultPaymentMethodRequest() {
1610
+ return { paymentMethodId: "" };
1611
+ }
1612
+ exports.SetDefaultPaymentMethodRequest = {
1613
+ encode(message, writer = new wire_1.BinaryWriter()) {
1614
+ if (message.paymentMethodId !== "") {
1615
+ writer.uint32(10).string(message.paymentMethodId);
1616
+ }
1617
+ return writer;
1618
+ },
1619
+ decode(input, length) {
1620
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1621
+ let end = length === undefined ? reader.len : reader.pos + length;
1622
+ const message = createBaseSetDefaultPaymentMethodRequest();
1623
+ while (reader.pos < end) {
1624
+ const tag = reader.uint32();
1625
+ switch (tag >>> 3) {
1626
+ case 1: {
1627
+ if (tag !== 10) {
1628
+ break;
1629
+ }
1630
+ message.paymentMethodId = reader.string();
1631
+ continue;
1632
+ }
1633
+ }
1634
+ if ((tag & 7) === 4 || tag === 0) {
1635
+ break;
1636
+ }
1637
+ reader.skip(tag & 7);
1638
+ }
1639
+ return message;
1640
+ },
1641
+ fromJSON(object) {
1642
+ return { paymentMethodId: isSet(object.paymentMethodId) ? globalThis.String(object.paymentMethodId) : "" };
1643
+ },
1644
+ toJSON(message) {
1645
+ const obj = {};
1646
+ if (message.paymentMethodId !== "") {
1647
+ obj.paymentMethodId = message.paymentMethodId;
1648
+ }
1649
+ return obj;
1650
+ },
1651
+ create(base) {
1652
+ return exports.SetDefaultPaymentMethodRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1653
+ },
1654
+ fromPartial(object) {
1655
+ var _a;
1656
+ const message = createBaseSetDefaultPaymentMethodRequest();
1657
+ message.paymentMethodId = (_a = object.paymentMethodId) !== null && _a !== void 0 ? _a : "";
1658
+ return message;
1659
+ },
1660
+ };
1661
+ function createBaseSetDefaultPaymentMethodResponse() {
1662
+ return { success: false, message: "" };
1663
+ }
1664
+ exports.SetDefaultPaymentMethodResponse = {
1665
+ encode(message, writer = new wire_1.BinaryWriter()) {
1666
+ if (message.success !== false) {
1667
+ writer.uint32(8).bool(message.success);
1668
+ }
1669
+ if (message.message !== "") {
1670
+ writer.uint32(18).string(message.message);
1671
+ }
1672
+ return writer;
1673
+ },
1674
+ decode(input, length) {
1675
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1676
+ let end = length === undefined ? reader.len : reader.pos + length;
1677
+ const message = createBaseSetDefaultPaymentMethodResponse();
1678
+ while (reader.pos < end) {
1679
+ const tag = reader.uint32();
1680
+ switch (tag >>> 3) {
1681
+ case 1: {
1682
+ if (tag !== 8) {
1683
+ break;
1684
+ }
1685
+ message.success = reader.bool();
1686
+ continue;
1687
+ }
1688
+ case 2: {
1689
+ if (tag !== 18) {
1690
+ break;
1691
+ }
1692
+ message.message = reader.string();
1693
+ continue;
1694
+ }
1695
+ }
1696
+ if ((tag & 7) === 4 || tag === 0) {
1697
+ break;
1698
+ }
1699
+ reader.skip(tag & 7);
1700
+ }
1701
+ return message;
1702
+ },
1703
+ fromJSON(object) {
1704
+ return {
1705
+ success: isSet(object.success) ? globalThis.Boolean(object.success) : false,
1706
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
1707
+ };
1708
+ },
1709
+ toJSON(message) {
1710
+ const obj = {};
1711
+ if (message.success !== false) {
1712
+ obj.success = message.success;
1713
+ }
1714
+ if (message.message !== "") {
1715
+ obj.message = message.message;
1716
+ }
1717
+ return obj;
1718
+ },
1719
+ create(base) {
1720
+ return exports.SetDefaultPaymentMethodResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1721
+ },
1722
+ fromPartial(object) {
1723
+ var _a, _b;
1724
+ const message = createBaseSetDefaultPaymentMethodResponse();
1725
+ message.success = (_a = object.success) !== null && _a !== void 0 ? _a : false;
1726
+ message.message = (_b = object.message) !== null && _b !== void 0 ? _b : "";
1727
+ return message;
1728
+ },
1729
+ };
1730
+ function createBaseRemovePaymentMethodRequest() {
1731
+ return { paymentMethodId: "" };
1732
+ }
1733
+ exports.RemovePaymentMethodRequest = {
1734
+ encode(message, writer = new wire_1.BinaryWriter()) {
1735
+ if (message.paymentMethodId !== "") {
1736
+ writer.uint32(10).string(message.paymentMethodId);
1737
+ }
1738
+ return writer;
1739
+ },
1740
+ decode(input, length) {
1741
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1742
+ let end = length === undefined ? reader.len : reader.pos + length;
1743
+ const message = createBaseRemovePaymentMethodRequest();
1744
+ while (reader.pos < end) {
1745
+ const tag = reader.uint32();
1746
+ switch (tag >>> 3) {
1747
+ case 1: {
1748
+ if (tag !== 10) {
1749
+ break;
1750
+ }
1751
+ message.paymentMethodId = reader.string();
1752
+ continue;
1753
+ }
1754
+ }
1755
+ if ((tag & 7) === 4 || tag === 0) {
1756
+ break;
1757
+ }
1758
+ reader.skip(tag & 7);
1759
+ }
1760
+ return message;
1761
+ },
1762
+ fromJSON(object) {
1763
+ return { paymentMethodId: isSet(object.paymentMethodId) ? globalThis.String(object.paymentMethodId) : "" };
1764
+ },
1765
+ toJSON(message) {
1766
+ const obj = {};
1767
+ if (message.paymentMethodId !== "") {
1768
+ obj.paymentMethodId = message.paymentMethodId;
1769
+ }
1770
+ return obj;
1771
+ },
1772
+ create(base) {
1773
+ return exports.RemovePaymentMethodRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1774
+ },
1775
+ fromPartial(object) {
1776
+ var _a;
1777
+ const message = createBaseRemovePaymentMethodRequest();
1778
+ message.paymentMethodId = (_a = object.paymentMethodId) !== null && _a !== void 0 ? _a : "";
1779
+ return message;
1780
+ },
1781
+ };
1782
+ function createBaseRemovePaymentMethodResponse() {
1783
+ return { success: false, message: "", remainingMethods: 0 };
1784
+ }
1785
+ exports.RemovePaymentMethodResponse = {
1786
+ encode(message, writer = new wire_1.BinaryWriter()) {
1787
+ if (message.success !== false) {
1788
+ writer.uint32(8).bool(message.success);
1789
+ }
1790
+ if (message.message !== "") {
1791
+ writer.uint32(18).string(message.message);
1792
+ }
1793
+ if (message.remainingMethods !== 0) {
1794
+ writer.uint32(24).int32(message.remainingMethods);
1795
+ }
1796
+ return writer;
1797
+ },
1798
+ decode(input, length) {
1799
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1800
+ let end = length === undefined ? reader.len : reader.pos + length;
1801
+ const message = createBaseRemovePaymentMethodResponse();
1802
+ while (reader.pos < end) {
1803
+ const tag = reader.uint32();
1804
+ switch (tag >>> 3) {
1805
+ case 1: {
1806
+ if (tag !== 8) {
1807
+ break;
1808
+ }
1809
+ message.success = reader.bool();
1810
+ continue;
1811
+ }
1812
+ case 2: {
1813
+ if (tag !== 18) {
1814
+ break;
1815
+ }
1816
+ message.message = reader.string();
1817
+ continue;
1818
+ }
1819
+ case 3: {
1820
+ if (tag !== 24) {
1821
+ break;
1822
+ }
1823
+ message.remainingMethods = reader.int32();
1824
+ continue;
1825
+ }
1826
+ }
1827
+ if ((tag & 7) === 4 || tag === 0) {
1828
+ break;
1829
+ }
1830
+ reader.skip(tag & 7);
1831
+ }
1832
+ return message;
1833
+ },
1834
+ fromJSON(object) {
1835
+ return {
1836
+ success: isSet(object.success) ? globalThis.Boolean(object.success) : false,
1837
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
1838
+ remainingMethods: isSet(object.remainingMethods) ? globalThis.Number(object.remainingMethods) : 0,
1839
+ };
1840
+ },
1841
+ toJSON(message) {
1842
+ const obj = {};
1843
+ if (message.success !== false) {
1844
+ obj.success = message.success;
1845
+ }
1846
+ if (message.message !== "") {
1847
+ obj.message = message.message;
1848
+ }
1849
+ if (message.remainingMethods !== 0) {
1850
+ obj.remainingMethods = Math.round(message.remainingMethods);
1851
+ }
1852
+ return obj;
1853
+ },
1854
+ create(base) {
1855
+ return exports.RemovePaymentMethodResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1856
+ },
1857
+ fromPartial(object) {
1858
+ var _a, _b, _c;
1859
+ const message = createBaseRemovePaymentMethodResponse();
1860
+ message.success = (_a = object.success) !== null && _a !== void 0 ? _a : false;
1861
+ message.message = (_b = object.message) !== null && _b !== void 0 ? _b : "";
1862
+ message.remainingMethods = (_c = object.remainingMethods) !== null && _c !== void 0 ? _c : 0;
1863
+ return message;
1864
+ },
1865
+ };
1866
+ function createBaseCreatePortalSessionRequest() {
1867
+ return { returnUrl: "" };
1868
+ }
1869
+ exports.CreatePortalSessionRequest = {
1870
+ encode(message, writer = new wire_1.BinaryWriter()) {
1871
+ if (message.returnUrl !== "") {
1872
+ writer.uint32(10).string(message.returnUrl);
1873
+ }
1874
+ return writer;
1875
+ },
1876
+ decode(input, length) {
1877
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1878
+ let end = length === undefined ? reader.len : reader.pos + length;
1879
+ const message = createBaseCreatePortalSessionRequest();
1880
+ while (reader.pos < end) {
1881
+ const tag = reader.uint32();
1882
+ switch (tag >>> 3) {
1883
+ case 1: {
1884
+ if (tag !== 10) {
1885
+ break;
1886
+ }
1887
+ message.returnUrl = reader.string();
1888
+ continue;
1889
+ }
1890
+ }
1891
+ if ((tag & 7) === 4 || tag === 0) {
1892
+ break;
1893
+ }
1894
+ reader.skip(tag & 7);
1895
+ }
1896
+ return message;
1897
+ },
1898
+ fromJSON(object) {
1899
+ return { returnUrl: isSet(object.returnUrl) ? globalThis.String(object.returnUrl) : "" };
1900
+ },
1901
+ toJSON(message) {
1902
+ const obj = {};
1903
+ if (message.returnUrl !== "") {
1904
+ obj.returnUrl = message.returnUrl;
1905
+ }
1906
+ return obj;
1907
+ },
1908
+ create(base) {
1909
+ return exports.CreatePortalSessionRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1910
+ },
1911
+ fromPartial(object) {
1912
+ var _a;
1913
+ const message = createBaseCreatePortalSessionRequest();
1914
+ message.returnUrl = (_a = object.returnUrl) !== null && _a !== void 0 ? _a : "";
1915
+ return message;
1916
+ },
1917
+ };
1918
+ function createBaseCreatePortalSessionResponse() {
1919
+ return { portalUrl: "", expiresAt: undefined };
1920
+ }
1921
+ exports.CreatePortalSessionResponse = {
1922
+ encode(message, writer = new wire_1.BinaryWriter()) {
1923
+ if (message.portalUrl !== "") {
1924
+ writer.uint32(10).string(message.portalUrl);
1925
+ }
1926
+ if (message.expiresAt !== undefined) {
1927
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(18).fork()).join();
1928
+ }
1929
+ return writer;
1930
+ },
1931
+ decode(input, length) {
1932
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1933
+ let end = length === undefined ? reader.len : reader.pos + length;
1934
+ const message = createBaseCreatePortalSessionResponse();
1935
+ while (reader.pos < end) {
1936
+ const tag = reader.uint32();
1937
+ switch (tag >>> 3) {
1938
+ case 1: {
1939
+ if (tag !== 10) {
1940
+ break;
1941
+ }
1942
+ message.portalUrl = reader.string();
1943
+ continue;
1944
+ }
1945
+ case 2: {
1946
+ if (tag !== 18) {
1947
+ break;
1948
+ }
1949
+ message.expiresAt = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
1950
+ continue;
1951
+ }
1952
+ }
1953
+ if ((tag & 7) === 4 || tag === 0) {
1954
+ break;
1955
+ }
1956
+ reader.skip(tag & 7);
1957
+ }
1958
+ return message;
1959
+ },
1960
+ fromJSON(object) {
1961
+ return {
1962
+ portalUrl: isSet(object.portalUrl) ? globalThis.String(object.portalUrl) : "",
1963
+ expiresAt: isSet(object.expiresAt) ? fromJsonTimestamp(object.expiresAt) : undefined,
1964
+ };
1965
+ },
1966
+ toJSON(message) {
1967
+ const obj = {};
1968
+ if (message.portalUrl !== "") {
1969
+ obj.portalUrl = message.portalUrl;
1970
+ }
1971
+ if (message.expiresAt !== undefined) {
1972
+ obj.expiresAt = message.expiresAt.toISOString();
1973
+ }
1974
+ return obj;
1975
+ },
1976
+ create(base) {
1977
+ return exports.CreatePortalSessionResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1978
+ },
1979
+ fromPartial(object) {
1980
+ var _a, _b;
1981
+ const message = createBaseCreatePortalSessionResponse();
1982
+ message.portalUrl = (_a = object.portalUrl) !== null && _a !== void 0 ? _a : "";
1983
+ message.expiresAt = (_b = object.expiresAt) !== null && _b !== void 0 ? _b : undefined;
1984
+ return message;
1985
+ },
1986
+ };
1987
+ function createBaseGetPricingPlansRequest() {
1988
+ return { currency: "", activeOnly: false };
1989
+ }
1990
+ exports.GetPricingPlansRequest = {
1991
+ encode(message, writer = new wire_1.BinaryWriter()) {
1992
+ if (message.currency !== "") {
1993
+ writer.uint32(10).string(message.currency);
1994
+ }
1995
+ if (message.activeOnly !== false) {
1996
+ writer.uint32(16).bool(message.activeOnly);
1997
+ }
1998
+ return writer;
1999
+ },
2000
+ decode(input, length) {
2001
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2002
+ let end = length === undefined ? reader.len : reader.pos + length;
2003
+ const message = createBaseGetPricingPlansRequest();
2004
+ while (reader.pos < end) {
2005
+ const tag = reader.uint32();
2006
+ switch (tag >>> 3) {
2007
+ case 1: {
2008
+ if (tag !== 10) {
2009
+ break;
2010
+ }
2011
+ message.currency = reader.string();
2012
+ continue;
2013
+ }
2014
+ case 2: {
2015
+ if (tag !== 16) {
2016
+ break;
2017
+ }
2018
+ message.activeOnly = reader.bool();
2019
+ continue;
2020
+ }
2021
+ }
2022
+ if ((tag & 7) === 4 || tag === 0) {
2023
+ break;
2024
+ }
2025
+ reader.skip(tag & 7);
2026
+ }
2027
+ return message;
2028
+ },
2029
+ fromJSON(object) {
2030
+ return {
2031
+ currency: isSet(object.currency) ? globalThis.String(object.currency) : "",
2032
+ activeOnly: isSet(object.activeOnly) ? globalThis.Boolean(object.activeOnly) : false,
2033
+ };
2034
+ },
2035
+ toJSON(message) {
2036
+ const obj = {};
2037
+ if (message.currency !== "") {
2038
+ obj.currency = message.currency;
2039
+ }
2040
+ if (message.activeOnly !== false) {
2041
+ obj.activeOnly = message.activeOnly;
2042
+ }
2043
+ return obj;
2044
+ },
2045
+ create(base) {
2046
+ return exports.GetPricingPlansRequest.fromPartial(base !== null && base !== void 0 ? base : {});
2047
+ },
2048
+ fromPartial(object) {
2049
+ var _a, _b;
2050
+ const message = createBaseGetPricingPlansRequest();
2051
+ message.currency = (_a = object.currency) !== null && _a !== void 0 ? _a : "";
2052
+ message.activeOnly = (_b = object.activeOnly) !== null && _b !== void 0 ? _b : false;
2053
+ return message;
2054
+ },
2055
+ };
2056
+ function createBaseGetPricingPlansResponse() {
2057
+ return { plans: [], recommendedPlanId: "", currentPlan: undefined };
2058
+ }
2059
+ exports.GetPricingPlansResponse = {
2060
+ encode(message, writer = new wire_1.BinaryWriter()) {
2061
+ for (const v of message.plans) {
2062
+ subscription_pb_1.PricingPlan.encode(v, writer.uint32(10).fork()).join();
2063
+ }
2064
+ if (message.recommendedPlanId !== "") {
2065
+ writer.uint32(18).string(message.recommendedPlanId);
2066
+ }
2067
+ if (message.currentPlan !== undefined) {
2068
+ subscription_pb_1.PricingPlan.encode(message.currentPlan, writer.uint32(26).fork()).join();
2069
+ }
2070
+ return writer;
2071
+ },
2072
+ decode(input, length) {
2073
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2074
+ let end = length === undefined ? reader.len : reader.pos + length;
2075
+ const message = createBaseGetPricingPlansResponse();
2076
+ while (reader.pos < end) {
2077
+ const tag = reader.uint32();
2078
+ switch (tag >>> 3) {
2079
+ case 1: {
2080
+ if (tag !== 10) {
2081
+ break;
2082
+ }
2083
+ message.plans.push(subscription_pb_1.PricingPlan.decode(reader, reader.uint32()));
2084
+ continue;
2085
+ }
2086
+ case 2: {
2087
+ if (tag !== 18) {
2088
+ break;
2089
+ }
2090
+ message.recommendedPlanId = reader.string();
2091
+ continue;
2092
+ }
2093
+ case 3: {
2094
+ if (tag !== 26) {
2095
+ break;
2096
+ }
2097
+ message.currentPlan = subscription_pb_1.PricingPlan.decode(reader, reader.uint32());
2098
+ continue;
2099
+ }
2100
+ }
2101
+ if ((tag & 7) === 4 || tag === 0) {
2102
+ break;
2103
+ }
2104
+ reader.skip(tag & 7);
2105
+ }
2106
+ return message;
2107
+ },
2108
+ fromJSON(object) {
2109
+ return {
2110
+ plans: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.plans) ? object.plans.map((e) => subscription_pb_1.PricingPlan.fromJSON(e)) : [],
2111
+ recommendedPlanId: isSet(object.recommendedPlanId) ? globalThis.String(object.recommendedPlanId) : "",
2112
+ currentPlan: isSet(object.currentPlan) ? subscription_pb_1.PricingPlan.fromJSON(object.currentPlan) : undefined,
2113
+ };
2114
+ },
2115
+ toJSON(message) {
2116
+ var _a;
2117
+ const obj = {};
2118
+ if ((_a = message.plans) === null || _a === void 0 ? void 0 : _a.length) {
2119
+ obj.plans = message.plans.map((e) => subscription_pb_1.PricingPlan.toJSON(e));
2120
+ }
2121
+ if (message.recommendedPlanId !== "") {
2122
+ obj.recommendedPlanId = message.recommendedPlanId;
2123
+ }
2124
+ if (message.currentPlan !== undefined) {
2125
+ obj.currentPlan = subscription_pb_1.PricingPlan.toJSON(message.currentPlan);
2126
+ }
2127
+ return obj;
2128
+ },
2129
+ create(base) {
2130
+ return exports.GetPricingPlansResponse.fromPartial(base !== null && base !== void 0 ? base : {});
2131
+ },
2132
+ fromPartial(object) {
2133
+ var _a, _b;
2134
+ const message = createBaseGetPricingPlansResponse();
2135
+ message.plans = ((_a = object.plans) === null || _a === void 0 ? void 0 : _a.map((e) => subscription_pb_1.PricingPlan.fromPartial(e))) || [];
2136
+ message.recommendedPlanId = (_b = object.recommendedPlanId) !== null && _b !== void 0 ? _b : "";
2137
+ message.currentPlan = (object.currentPlan !== undefined && object.currentPlan !== null)
2138
+ ? subscription_pb_1.PricingPlan.fromPartial(object.currentPlan)
2139
+ : undefined;
2140
+ return message;
2141
+ },
2142
+ };
2143
+ function createBaseApplyPromoCodeRequest() {
2144
+ return { promoCode: "" };
2145
+ }
2146
+ exports.ApplyPromoCodeRequest = {
2147
+ encode(message, writer = new wire_1.BinaryWriter()) {
2148
+ if (message.promoCode !== "") {
2149
+ writer.uint32(10).string(message.promoCode);
2150
+ }
2151
+ return writer;
2152
+ },
2153
+ decode(input, length) {
2154
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2155
+ let end = length === undefined ? reader.len : reader.pos + length;
2156
+ const message = createBaseApplyPromoCodeRequest();
2157
+ while (reader.pos < end) {
2158
+ const tag = reader.uint32();
2159
+ switch (tag >>> 3) {
2160
+ case 1: {
2161
+ if (tag !== 10) {
2162
+ break;
2163
+ }
2164
+ message.promoCode = reader.string();
2165
+ continue;
2166
+ }
2167
+ }
2168
+ if ((tag & 7) === 4 || tag === 0) {
2169
+ break;
2170
+ }
2171
+ reader.skip(tag & 7);
2172
+ }
2173
+ return message;
2174
+ },
2175
+ fromJSON(object) {
2176
+ return { promoCode: isSet(object.promoCode) ? globalThis.String(object.promoCode) : "" };
2177
+ },
2178
+ toJSON(message) {
2179
+ const obj = {};
2180
+ if (message.promoCode !== "") {
2181
+ obj.promoCode = message.promoCode;
2182
+ }
2183
+ return obj;
2184
+ },
2185
+ create(base) {
2186
+ return exports.ApplyPromoCodeRequest.fromPartial(base !== null && base !== void 0 ? base : {});
2187
+ },
2188
+ fromPartial(object) {
2189
+ var _a;
2190
+ const message = createBaseApplyPromoCodeRequest();
2191
+ message.promoCode = (_a = object.promoCode) !== null && _a !== void 0 ? _a : "";
2192
+ return message;
2193
+ },
2194
+ };
2195
+ function createBaseApplyPromoCodeResponse() {
2196
+ return { valid: false, discount: undefined, message: "", expiresAt: undefined };
2197
+ }
2198
+ exports.ApplyPromoCodeResponse = {
2199
+ encode(message, writer = new wire_1.BinaryWriter()) {
2200
+ if (message.valid !== false) {
2201
+ writer.uint32(8).bool(message.valid);
2202
+ }
2203
+ if (message.discount !== undefined) {
2204
+ subscription_pb_1.Discount.encode(message.discount, writer.uint32(18).fork()).join();
2205
+ }
2206
+ if (message.message !== "") {
2207
+ writer.uint32(26).string(message.message);
2208
+ }
2209
+ if (message.expiresAt !== undefined) {
2210
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(34).fork()).join();
2211
+ }
2212
+ return writer;
2213
+ },
2214
+ decode(input, length) {
2215
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2216
+ let end = length === undefined ? reader.len : reader.pos + length;
2217
+ const message = createBaseApplyPromoCodeResponse();
2218
+ while (reader.pos < end) {
2219
+ const tag = reader.uint32();
2220
+ switch (tag >>> 3) {
2221
+ case 1: {
2222
+ if (tag !== 8) {
2223
+ break;
2224
+ }
2225
+ message.valid = reader.bool();
2226
+ continue;
2227
+ }
2228
+ case 2: {
2229
+ if (tag !== 18) {
2230
+ break;
2231
+ }
2232
+ message.discount = subscription_pb_1.Discount.decode(reader, reader.uint32());
2233
+ continue;
2234
+ }
2235
+ case 3: {
2236
+ if (tag !== 26) {
2237
+ break;
2238
+ }
2239
+ message.message = reader.string();
2240
+ continue;
2241
+ }
2242
+ case 4: {
2243
+ if (tag !== 34) {
2244
+ break;
2245
+ }
2246
+ message.expiresAt = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
2247
+ continue;
2248
+ }
2249
+ }
2250
+ if ((tag & 7) === 4 || tag === 0) {
2251
+ break;
2252
+ }
2253
+ reader.skip(tag & 7);
2254
+ }
2255
+ return message;
2256
+ },
2257
+ fromJSON(object) {
2258
+ return {
2259
+ valid: isSet(object.valid) ? globalThis.Boolean(object.valid) : false,
2260
+ discount: isSet(object.discount) ? subscription_pb_1.Discount.fromJSON(object.discount) : undefined,
2261
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
2262
+ expiresAt: isSet(object.expiresAt) ? fromJsonTimestamp(object.expiresAt) : undefined,
2263
+ };
2264
+ },
2265
+ toJSON(message) {
2266
+ const obj = {};
2267
+ if (message.valid !== false) {
2268
+ obj.valid = message.valid;
2269
+ }
2270
+ if (message.discount !== undefined) {
2271
+ obj.discount = subscription_pb_1.Discount.toJSON(message.discount);
2272
+ }
2273
+ if (message.message !== "") {
2274
+ obj.message = message.message;
2275
+ }
2276
+ if (message.expiresAt !== undefined) {
2277
+ obj.expiresAt = message.expiresAt.toISOString();
2278
+ }
2279
+ return obj;
2280
+ },
2281
+ create(base) {
2282
+ return exports.ApplyPromoCodeResponse.fromPartial(base !== null && base !== void 0 ? base : {});
2283
+ },
2284
+ fromPartial(object) {
2285
+ var _a, _b, _c;
2286
+ const message = createBaseApplyPromoCodeResponse();
2287
+ message.valid = (_a = object.valid) !== null && _a !== void 0 ? _a : false;
2288
+ message.discount = (object.discount !== undefined && object.discount !== null)
2289
+ ? subscription_pb_1.Discount.fromPartial(object.discount)
2290
+ : undefined;
2291
+ message.message = (_b = object.message) !== null && _b !== void 0 ? _b : "";
2292
+ message.expiresAt = (_c = object.expiresAt) !== null && _c !== void 0 ? _c : undefined;
2293
+ return message;
2294
+ },
2295
+ };
2296
+ function createBaseHandleStripeWebhookRequest() {
2297
+ return { payload: new Uint8Array(0), signature: "" };
2298
+ }
2299
+ exports.HandleStripeWebhookRequest = {
2300
+ encode(message, writer = new wire_1.BinaryWriter()) {
2301
+ if (message.payload.length !== 0) {
2302
+ writer.uint32(10).bytes(message.payload);
2303
+ }
2304
+ if (message.signature !== "") {
2305
+ writer.uint32(18).string(message.signature);
2306
+ }
2307
+ return writer;
2308
+ },
2309
+ decode(input, length) {
2310
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2311
+ let end = length === undefined ? reader.len : reader.pos + length;
2312
+ const message = createBaseHandleStripeWebhookRequest();
2313
+ while (reader.pos < end) {
2314
+ const tag = reader.uint32();
2315
+ switch (tag >>> 3) {
2316
+ case 1: {
2317
+ if (tag !== 10) {
2318
+ break;
2319
+ }
2320
+ message.payload = reader.bytes();
2321
+ continue;
2322
+ }
2323
+ case 2: {
2324
+ if (tag !== 18) {
2325
+ break;
2326
+ }
2327
+ message.signature = reader.string();
2328
+ continue;
2329
+ }
2330
+ }
2331
+ if ((tag & 7) === 4 || tag === 0) {
2332
+ break;
2333
+ }
2334
+ reader.skip(tag & 7);
2335
+ }
2336
+ return message;
2337
+ },
2338
+ fromJSON(object) {
2339
+ return {
2340
+ payload: isSet(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(0),
2341
+ signature: isSet(object.signature) ? globalThis.String(object.signature) : "",
2342
+ };
2343
+ },
2344
+ toJSON(message) {
2345
+ const obj = {};
2346
+ if (message.payload.length !== 0) {
2347
+ obj.payload = base64FromBytes(message.payload);
2348
+ }
2349
+ if (message.signature !== "") {
2350
+ obj.signature = message.signature;
2351
+ }
2352
+ return obj;
2353
+ },
2354
+ create(base) {
2355
+ return exports.HandleStripeWebhookRequest.fromPartial(base !== null && base !== void 0 ? base : {});
2356
+ },
2357
+ fromPartial(object) {
2358
+ var _a, _b;
2359
+ const message = createBaseHandleStripeWebhookRequest();
2360
+ message.payload = (_a = object.payload) !== null && _a !== void 0 ? _a : new Uint8Array(0);
2361
+ message.signature = (_b = object.signature) !== null && _b !== void 0 ? _b : "";
2362
+ return message;
2363
+ },
2364
+ };
2365
+ function createBaseHandleStripeWebhookResponse() {
2366
+ return { success: false, eventId: "", eventType: "", message: "" };
2367
+ }
2368
+ exports.HandleStripeWebhookResponse = {
2369
+ encode(message, writer = new wire_1.BinaryWriter()) {
2370
+ if (message.success !== false) {
2371
+ writer.uint32(8).bool(message.success);
2372
+ }
2373
+ if (message.eventId !== "") {
2374
+ writer.uint32(18).string(message.eventId);
2375
+ }
2376
+ if (message.eventType !== "") {
2377
+ writer.uint32(26).string(message.eventType);
2378
+ }
2379
+ if (message.message !== "") {
2380
+ writer.uint32(34).string(message.message);
2381
+ }
2382
+ return writer;
2383
+ },
2384
+ decode(input, length) {
2385
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2386
+ let end = length === undefined ? reader.len : reader.pos + length;
2387
+ const message = createBaseHandleStripeWebhookResponse();
2388
+ while (reader.pos < end) {
2389
+ const tag = reader.uint32();
2390
+ switch (tag >>> 3) {
2391
+ case 1: {
2392
+ if (tag !== 8) {
2393
+ break;
2394
+ }
2395
+ message.success = reader.bool();
2396
+ continue;
2397
+ }
2398
+ case 2: {
2399
+ if (tag !== 18) {
2400
+ break;
2401
+ }
2402
+ message.eventId = reader.string();
2403
+ continue;
2404
+ }
2405
+ case 3: {
2406
+ if (tag !== 26) {
2407
+ break;
2408
+ }
2409
+ message.eventType = reader.string();
2410
+ continue;
2411
+ }
2412
+ case 4: {
2413
+ if (tag !== 34) {
2414
+ break;
2415
+ }
2416
+ message.message = reader.string();
2417
+ continue;
2418
+ }
2419
+ }
2420
+ if ((tag & 7) === 4 || tag === 0) {
2421
+ break;
2422
+ }
2423
+ reader.skip(tag & 7);
2424
+ }
2425
+ return message;
2426
+ },
2427
+ fromJSON(object) {
2428
+ return {
2429
+ success: isSet(object.success) ? globalThis.Boolean(object.success) : false,
2430
+ eventId: isSet(object.eventId) ? globalThis.String(object.eventId) : "",
2431
+ eventType: isSet(object.eventType) ? globalThis.String(object.eventType) : "",
2432
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
2433
+ };
2434
+ },
2435
+ toJSON(message) {
2436
+ const obj = {};
2437
+ if (message.success !== false) {
2438
+ obj.success = message.success;
2439
+ }
2440
+ if (message.eventId !== "") {
2441
+ obj.eventId = message.eventId;
2442
+ }
2443
+ if (message.eventType !== "") {
2444
+ obj.eventType = message.eventType;
2445
+ }
2446
+ if (message.message !== "") {
2447
+ obj.message = message.message;
2448
+ }
2449
+ return obj;
2450
+ },
2451
+ create(base) {
2452
+ return exports.HandleStripeWebhookResponse.fromPartial(base !== null && base !== void 0 ? base : {});
2453
+ },
2454
+ fromPartial(object) {
2455
+ var _a, _b, _c, _d;
2456
+ const message = createBaseHandleStripeWebhookResponse();
2457
+ message.success = (_a = object.success) !== null && _a !== void 0 ? _a : false;
2458
+ message.eventId = (_b = object.eventId) !== null && _b !== void 0 ? _b : "";
2459
+ message.eventType = (_c = object.eventType) !== null && _c !== void 0 ? _c : "";
2460
+ message.message = (_d = object.message) !== null && _d !== void 0 ? _d : "";
2461
+ return message;
2462
+ },
2463
+ };
2464
+ function createBaseGetUsageSummaryRequest() {
2465
+ return { period: "", startDate: undefined, endDate: undefined };
2466
+ }
2467
+ exports.GetUsageSummaryRequest = {
2468
+ encode(message, writer = new wire_1.BinaryWriter()) {
2469
+ if (message.period !== "") {
2470
+ writer.uint32(10).string(message.period);
2471
+ }
2472
+ if (message.startDate !== undefined) {
2473
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.startDate), writer.uint32(18).fork()).join();
2474
+ }
2475
+ if (message.endDate !== undefined) {
2476
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.endDate), writer.uint32(26).fork()).join();
2477
+ }
2478
+ return writer;
2479
+ },
2480
+ decode(input, length) {
2481
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2482
+ let end = length === undefined ? reader.len : reader.pos + length;
2483
+ const message = createBaseGetUsageSummaryRequest();
2484
+ while (reader.pos < end) {
2485
+ const tag = reader.uint32();
2486
+ switch (tag >>> 3) {
2487
+ case 1: {
2488
+ if (tag !== 10) {
2489
+ break;
2490
+ }
2491
+ message.period = reader.string();
2492
+ continue;
2493
+ }
2494
+ case 2: {
2495
+ if (tag !== 18) {
2496
+ break;
2497
+ }
2498
+ message.startDate = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
2499
+ continue;
2500
+ }
2501
+ case 3: {
2502
+ if (tag !== 26) {
2503
+ break;
2504
+ }
2505
+ message.endDate = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
2506
+ continue;
2507
+ }
2508
+ }
2509
+ if ((tag & 7) === 4 || tag === 0) {
2510
+ break;
2511
+ }
2512
+ reader.skip(tag & 7);
2513
+ }
2514
+ return message;
2515
+ },
2516
+ fromJSON(object) {
2517
+ return {
2518
+ period: isSet(object.period) ? globalThis.String(object.period) : "",
2519
+ startDate: isSet(object.startDate) ? fromJsonTimestamp(object.startDate) : undefined,
2520
+ endDate: isSet(object.endDate) ? fromJsonTimestamp(object.endDate) : undefined,
2521
+ };
2522
+ },
2523
+ toJSON(message) {
2524
+ const obj = {};
2525
+ if (message.period !== "") {
2526
+ obj.period = message.period;
2527
+ }
2528
+ if (message.startDate !== undefined) {
2529
+ obj.startDate = message.startDate.toISOString();
2530
+ }
2531
+ if (message.endDate !== undefined) {
2532
+ obj.endDate = message.endDate.toISOString();
2533
+ }
2534
+ return obj;
2535
+ },
2536
+ create(base) {
2537
+ return exports.GetUsageSummaryRequest.fromPartial(base !== null && base !== void 0 ? base : {});
2538
+ },
2539
+ fromPartial(object) {
2540
+ var _a, _b, _c;
2541
+ const message = createBaseGetUsageSummaryRequest();
2542
+ message.period = (_a = object.period) !== null && _a !== void 0 ? _a : "";
2543
+ message.startDate = (_b = object.startDate) !== null && _b !== void 0 ? _b : undefined;
2544
+ message.endDate = (_c = object.endDate) !== null && _c !== void 0 ? _c : undefined;
2545
+ return message;
2546
+ },
2547
+ };
2548
+ function createBaseGetUsageSummaryResponse() {
2549
+ return { currentPeriod: undefined, previousPeriods: [], limits: undefined };
2550
+ }
2551
+ exports.GetUsageSummaryResponse = {
2552
+ encode(message, writer = new wire_1.BinaryWriter()) {
2553
+ if (message.currentPeriod !== undefined) {
2554
+ exports.UsagePeriod.encode(message.currentPeriod, writer.uint32(10).fork()).join();
2555
+ }
2556
+ for (const v of message.previousPeriods) {
2557
+ exports.UsagePeriod.encode(v, writer.uint32(18).fork()).join();
2558
+ }
2559
+ if (message.limits !== undefined) {
2560
+ exports.UsageLimits.encode(message.limits, writer.uint32(26).fork()).join();
2561
+ }
2562
+ return writer;
2563
+ },
2564
+ decode(input, length) {
2565
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2566
+ let end = length === undefined ? reader.len : reader.pos + length;
2567
+ const message = createBaseGetUsageSummaryResponse();
2568
+ while (reader.pos < end) {
2569
+ const tag = reader.uint32();
2570
+ switch (tag >>> 3) {
2571
+ case 1: {
2572
+ if (tag !== 10) {
2573
+ break;
2574
+ }
2575
+ message.currentPeriod = exports.UsagePeriod.decode(reader, reader.uint32());
2576
+ continue;
2577
+ }
2578
+ case 2: {
2579
+ if (tag !== 18) {
2580
+ break;
2581
+ }
2582
+ message.previousPeriods.push(exports.UsagePeriod.decode(reader, reader.uint32()));
2583
+ continue;
2584
+ }
2585
+ case 3: {
2586
+ if (tag !== 26) {
2587
+ break;
2588
+ }
2589
+ message.limits = exports.UsageLimits.decode(reader, reader.uint32());
2590
+ continue;
2591
+ }
2592
+ }
2593
+ if ((tag & 7) === 4 || tag === 0) {
2594
+ break;
2595
+ }
2596
+ reader.skip(tag & 7);
2597
+ }
2598
+ return message;
2599
+ },
2600
+ fromJSON(object) {
2601
+ return {
2602
+ currentPeriod: isSet(object.currentPeriod) ? exports.UsagePeriod.fromJSON(object.currentPeriod) : undefined,
2603
+ previousPeriods: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.previousPeriods)
2604
+ ? object.previousPeriods.map((e) => exports.UsagePeriod.fromJSON(e))
2605
+ : [],
2606
+ limits: isSet(object.limits) ? exports.UsageLimits.fromJSON(object.limits) : undefined,
2607
+ };
2608
+ },
2609
+ toJSON(message) {
2610
+ var _a;
2611
+ const obj = {};
2612
+ if (message.currentPeriod !== undefined) {
2613
+ obj.currentPeriod = exports.UsagePeriod.toJSON(message.currentPeriod);
2614
+ }
2615
+ if ((_a = message.previousPeriods) === null || _a === void 0 ? void 0 : _a.length) {
2616
+ obj.previousPeriods = message.previousPeriods.map((e) => exports.UsagePeriod.toJSON(e));
2617
+ }
2618
+ if (message.limits !== undefined) {
2619
+ obj.limits = exports.UsageLimits.toJSON(message.limits);
2620
+ }
2621
+ return obj;
2622
+ },
2623
+ create(base) {
2624
+ return exports.GetUsageSummaryResponse.fromPartial(base !== null && base !== void 0 ? base : {});
2625
+ },
2626
+ fromPartial(object) {
2627
+ var _a;
2628
+ const message = createBaseGetUsageSummaryResponse();
2629
+ message.currentPeriod = (object.currentPeriod !== undefined && object.currentPeriod !== null)
2630
+ ? exports.UsagePeriod.fromPartial(object.currentPeriod)
2631
+ : undefined;
2632
+ message.previousPeriods = ((_a = object.previousPeriods) === null || _a === void 0 ? void 0 : _a.map((e) => exports.UsagePeriod.fromPartial(e))) || [];
2633
+ message.limits = (object.limits !== undefined && object.limits !== null)
2634
+ ? exports.UsageLimits.fromPartial(object.limits)
2635
+ : undefined;
2636
+ return message;
2637
+ },
2638
+ };
2639
+ function createBaseUsagePeriod() {
2640
+ return {
2641
+ startDate: undefined,
2642
+ endDate: undefined,
2643
+ apiRequests: 0,
2644
+ apiRequestsLimit: 0,
2645
+ usagePercentage: 0,
2646
+ requestsByEndpoint: {},
2647
+ requestsByApiKey: {},
2648
+ billableRequests: 0,
2649
+ overageRequests: 0,
2650
+ overageCostCents: 0,
2651
+ };
2652
+ }
2653
+ exports.UsagePeriod = {
2654
+ encode(message, writer = new wire_1.BinaryWriter()) {
2655
+ if (message.startDate !== undefined) {
2656
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.startDate), writer.uint32(10).fork()).join();
2657
+ }
2658
+ if (message.endDate !== undefined) {
2659
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.endDate), writer.uint32(18).fork()).join();
2660
+ }
2661
+ if (message.apiRequests !== 0) {
2662
+ writer.uint32(24).int64(message.apiRequests);
2663
+ }
2664
+ if (message.apiRequestsLimit !== 0) {
2665
+ writer.uint32(32).int64(message.apiRequestsLimit);
2666
+ }
2667
+ if (message.usagePercentage !== 0) {
2668
+ writer.uint32(41).double(message.usagePercentage);
2669
+ }
2670
+ Object.entries(message.requestsByEndpoint).forEach(([key, value]) => {
2671
+ exports.UsagePeriod_RequestsByEndpointEntry.encode({ key: key, value }, writer.uint32(50).fork()).join();
2672
+ });
2673
+ Object.entries(message.requestsByApiKey).forEach(([key, value]) => {
2674
+ exports.UsagePeriod_RequestsByApiKeyEntry.encode({ key: key, value }, writer.uint32(58).fork()).join();
2675
+ });
2676
+ if (message.billableRequests !== 0) {
2677
+ writer.uint32(64).int64(message.billableRequests);
2678
+ }
2679
+ if (message.overageRequests !== 0) {
2680
+ writer.uint32(72).int64(message.overageRequests);
2681
+ }
2682
+ if (message.overageCostCents !== 0) {
2683
+ writer.uint32(80).int64(message.overageCostCents);
2684
+ }
2685
+ return writer;
2686
+ },
2687
+ decode(input, length) {
2688
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2689
+ let end = length === undefined ? reader.len : reader.pos + length;
2690
+ const message = createBaseUsagePeriod();
2691
+ while (reader.pos < end) {
2692
+ const tag = reader.uint32();
2693
+ switch (tag >>> 3) {
2694
+ case 1: {
2695
+ if (tag !== 10) {
2696
+ break;
2697
+ }
2698
+ message.startDate = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
2699
+ continue;
2700
+ }
2701
+ case 2: {
2702
+ if (tag !== 18) {
2703
+ break;
2704
+ }
2705
+ message.endDate = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
2706
+ continue;
2707
+ }
2708
+ case 3: {
2709
+ if (tag !== 24) {
2710
+ break;
2711
+ }
2712
+ message.apiRequests = longToNumber(reader.int64());
2713
+ continue;
2714
+ }
2715
+ case 4: {
2716
+ if (tag !== 32) {
2717
+ break;
2718
+ }
2719
+ message.apiRequestsLimit = longToNumber(reader.int64());
2720
+ continue;
2721
+ }
2722
+ case 5: {
2723
+ if (tag !== 41) {
2724
+ break;
2725
+ }
2726
+ message.usagePercentage = reader.double();
2727
+ continue;
2728
+ }
2729
+ case 6: {
2730
+ if (tag !== 50) {
2731
+ break;
2732
+ }
2733
+ const entry6 = exports.UsagePeriod_RequestsByEndpointEntry.decode(reader, reader.uint32());
2734
+ if (entry6.value !== undefined) {
2735
+ message.requestsByEndpoint[entry6.key] = entry6.value;
2736
+ }
2737
+ continue;
2738
+ }
2739
+ case 7: {
2740
+ if (tag !== 58) {
2741
+ break;
2742
+ }
2743
+ const entry7 = exports.UsagePeriod_RequestsByApiKeyEntry.decode(reader, reader.uint32());
2744
+ if (entry7.value !== undefined) {
2745
+ message.requestsByApiKey[entry7.key] = entry7.value;
2746
+ }
2747
+ continue;
2748
+ }
2749
+ case 8: {
2750
+ if (tag !== 64) {
2751
+ break;
2752
+ }
2753
+ message.billableRequests = longToNumber(reader.int64());
2754
+ continue;
2755
+ }
2756
+ case 9: {
2757
+ if (tag !== 72) {
2758
+ break;
2759
+ }
2760
+ message.overageRequests = longToNumber(reader.int64());
2761
+ continue;
2762
+ }
2763
+ case 10: {
2764
+ if (tag !== 80) {
2765
+ break;
2766
+ }
2767
+ message.overageCostCents = longToNumber(reader.int64());
2768
+ continue;
2769
+ }
2770
+ }
2771
+ if ((tag & 7) === 4 || tag === 0) {
2772
+ break;
2773
+ }
2774
+ reader.skip(tag & 7);
2775
+ }
2776
+ return message;
2777
+ },
2778
+ fromJSON(object) {
2779
+ return {
2780
+ startDate: isSet(object.startDate) ? fromJsonTimestamp(object.startDate) : undefined,
2781
+ endDate: isSet(object.endDate) ? fromJsonTimestamp(object.endDate) : undefined,
2782
+ apiRequests: isSet(object.apiRequests) ? globalThis.Number(object.apiRequests) : 0,
2783
+ apiRequestsLimit: isSet(object.apiRequestsLimit) ? globalThis.Number(object.apiRequestsLimit) : 0,
2784
+ usagePercentage: isSet(object.usagePercentage) ? globalThis.Number(object.usagePercentage) : 0,
2785
+ requestsByEndpoint: isObject(object.requestsByEndpoint)
2786
+ ? Object.entries(object.requestsByEndpoint).reduce((acc, [key, value]) => {
2787
+ acc[key] = Number(value);
2788
+ return acc;
2789
+ }, {})
2790
+ : {},
2791
+ requestsByApiKey: isObject(object.requestsByApiKey)
2792
+ ? Object.entries(object.requestsByApiKey).reduce((acc, [key, value]) => {
2793
+ acc[key] = Number(value);
2794
+ return acc;
2795
+ }, {})
2796
+ : {},
2797
+ billableRequests: isSet(object.billableRequests) ? globalThis.Number(object.billableRequests) : 0,
2798
+ overageRequests: isSet(object.overageRequests) ? globalThis.Number(object.overageRequests) : 0,
2799
+ overageCostCents: isSet(object.overageCostCents) ? globalThis.Number(object.overageCostCents) : 0,
2800
+ };
2801
+ },
2802
+ toJSON(message) {
2803
+ const obj = {};
2804
+ if (message.startDate !== undefined) {
2805
+ obj.startDate = message.startDate.toISOString();
2806
+ }
2807
+ if (message.endDate !== undefined) {
2808
+ obj.endDate = message.endDate.toISOString();
2809
+ }
2810
+ if (message.apiRequests !== 0) {
2811
+ obj.apiRequests = Math.round(message.apiRequests);
2812
+ }
2813
+ if (message.apiRequestsLimit !== 0) {
2814
+ obj.apiRequestsLimit = Math.round(message.apiRequestsLimit);
2815
+ }
2816
+ if (message.usagePercentage !== 0) {
2817
+ obj.usagePercentage = message.usagePercentage;
2818
+ }
2819
+ if (message.requestsByEndpoint) {
2820
+ const entries = Object.entries(message.requestsByEndpoint);
2821
+ if (entries.length > 0) {
2822
+ obj.requestsByEndpoint = {};
2823
+ entries.forEach(([k, v]) => {
2824
+ obj.requestsByEndpoint[k] = Math.round(v);
2825
+ });
2826
+ }
2827
+ }
2828
+ if (message.requestsByApiKey) {
2829
+ const entries = Object.entries(message.requestsByApiKey);
2830
+ if (entries.length > 0) {
2831
+ obj.requestsByApiKey = {};
2832
+ entries.forEach(([k, v]) => {
2833
+ obj.requestsByApiKey[k] = Math.round(v);
2834
+ });
2835
+ }
2836
+ }
2837
+ if (message.billableRequests !== 0) {
2838
+ obj.billableRequests = Math.round(message.billableRequests);
2839
+ }
2840
+ if (message.overageRequests !== 0) {
2841
+ obj.overageRequests = Math.round(message.overageRequests);
2842
+ }
2843
+ if (message.overageCostCents !== 0) {
2844
+ obj.overageCostCents = Math.round(message.overageCostCents);
2845
+ }
2846
+ return obj;
2847
+ },
2848
+ create(base) {
2849
+ return exports.UsagePeriod.fromPartial(base !== null && base !== void 0 ? base : {});
2850
+ },
2851
+ fromPartial(object) {
2852
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2853
+ const message = createBaseUsagePeriod();
2854
+ message.startDate = (_a = object.startDate) !== null && _a !== void 0 ? _a : undefined;
2855
+ message.endDate = (_b = object.endDate) !== null && _b !== void 0 ? _b : undefined;
2856
+ message.apiRequests = (_c = object.apiRequests) !== null && _c !== void 0 ? _c : 0;
2857
+ message.apiRequestsLimit = (_d = object.apiRequestsLimit) !== null && _d !== void 0 ? _d : 0;
2858
+ message.usagePercentage = (_e = object.usagePercentage) !== null && _e !== void 0 ? _e : 0;
2859
+ message.requestsByEndpoint = Object.entries((_f = object.requestsByEndpoint) !== null && _f !== void 0 ? _f : {}).reduce((acc, [key, value]) => {
2860
+ if (value !== undefined) {
2861
+ acc[key] = globalThis.Number(value);
2862
+ }
2863
+ return acc;
2864
+ }, {});
2865
+ message.requestsByApiKey = Object.entries((_g = object.requestsByApiKey) !== null && _g !== void 0 ? _g : {}).reduce((acc, [key, value]) => {
2866
+ if (value !== undefined) {
2867
+ acc[key] = globalThis.Number(value);
2868
+ }
2869
+ return acc;
2870
+ }, {});
2871
+ message.billableRequests = (_h = object.billableRequests) !== null && _h !== void 0 ? _h : 0;
2872
+ message.overageRequests = (_j = object.overageRequests) !== null && _j !== void 0 ? _j : 0;
2873
+ message.overageCostCents = (_k = object.overageCostCents) !== null && _k !== void 0 ? _k : 0;
2874
+ return message;
2875
+ },
2876
+ };
2877
+ function createBaseUsagePeriod_RequestsByEndpointEntry() {
2878
+ return { key: "", value: 0 };
2879
+ }
2880
+ exports.UsagePeriod_RequestsByEndpointEntry = {
2881
+ encode(message, writer = new wire_1.BinaryWriter()) {
2882
+ if (message.key !== "") {
2883
+ writer.uint32(10).string(message.key);
2884
+ }
2885
+ if (message.value !== 0) {
2886
+ writer.uint32(16).int64(message.value);
2887
+ }
2888
+ return writer;
2889
+ },
2890
+ decode(input, length) {
2891
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2892
+ let end = length === undefined ? reader.len : reader.pos + length;
2893
+ const message = createBaseUsagePeriod_RequestsByEndpointEntry();
2894
+ while (reader.pos < end) {
2895
+ const tag = reader.uint32();
2896
+ switch (tag >>> 3) {
2897
+ case 1: {
2898
+ if (tag !== 10) {
2899
+ break;
2900
+ }
2901
+ message.key = reader.string();
2902
+ continue;
2903
+ }
2904
+ case 2: {
2905
+ if (tag !== 16) {
2906
+ break;
2907
+ }
2908
+ message.value = longToNumber(reader.int64());
2909
+ continue;
2910
+ }
2911
+ }
2912
+ if ((tag & 7) === 4 || tag === 0) {
2913
+ break;
2914
+ }
2915
+ reader.skip(tag & 7);
2916
+ }
2917
+ return message;
2918
+ },
2919
+ fromJSON(object) {
2920
+ return {
2921
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
2922
+ value: isSet(object.value) ? globalThis.Number(object.value) : 0,
2923
+ };
2924
+ },
2925
+ toJSON(message) {
2926
+ const obj = {};
2927
+ if (message.key !== "") {
2928
+ obj.key = message.key;
2929
+ }
2930
+ if (message.value !== 0) {
2931
+ obj.value = Math.round(message.value);
2932
+ }
2933
+ return obj;
2934
+ },
2935
+ create(base) {
2936
+ return exports.UsagePeriod_RequestsByEndpointEntry.fromPartial(base !== null && base !== void 0 ? base : {});
2937
+ },
2938
+ fromPartial(object) {
2939
+ var _a, _b;
2940
+ const message = createBaseUsagePeriod_RequestsByEndpointEntry();
2941
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
2942
+ message.value = (_b = object.value) !== null && _b !== void 0 ? _b : 0;
2943
+ return message;
2944
+ },
2945
+ };
2946
+ function createBaseUsagePeriod_RequestsByApiKeyEntry() {
2947
+ return { key: "", value: 0 };
2948
+ }
2949
+ exports.UsagePeriod_RequestsByApiKeyEntry = {
2950
+ encode(message, writer = new wire_1.BinaryWriter()) {
2951
+ if (message.key !== "") {
2952
+ writer.uint32(10).string(message.key);
2953
+ }
2954
+ if (message.value !== 0) {
2955
+ writer.uint32(16).int64(message.value);
2956
+ }
2957
+ return writer;
2958
+ },
2959
+ decode(input, length) {
2960
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2961
+ let end = length === undefined ? reader.len : reader.pos + length;
2962
+ const message = createBaseUsagePeriod_RequestsByApiKeyEntry();
2963
+ while (reader.pos < end) {
2964
+ const tag = reader.uint32();
2965
+ switch (tag >>> 3) {
2966
+ case 1: {
2967
+ if (tag !== 10) {
2968
+ break;
2969
+ }
2970
+ message.key = reader.string();
2971
+ continue;
2972
+ }
2973
+ case 2: {
2974
+ if (tag !== 16) {
2975
+ break;
2976
+ }
2977
+ message.value = longToNumber(reader.int64());
2978
+ continue;
2979
+ }
2980
+ }
2981
+ if ((tag & 7) === 4 || tag === 0) {
2982
+ break;
2983
+ }
2984
+ reader.skip(tag & 7);
2985
+ }
2986
+ return message;
2987
+ },
2988
+ fromJSON(object) {
2989
+ return {
2990
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
2991
+ value: isSet(object.value) ? globalThis.Number(object.value) : 0,
2992
+ };
2993
+ },
2994
+ toJSON(message) {
2995
+ const obj = {};
2996
+ if (message.key !== "") {
2997
+ obj.key = message.key;
2998
+ }
2999
+ if (message.value !== 0) {
3000
+ obj.value = Math.round(message.value);
3001
+ }
3002
+ return obj;
3003
+ },
3004
+ create(base) {
3005
+ return exports.UsagePeriod_RequestsByApiKeyEntry.fromPartial(base !== null && base !== void 0 ? base : {});
3006
+ },
3007
+ fromPartial(object) {
3008
+ var _a, _b;
3009
+ const message = createBaseUsagePeriod_RequestsByApiKeyEntry();
3010
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
3011
+ message.value = (_b = object.value) !== null && _b !== void 0 ? _b : 0;
3012
+ return message;
3013
+ },
3014
+ };
3015
+ function createBaseUsageLimits() {
3016
+ return {
3017
+ tier: "",
3018
+ requestsPerHour: 0,
3019
+ requestsPerDay: 0,
3020
+ requestsPerMonth: 0,
3021
+ unlimited: false,
3022
+ overageRateCents: 0,
3023
+ };
3024
+ }
3025
+ exports.UsageLimits = {
3026
+ encode(message, writer = new wire_1.BinaryWriter()) {
3027
+ if (message.tier !== "") {
3028
+ writer.uint32(10).string(message.tier);
3029
+ }
3030
+ if (message.requestsPerHour !== 0) {
3031
+ writer.uint32(16).int64(message.requestsPerHour);
3032
+ }
3033
+ if (message.requestsPerDay !== 0) {
3034
+ writer.uint32(24).int64(message.requestsPerDay);
3035
+ }
3036
+ if (message.requestsPerMonth !== 0) {
3037
+ writer.uint32(32).int64(message.requestsPerMonth);
3038
+ }
3039
+ if (message.unlimited !== false) {
3040
+ writer.uint32(40).bool(message.unlimited);
3041
+ }
3042
+ if (message.overageRateCents !== 0) {
3043
+ writer.uint32(48).int64(message.overageRateCents);
3044
+ }
3045
+ return writer;
3046
+ },
3047
+ decode(input, length) {
3048
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
3049
+ let end = length === undefined ? reader.len : reader.pos + length;
3050
+ const message = createBaseUsageLimits();
3051
+ while (reader.pos < end) {
3052
+ const tag = reader.uint32();
3053
+ switch (tag >>> 3) {
3054
+ case 1: {
3055
+ if (tag !== 10) {
3056
+ break;
3057
+ }
3058
+ message.tier = reader.string();
3059
+ continue;
3060
+ }
3061
+ case 2: {
3062
+ if (tag !== 16) {
3063
+ break;
3064
+ }
3065
+ message.requestsPerHour = longToNumber(reader.int64());
3066
+ continue;
3067
+ }
3068
+ case 3: {
3069
+ if (tag !== 24) {
3070
+ break;
3071
+ }
3072
+ message.requestsPerDay = longToNumber(reader.int64());
3073
+ continue;
3074
+ }
3075
+ case 4: {
3076
+ if (tag !== 32) {
3077
+ break;
3078
+ }
3079
+ message.requestsPerMonth = longToNumber(reader.int64());
3080
+ continue;
3081
+ }
3082
+ case 5: {
3083
+ if (tag !== 40) {
3084
+ break;
3085
+ }
3086
+ message.unlimited = reader.bool();
3087
+ continue;
3088
+ }
3089
+ case 6: {
3090
+ if (tag !== 48) {
3091
+ break;
3092
+ }
3093
+ message.overageRateCents = longToNumber(reader.int64());
3094
+ continue;
3095
+ }
3096
+ }
3097
+ if ((tag & 7) === 4 || tag === 0) {
3098
+ break;
3099
+ }
3100
+ reader.skip(tag & 7);
3101
+ }
3102
+ return message;
3103
+ },
3104
+ fromJSON(object) {
3105
+ return {
3106
+ tier: isSet(object.tier) ? globalThis.String(object.tier) : "",
3107
+ requestsPerHour: isSet(object.requestsPerHour) ? globalThis.Number(object.requestsPerHour) : 0,
3108
+ requestsPerDay: isSet(object.requestsPerDay) ? globalThis.Number(object.requestsPerDay) : 0,
3109
+ requestsPerMonth: isSet(object.requestsPerMonth) ? globalThis.Number(object.requestsPerMonth) : 0,
3110
+ unlimited: isSet(object.unlimited) ? globalThis.Boolean(object.unlimited) : false,
3111
+ overageRateCents: isSet(object.overageRateCents) ? globalThis.Number(object.overageRateCents) : 0,
3112
+ };
3113
+ },
3114
+ toJSON(message) {
3115
+ const obj = {};
3116
+ if (message.tier !== "") {
3117
+ obj.tier = message.tier;
3118
+ }
3119
+ if (message.requestsPerHour !== 0) {
3120
+ obj.requestsPerHour = Math.round(message.requestsPerHour);
3121
+ }
3122
+ if (message.requestsPerDay !== 0) {
3123
+ obj.requestsPerDay = Math.round(message.requestsPerDay);
3124
+ }
3125
+ if (message.requestsPerMonth !== 0) {
3126
+ obj.requestsPerMonth = Math.round(message.requestsPerMonth);
3127
+ }
3128
+ if (message.unlimited !== false) {
3129
+ obj.unlimited = message.unlimited;
3130
+ }
3131
+ if (message.overageRateCents !== 0) {
3132
+ obj.overageRateCents = Math.round(message.overageRateCents);
3133
+ }
3134
+ return obj;
3135
+ },
3136
+ create(base) {
3137
+ return exports.UsageLimits.fromPartial(base !== null && base !== void 0 ? base : {});
3138
+ },
3139
+ fromPartial(object) {
3140
+ var _a, _b, _c, _d, _e, _f;
3141
+ const message = createBaseUsageLimits();
3142
+ message.tier = (_a = object.tier) !== null && _a !== void 0 ? _a : "";
3143
+ message.requestsPerHour = (_b = object.requestsPerHour) !== null && _b !== void 0 ? _b : 0;
3144
+ message.requestsPerDay = (_c = object.requestsPerDay) !== null && _c !== void 0 ? _c : 0;
3145
+ message.requestsPerMonth = (_d = object.requestsPerMonth) !== null && _d !== void 0 ? _d : 0;
3146
+ message.unlimited = (_e = object.unlimited) !== null && _e !== void 0 ? _e : false;
3147
+ message.overageRateCents = (_f = object.overageRateCents) !== null && _f !== void 0 ? _f : 0;
3148
+ return message;
3149
+ },
3150
+ };
3151
+ function createBaseGetCreditBalanceRequest() {
3152
+ return {};
3153
+ }
3154
+ exports.GetCreditBalanceRequest = {
3155
+ encode(_, writer = new wire_1.BinaryWriter()) {
3156
+ return writer;
3157
+ },
3158
+ decode(input, length) {
3159
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
3160
+ let end = length === undefined ? reader.len : reader.pos + length;
3161
+ const message = createBaseGetCreditBalanceRequest();
3162
+ while (reader.pos < end) {
3163
+ const tag = reader.uint32();
3164
+ switch (tag >>> 3) {
3165
+ }
3166
+ if ((tag & 7) === 4 || tag === 0) {
3167
+ break;
3168
+ }
3169
+ reader.skip(tag & 7);
3170
+ }
3171
+ return message;
3172
+ },
3173
+ fromJSON(_) {
3174
+ return {};
3175
+ },
3176
+ toJSON(_) {
3177
+ const obj = {};
3178
+ return obj;
3179
+ },
3180
+ create(base) {
3181
+ return exports.GetCreditBalanceRequest.fromPartial(base !== null && base !== void 0 ? base : {});
3182
+ },
3183
+ fromPartial(_) {
3184
+ const message = createBaseGetCreditBalanceRequest();
3185
+ return message;
3186
+ },
3187
+ };
3188
+ function createBaseGetCreditBalanceResponse() {
3189
+ return { credits: 0, pendingCredits: 0, expiresAt: undefined, recentTransactions: [] };
3190
+ }
3191
+ exports.GetCreditBalanceResponse = {
3192
+ encode(message, writer = new wire_1.BinaryWriter()) {
3193
+ if (message.credits !== 0) {
3194
+ writer.uint32(8).int64(message.credits);
3195
+ }
3196
+ if (message.pendingCredits !== 0) {
3197
+ writer.uint32(16).int64(message.pendingCredits);
3198
+ }
3199
+ if (message.expiresAt !== undefined) {
3200
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(26).fork()).join();
3201
+ }
3202
+ for (const v of message.recentTransactions) {
3203
+ exports.CreditTransaction.encode(v, writer.uint32(34).fork()).join();
3204
+ }
3205
+ return writer;
3206
+ },
3207
+ decode(input, length) {
3208
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
3209
+ let end = length === undefined ? reader.len : reader.pos + length;
3210
+ const message = createBaseGetCreditBalanceResponse();
3211
+ while (reader.pos < end) {
3212
+ const tag = reader.uint32();
3213
+ switch (tag >>> 3) {
3214
+ case 1: {
3215
+ if (tag !== 8) {
3216
+ break;
3217
+ }
3218
+ message.credits = longToNumber(reader.int64());
3219
+ continue;
3220
+ }
3221
+ case 2: {
3222
+ if (tag !== 16) {
3223
+ break;
3224
+ }
3225
+ message.pendingCredits = longToNumber(reader.int64());
3226
+ continue;
3227
+ }
3228
+ case 3: {
3229
+ if (tag !== 26) {
3230
+ break;
3231
+ }
3232
+ message.expiresAt = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
3233
+ continue;
3234
+ }
3235
+ case 4: {
3236
+ if (tag !== 34) {
3237
+ break;
3238
+ }
3239
+ message.recentTransactions.push(exports.CreditTransaction.decode(reader, reader.uint32()));
3240
+ continue;
3241
+ }
3242
+ }
3243
+ if ((tag & 7) === 4 || tag === 0) {
3244
+ break;
3245
+ }
3246
+ reader.skip(tag & 7);
3247
+ }
3248
+ return message;
3249
+ },
3250
+ fromJSON(object) {
3251
+ return {
3252
+ credits: isSet(object.credits) ? globalThis.Number(object.credits) : 0,
3253
+ pendingCredits: isSet(object.pendingCredits) ? globalThis.Number(object.pendingCredits) : 0,
3254
+ expiresAt: isSet(object.expiresAt) ? fromJsonTimestamp(object.expiresAt) : undefined,
3255
+ recentTransactions: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.recentTransactions)
3256
+ ? object.recentTransactions.map((e) => exports.CreditTransaction.fromJSON(e))
3257
+ : [],
3258
+ };
3259
+ },
3260
+ toJSON(message) {
3261
+ var _a;
3262
+ const obj = {};
3263
+ if (message.credits !== 0) {
3264
+ obj.credits = Math.round(message.credits);
3265
+ }
3266
+ if (message.pendingCredits !== 0) {
3267
+ obj.pendingCredits = Math.round(message.pendingCredits);
3268
+ }
3269
+ if (message.expiresAt !== undefined) {
3270
+ obj.expiresAt = message.expiresAt.toISOString();
3271
+ }
3272
+ if ((_a = message.recentTransactions) === null || _a === void 0 ? void 0 : _a.length) {
3273
+ obj.recentTransactions = message.recentTransactions.map((e) => exports.CreditTransaction.toJSON(e));
3274
+ }
3275
+ return obj;
3276
+ },
3277
+ create(base) {
3278
+ return exports.GetCreditBalanceResponse.fromPartial(base !== null && base !== void 0 ? base : {});
3279
+ },
3280
+ fromPartial(object) {
3281
+ var _a, _b, _c, _d;
3282
+ const message = createBaseGetCreditBalanceResponse();
3283
+ message.credits = (_a = object.credits) !== null && _a !== void 0 ? _a : 0;
3284
+ message.pendingCredits = (_b = object.pendingCredits) !== null && _b !== void 0 ? _b : 0;
3285
+ message.expiresAt = (_c = object.expiresAt) !== null && _c !== void 0 ? _c : undefined;
3286
+ message.recentTransactions = ((_d = object.recentTransactions) === null || _d === void 0 ? void 0 : _d.map((e) => exports.CreditTransaction.fromPartial(e))) || [];
3287
+ return message;
3288
+ },
3289
+ };
3290
+ function createBaseCreditTransaction() {
3291
+ return { id: "", type: "", amount: 0, description: "", createdAt: undefined };
3292
+ }
3293
+ exports.CreditTransaction = {
3294
+ encode(message, writer = new wire_1.BinaryWriter()) {
3295
+ if (message.id !== "") {
3296
+ writer.uint32(10).string(message.id);
3297
+ }
3298
+ if (message.type !== "") {
3299
+ writer.uint32(18).string(message.type);
3300
+ }
3301
+ if (message.amount !== 0) {
3302
+ writer.uint32(24).int64(message.amount);
3303
+ }
3304
+ if (message.description !== "") {
3305
+ writer.uint32(34).string(message.description);
3306
+ }
3307
+ if (message.createdAt !== undefined) {
3308
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(42).fork()).join();
3309
+ }
3310
+ return writer;
3311
+ },
3312
+ decode(input, length) {
3313
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
3314
+ let end = length === undefined ? reader.len : reader.pos + length;
3315
+ const message = createBaseCreditTransaction();
3316
+ while (reader.pos < end) {
3317
+ const tag = reader.uint32();
3318
+ switch (tag >>> 3) {
3319
+ case 1: {
3320
+ if (tag !== 10) {
3321
+ break;
3322
+ }
3323
+ message.id = reader.string();
3324
+ continue;
3325
+ }
3326
+ case 2: {
3327
+ if (tag !== 18) {
3328
+ break;
3329
+ }
3330
+ message.type = reader.string();
3331
+ continue;
3332
+ }
3333
+ case 3: {
3334
+ if (tag !== 24) {
3335
+ break;
3336
+ }
3337
+ message.amount = longToNumber(reader.int64());
3338
+ continue;
3339
+ }
3340
+ case 4: {
3341
+ if (tag !== 34) {
3342
+ break;
3343
+ }
3344
+ message.description = reader.string();
3345
+ continue;
3346
+ }
3347
+ case 5: {
3348
+ if (tag !== 42) {
3349
+ break;
3350
+ }
3351
+ message.createdAt = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
3352
+ continue;
3353
+ }
3354
+ }
3355
+ if ((tag & 7) === 4 || tag === 0) {
3356
+ break;
3357
+ }
3358
+ reader.skip(tag & 7);
3359
+ }
3360
+ return message;
3361
+ },
3362
+ fromJSON(object) {
3363
+ return {
3364
+ id: isSet(object.id) ? globalThis.String(object.id) : "",
3365
+ type: isSet(object.type) ? globalThis.String(object.type) : "",
3366
+ amount: isSet(object.amount) ? globalThis.Number(object.amount) : 0,
3367
+ description: isSet(object.description) ? globalThis.String(object.description) : "",
3368
+ createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined,
3369
+ };
3370
+ },
3371
+ toJSON(message) {
3372
+ const obj = {};
3373
+ if (message.id !== "") {
3374
+ obj.id = message.id;
3375
+ }
3376
+ if (message.type !== "") {
3377
+ obj.type = message.type;
3378
+ }
3379
+ if (message.amount !== 0) {
3380
+ obj.amount = Math.round(message.amount);
3381
+ }
3382
+ if (message.description !== "") {
3383
+ obj.description = message.description;
3384
+ }
3385
+ if (message.createdAt !== undefined) {
3386
+ obj.createdAt = message.createdAt.toISOString();
3387
+ }
3388
+ return obj;
3389
+ },
3390
+ create(base) {
3391
+ return exports.CreditTransaction.fromPartial(base !== null && base !== void 0 ? base : {});
3392
+ },
3393
+ fromPartial(object) {
3394
+ var _a, _b, _c, _d, _e;
3395
+ const message = createBaseCreditTransaction();
3396
+ message.id = (_a = object.id) !== null && _a !== void 0 ? _a : "";
3397
+ message.type = (_b = object.type) !== null && _b !== void 0 ? _b : "";
3398
+ message.amount = (_c = object.amount) !== null && _c !== void 0 ? _c : 0;
3399
+ message.description = (_d = object.description) !== null && _d !== void 0 ? _d : "";
3400
+ message.createdAt = (_e = object.createdAt) !== null && _e !== void 0 ? _e : undefined;
3401
+ return message;
3402
+ },
3403
+ };
3404
+ function createBaseUpdateTaxInfoRequest() {
3405
+ return { taxId: "", taxIdType: "", billingAddress: undefined, businessName: "", taxExempt: false };
3406
+ }
3407
+ exports.UpdateTaxInfoRequest = {
3408
+ encode(message, writer = new wire_1.BinaryWriter()) {
3409
+ if (message.taxId !== "") {
3410
+ writer.uint32(10).string(message.taxId);
3411
+ }
3412
+ if (message.taxIdType !== "") {
3413
+ writer.uint32(18).string(message.taxIdType);
3414
+ }
3415
+ if (message.billingAddress !== undefined) {
3416
+ subscription_pb_1.Address.encode(message.billingAddress, writer.uint32(26).fork()).join();
3417
+ }
3418
+ if (message.businessName !== "") {
3419
+ writer.uint32(34).string(message.businessName);
3420
+ }
3421
+ if (message.taxExempt !== false) {
3422
+ writer.uint32(40).bool(message.taxExempt);
3423
+ }
3424
+ return writer;
3425
+ },
3426
+ decode(input, length) {
3427
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
3428
+ let end = length === undefined ? reader.len : reader.pos + length;
3429
+ const message = createBaseUpdateTaxInfoRequest();
3430
+ while (reader.pos < end) {
3431
+ const tag = reader.uint32();
3432
+ switch (tag >>> 3) {
3433
+ case 1: {
3434
+ if (tag !== 10) {
3435
+ break;
3436
+ }
3437
+ message.taxId = reader.string();
3438
+ continue;
3439
+ }
3440
+ case 2: {
3441
+ if (tag !== 18) {
3442
+ break;
3443
+ }
3444
+ message.taxIdType = reader.string();
3445
+ continue;
3446
+ }
3447
+ case 3: {
3448
+ if (tag !== 26) {
3449
+ break;
3450
+ }
3451
+ message.billingAddress = subscription_pb_1.Address.decode(reader, reader.uint32());
3452
+ continue;
3453
+ }
3454
+ case 4: {
3455
+ if (tag !== 34) {
3456
+ break;
3457
+ }
3458
+ message.businessName = reader.string();
3459
+ continue;
3460
+ }
3461
+ case 5: {
3462
+ if (tag !== 40) {
3463
+ break;
3464
+ }
3465
+ message.taxExempt = reader.bool();
3466
+ continue;
3467
+ }
3468
+ }
3469
+ if ((tag & 7) === 4 || tag === 0) {
3470
+ break;
3471
+ }
3472
+ reader.skip(tag & 7);
3473
+ }
3474
+ return message;
3475
+ },
3476
+ fromJSON(object) {
3477
+ return {
3478
+ taxId: isSet(object.taxId) ? globalThis.String(object.taxId) : "",
3479
+ taxIdType: isSet(object.taxIdType) ? globalThis.String(object.taxIdType) : "",
3480
+ billingAddress: isSet(object.billingAddress) ? subscription_pb_1.Address.fromJSON(object.billingAddress) : undefined,
3481
+ businessName: isSet(object.businessName) ? globalThis.String(object.businessName) : "",
3482
+ taxExempt: isSet(object.taxExempt) ? globalThis.Boolean(object.taxExempt) : false,
3483
+ };
3484
+ },
3485
+ toJSON(message) {
3486
+ const obj = {};
3487
+ if (message.taxId !== "") {
3488
+ obj.taxId = message.taxId;
3489
+ }
3490
+ if (message.taxIdType !== "") {
3491
+ obj.taxIdType = message.taxIdType;
3492
+ }
3493
+ if (message.billingAddress !== undefined) {
3494
+ obj.billingAddress = subscription_pb_1.Address.toJSON(message.billingAddress);
3495
+ }
3496
+ if (message.businessName !== "") {
3497
+ obj.businessName = message.businessName;
3498
+ }
3499
+ if (message.taxExempt !== false) {
3500
+ obj.taxExempt = message.taxExempt;
3501
+ }
3502
+ return obj;
3503
+ },
3504
+ create(base) {
3505
+ return exports.UpdateTaxInfoRequest.fromPartial(base !== null && base !== void 0 ? base : {});
3506
+ },
3507
+ fromPartial(object) {
3508
+ var _a, _b, _c, _d;
3509
+ const message = createBaseUpdateTaxInfoRequest();
3510
+ message.taxId = (_a = object.taxId) !== null && _a !== void 0 ? _a : "";
3511
+ message.taxIdType = (_b = object.taxIdType) !== null && _b !== void 0 ? _b : "";
3512
+ message.billingAddress = (object.billingAddress !== undefined && object.billingAddress !== null)
3513
+ ? subscription_pb_1.Address.fromPartial(object.billingAddress)
3514
+ : undefined;
3515
+ message.businessName = (_c = object.businessName) !== null && _c !== void 0 ? _c : "";
3516
+ message.taxExempt = (_d = object.taxExempt) !== null && _d !== void 0 ? _d : false;
3517
+ return message;
3518
+ },
3519
+ };
3520
+ function createBaseUpdateTaxInfoResponse() {
3521
+ return { success: false, message: "", taxInfo: undefined };
3522
+ }
3523
+ exports.UpdateTaxInfoResponse = {
3524
+ encode(message, writer = new wire_1.BinaryWriter()) {
3525
+ if (message.success !== false) {
3526
+ writer.uint32(8).bool(message.success);
3527
+ }
3528
+ if (message.message !== "") {
3529
+ writer.uint32(18).string(message.message);
3530
+ }
3531
+ if (message.taxInfo !== undefined) {
3532
+ exports.TaxInfo.encode(message.taxInfo, writer.uint32(26).fork()).join();
3533
+ }
3534
+ return writer;
3535
+ },
3536
+ decode(input, length) {
3537
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
3538
+ let end = length === undefined ? reader.len : reader.pos + length;
3539
+ const message = createBaseUpdateTaxInfoResponse();
3540
+ while (reader.pos < end) {
3541
+ const tag = reader.uint32();
3542
+ switch (tag >>> 3) {
3543
+ case 1: {
3544
+ if (tag !== 8) {
3545
+ break;
3546
+ }
3547
+ message.success = reader.bool();
3548
+ continue;
3549
+ }
3550
+ case 2: {
3551
+ if (tag !== 18) {
3552
+ break;
3553
+ }
3554
+ message.message = reader.string();
3555
+ continue;
3556
+ }
3557
+ case 3: {
3558
+ if (tag !== 26) {
3559
+ break;
3560
+ }
3561
+ message.taxInfo = exports.TaxInfo.decode(reader, reader.uint32());
3562
+ continue;
3563
+ }
3564
+ }
3565
+ if ((tag & 7) === 4 || tag === 0) {
3566
+ break;
3567
+ }
3568
+ reader.skip(tag & 7);
3569
+ }
3570
+ return message;
3571
+ },
3572
+ fromJSON(object) {
3573
+ return {
3574
+ success: isSet(object.success) ? globalThis.Boolean(object.success) : false,
3575
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
3576
+ taxInfo: isSet(object.taxInfo) ? exports.TaxInfo.fromJSON(object.taxInfo) : undefined,
3577
+ };
3578
+ },
3579
+ toJSON(message) {
3580
+ const obj = {};
3581
+ if (message.success !== false) {
3582
+ obj.success = message.success;
3583
+ }
3584
+ if (message.message !== "") {
3585
+ obj.message = message.message;
3586
+ }
3587
+ if (message.taxInfo !== undefined) {
3588
+ obj.taxInfo = exports.TaxInfo.toJSON(message.taxInfo);
3589
+ }
3590
+ return obj;
3591
+ },
3592
+ create(base) {
3593
+ return exports.UpdateTaxInfoResponse.fromPartial(base !== null && base !== void 0 ? base : {});
3594
+ },
3595
+ fromPartial(object) {
3596
+ var _a, _b;
3597
+ const message = createBaseUpdateTaxInfoResponse();
3598
+ message.success = (_a = object.success) !== null && _a !== void 0 ? _a : false;
3599
+ message.message = (_b = object.message) !== null && _b !== void 0 ? _b : "";
3600
+ message.taxInfo = (object.taxInfo !== undefined && object.taxInfo !== null)
3601
+ ? exports.TaxInfo.fromPartial(object.taxInfo)
3602
+ : undefined;
3603
+ return message;
3604
+ },
3605
+ };
3606
+ function createBaseTaxInfo() {
3607
+ return {
3608
+ taxId: "",
3609
+ taxIdType: "",
3610
+ verificationStatus: "",
3611
+ billingAddress: undefined,
3612
+ businessName: "",
3613
+ taxExempt: false,
3614
+ applicableRates: [],
3615
+ };
3616
+ }
3617
+ exports.TaxInfo = {
3618
+ encode(message, writer = new wire_1.BinaryWriter()) {
3619
+ if (message.taxId !== "") {
3620
+ writer.uint32(10).string(message.taxId);
3621
+ }
3622
+ if (message.taxIdType !== "") {
3623
+ writer.uint32(18).string(message.taxIdType);
3624
+ }
3625
+ if (message.verificationStatus !== "") {
3626
+ writer.uint32(26).string(message.verificationStatus);
3627
+ }
3628
+ if (message.billingAddress !== undefined) {
3629
+ subscription_pb_1.Address.encode(message.billingAddress, writer.uint32(34).fork()).join();
3630
+ }
3631
+ if (message.businessName !== "") {
3632
+ writer.uint32(42).string(message.businessName);
3633
+ }
3634
+ if (message.taxExempt !== false) {
3635
+ writer.uint32(48).bool(message.taxExempt);
3636
+ }
3637
+ for (const v of message.applicableRates) {
3638
+ invoice_pb_1.TaxRate.encode(v, writer.uint32(58).fork()).join();
3639
+ }
3640
+ return writer;
3641
+ },
3642
+ decode(input, length) {
3643
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
3644
+ let end = length === undefined ? reader.len : reader.pos + length;
3645
+ const message = createBaseTaxInfo();
3646
+ while (reader.pos < end) {
3647
+ const tag = reader.uint32();
3648
+ switch (tag >>> 3) {
3649
+ case 1: {
3650
+ if (tag !== 10) {
3651
+ break;
3652
+ }
3653
+ message.taxId = reader.string();
3654
+ continue;
3655
+ }
3656
+ case 2: {
3657
+ if (tag !== 18) {
3658
+ break;
3659
+ }
3660
+ message.taxIdType = reader.string();
3661
+ continue;
3662
+ }
3663
+ case 3: {
3664
+ if (tag !== 26) {
3665
+ break;
3666
+ }
3667
+ message.verificationStatus = reader.string();
3668
+ continue;
3669
+ }
3670
+ case 4: {
3671
+ if (tag !== 34) {
3672
+ break;
3673
+ }
3674
+ message.billingAddress = subscription_pb_1.Address.decode(reader, reader.uint32());
3675
+ continue;
3676
+ }
3677
+ case 5: {
3678
+ if (tag !== 42) {
3679
+ break;
3680
+ }
3681
+ message.businessName = reader.string();
3682
+ continue;
3683
+ }
3684
+ case 6: {
3685
+ if (tag !== 48) {
3686
+ break;
3687
+ }
3688
+ message.taxExempt = reader.bool();
3689
+ continue;
3690
+ }
3691
+ case 7: {
3692
+ if (tag !== 58) {
3693
+ break;
3694
+ }
3695
+ message.applicableRates.push(invoice_pb_1.TaxRate.decode(reader, reader.uint32()));
3696
+ continue;
3697
+ }
3698
+ }
3699
+ if ((tag & 7) === 4 || tag === 0) {
3700
+ break;
3701
+ }
3702
+ reader.skip(tag & 7);
3703
+ }
3704
+ return message;
3705
+ },
3706
+ fromJSON(object) {
3707
+ return {
3708
+ taxId: isSet(object.taxId) ? globalThis.String(object.taxId) : "",
3709
+ taxIdType: isSet(object.taxIdType) ? globalThis.String(object.taxIdType) : "",
3710
+ verificationStatus: isSet(object.verificationStatus) ? globalThis.String(object.verificationStatus) : "",
3711
+ billingAddress: isSet(object.billingAddress) ? subscription_pb_1.Address.fromJSON(object.billingAddress) : undefined,
3712
+ businessName: isSet(object.businessName) ? globalThis.String(object.businessName) : "",
3713
+ taxExempt: isSet(object.taxExempt) ? globalThis.Boolean(object.taxExempt) : false,
3714
+ applicableRates: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.applicableRates)
3715
+ ? object.applicableRates.map((e) => invoice_pb_1.TaxRate.fromJSON(e))
3716
+ : [],
3717
+ };
3718
+ },
3719
+ toJSON(message) {
3720
+ var _a;
3721
+ const obj = {};
3722
+ if (message.taxId !== "") {
3723
+ obj.taxId = message.taxId;
3724
+ }
3725
+ if (message.taxIdType !== "") {
3726
+ obj.taxIdType = message.taxIdType;
3727
+ }
3728
+ if (message.verificationStatus !== "") {
3729
+ obj.verificationStatus = message.verificationStatus;
3730
+ }
3731
+ if (message.billingAddress !== undefined) {
3732
+ obj.billingAddress = subscription_pb_1.Address.toJSON(message.billingAddress);
3733
+ }
3734
+ if (message.businessName !== "") {
3735
+ obj.businessName = message.businessName;
3736
+ }
3737
+ if (message.taxExempt !== false) {
3738
+ obj.taxExempt = message.taxExempt;
3739
+ }
3740
+ if ((_a = message.applicableRates) === null || _a === void 0 ? void 0 : _a.length) {
3741
+ obj.applicableRates = message.applicableRates.map((e) => invoice_pb_1.TaxRate.toJSON(e));
3742
+ }
3743
+ return obj;
3744
+ },
3745
+ create(base) {
3746
+ return exports.TaxInfo.fromPartial(base !== null && base !== void 0 ? base : {});
3747
+ },
3748
+ fromPartial(object) {
3749
+ var _a, _b, _c, _d, _e, _f;
3750
+ const message = createBaseTaxInfo();
3751
+ message.taxId = (_a = object.taxId) !== null && _a !== void 0 ? _a : "";
3752
+ message.taxIdType = (_b = object.taxIdType) !== null && _b !== void 0 ? _b : "";
3753
+ message.verificationStatus = (_c = object.verificationStatus) !== null && _c !== void 0 ? _c : "";
3754
+ message.billingAddress = (object.billingAddress !== undefined && object.billingAddress !== null)
3755
+ ? subscription_pb_1.Address.fromPartial(object.billingAddress)
3756
+ : undefined;
3757
+ message.businessName = (_d = object.businessName) !== null && _d !== void 0 ? _d : "";
3758
+ message.taxExempt = (_e = object.taxExempt) !== null && _e !== void 0 ? _e : false;
3759
+ message.applicableRates = ((_f = object.applicableRates) === null || _f === void 0 ? void 0 : _f.map((e) => invoice_pb_1.TaxRate.fromPartial(e))) || [];
3760
+ return message;
3761
+ },
3762
+ };
3763
+ function createBaseDownloadInvoiceRequest() {
3764
+ return { invoiceId: "" };
3765
+ }
3766
+ exports.DownloadInvoiceRequest = {
3767
+ encode(message, writer = new wire_1.BinaryWriter()) {
3768
+ if (message.invoiceId !== "") {
3769
+ writer.uint32(10).string(message.invoiceId);
3770
+ }
3771
+ return writer;
3772
+ },
3773
+ decode(input, length) {
3774
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
3775
+ let end = length === undefined ? reader.len : reader.pos + length;
3776
+ const message = createBaseDownloadInvoiceRequest();
3777
+ while (reader.pos < end) {
3778
+ const tag = reader.uint32();
3779
+ switch (tag >>> 3) {
3780
+ case 1: {
3781
+ if (tag !== 10) {
3782
+ break;
3783
+ }
3784
+ message.invoiceId = reader.string();
3785
+ continue;
3786
+ }
3787
+ }
3788
+ if ((tag & 7) === 4 || tag === 0) {
3789
+ break;
3790
+ }
3791
+ reader.skip(tag & 7);
3792
+ }
3793
+ return message;
3794
+ },
3795
+ fromJSON(object) {
3796
+ return { invoiceId: isSet(object.invoiceId) ? globalThis.String(object.invoiceId) : "" };
3797
+ },
3798
+ toJSON(message) {
3799
+ const obj = {};
3800
+ if (message.invoiceId !== "") {
3801
+ obj.invoiceId = message.invoiceId;
3802
+ }
3803
+ return obj;
3804
+ },
3805
+ create(base) {
3806
+ return exports.DownloadInvoiceRequest.fromPartial(base !== null && base !== void 0 ? base : {});
3807
+ },
3808
+ fromPartial(object) {
3809
+ var _a;
3810
+ const message = createBaseDownloadInvoiceRequest();
3811
+ message.invoiceId = (_a = object.invoiceId) !== null && _a !== void 0 ? _a : "";
3812
+ return message;
3813
+ },
3814
+ };
3815
+ function createBaseDownloadInvoiceResponse() {
3816
+ return { pdfData: new Uint8Array(0), filename: "", contentType: "" };
3817
+ }
3818
+ exports.DownloadInvoiceResponse = {
3819
+ encode(message, writer = new wire_1.BinaryWriter()) {
3820
+ if (message.pdfData.length !== 0) {
3821
+ writer.uint32(10).bytes(message.pdfData);
3822
+ }
3823
+ if (message.filename !== "") {
3824
+ writer.uint32(18).string(message.filename);
3825
+ }
3826
+ if (message.contentType !== "") {
3827
+ writer.uint32(26).string(message.contentType);
3828
+ }
3829
+ return writer;
3830
+ },
3831
+ decode(input, length) {
3832
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
3833
+ let end = length === undefined ? reader.len : reader.pos + length;
3834
+ const message = createBaseDownloadInvoiceResponse();
3835
+ while (reader.pos < end) {
3836
+ const tag = reader.uint32();
3837
+ switch (tag >>> 3) {
3838
+ case 1: {
3839
+ if (tag !== 10) {
3840
+ break;
3841
+ }
3842
+ message.pdfData = reader.bytes();
3843
+ continue;
3844
+ }
3845
+ case 2: {
3846
+ if (tag !== 18) {
3847
+ break;
3848
+ }
3849
+ message.filename = reader.string();
3850
+ continue;
3851
+ }
3852
+ case 3: {
3853
+ if (tag !== 26) {
3854
+ break;
3855
+ }
3856
+ message.contentType = reader.string();
3857
+ continue;
3858
+ }
3859
+ }
3860
+ if ((tag & 7) === 4 || tag === 0) {
3861
+ break;
3862
+ }
3863
+ reader.skip(tag & 7);
3864
+ }
3865
+ return message;
3866
+ },
3867
+ fromJSON(object) {
3868
+ return {
3869
+ pdfData: isSet(object.pdfData) ? bytesFromBase64(object.pdfData) : new Uint8Array(0),
3870
+ filename: isSet(object.filename) ? globalThis.String(object.filename) : "",
3871
+ contentType: isSet(object.contentType) ? globalThis.String(object.contentType) : "",
3872
+ };
3873
+ },
3874
+ toJSON(message) {
3875
+ const obj = {};
3876
+ if (message.pdfData.length !== 0) {
3877
+ obj.pdfData = base64FromBytes(message.pdfData);
3878
+ }
3879
+ if (message.filename !== "") {
3880
+ obj.filename = message.filename;
3881
+ }
3882
+ if (message.contentType !== "") {
3883
+ obj.contentType = message.contentType;
3884
+ }
3885
+ return obj;
3886
+ },
3887
+ create(base) {
3888
+ return exports.DownloadInvoiceResponse.fromPartial(base !== null && base !== void 0 ? base : {});
3889
+ },
3890
+ fromPartial(object) {
3891
+ var _a, _b, _c;
3892
+ const message = createBaseDownloadInvoiceResponse();
3893
+ message.pdfData = (_a = object.pdfData) !== null && _a !== void 0 ? _a : new Uint8Array(0);
3894
+ message.filename = (_b = object.filename) !== null && _b !== void 0 ? _b : "";
3895
+ message.contentType = (_c = object.contentType) !== null && _c !== void 0 ? _c : "";
3896
+ return message;
3897
+ },
3898
+ };
3899
+ exports.PaymentService = {
3900
+ /** Create a Stripe checkout session for subscription */
3901
+ createCheckoutSession: {
3902
+ path: "/weaveapi.payment.v1.Payment/CreateCheckoutSession",
3903
+ requestStream: false,
3904
+ responseStream: false,
3905
+ requestSerialize: (value) => Buffer.from(exports.CreateCheckoutSessionRequest.encode(value).finish()),
3906
+ requestDeserialize: (value) => exports.CreateCheckoutSessionRequest.decode(value),
3907
+ responseSerialize: (value) => Buffer.from(exports.CreateCheckoutSessionResponse.encode(value).finish()),
3908
+ responseDeserialize: (value) => exports.CreateCheckoutSessionResponse.decode(value),
3909
+ },
3910
+ /** Get current subscription status */
3911
+ getSubscriptionStatus: {
3912
+ path: "/weaveapi.payment.v1.Payment/GetSubscriptionStatus",
3913
+ requestStream: false,
3914
+ responseStream: false,
3915
+ requestSerialize: (value) => Buffer.from(exports.GetSubscriptionStatusRequest.encode(value).finish()),
3916
+ requestDeserialize: (value) => exports.GetSubscriptionStatusRequest.decode(value),
3917
+ responseSerialize: (value) => Buffer.from(exports.GetSubscriptionStatusResponse.encode(value).finish()),
3918
+ responseDeserialize: (value) => exports.GetSubscriptionStatusResponse.decode(value),
3919
+ },
3920
+ /** Update subscription (change payment method, etc) */
3921
+ updateSubscription: {
3922
+ path: "/weaveapi.payment.v1.Payment/UpdateSubscription",
3923
+ requestStream: false,
3924
+ responseStream: false,
3925
+ requestSerialize: (value) => Buffer.from(exports.UpdateSubscriptionRequest.encode(value).finish()),
3926
+ requestDeserialize: (value) => exports.UpdateSubscriptionRequest.decode(value),
3927
+ responseSerialize: (value) => Buffer.from(exports.UpdateSubscriptionResponse.encode(value).finish()),
3928
+ responseDeserialize: (value) => exports.UpdateSubscriptionResponse.decode(value),
3929
+ },
3930
+ /** Cancel subscription */
3931
+ cancelSubscription: {
3932
+ path: "/weaveapi.payment.v1.Payment/CancelSubscription",
3933
+ requestStream: false,
3934
+ responseStream: false,
3935
+ requestSerialize: (value) => Buffer.from(exports.CancelSubscriptionRequest.encode(value).finish()),
3936
+ requestDeserialize: (value) => exports.CancelSubscriptionRequest.decode(value),
3937
+ responseSerialize: (value) => Buffer.from(exports.CancelSubscriptionResponse.encode(value).finish()),
3938
+ responseDeserialize: (value) => exports.CancelSubscriptionResponse.decode(value),
3939
+ },
3940
+ /** Resume cancelled subscription */
3941
+ resumeSubscription: {
3942
+ path: "/weaveapi.payment.v1.Payment/ResumeSubscription",
3943
+ requestStream: false,
3944
+ responseStream: false,
3945
+ requestSerialize: (value) => Buffer.from(exports.ResumeSubscriptionRequest.encode(value).finish()),
3946
+ requestDeserialize: (value) => exports.ResumeSubscriptionRequest.decode(value),
3947
+ responseSerialize: (value) => Buffer.from(exports.ResumeSubscriptionResponse.encode(value).finish()),
3948
+ responseDeserialize: (value) => exports.ResumeSubscriptionResponse.decode(value),
3949
+ },
3950
+ /** Get billing history */
3951
+ getBillingHistory: {
3952
+ path: "/weaveapi.payment.v1.Payment/GetBillingHistory",
3953
+ requestStream: false,
3954
+ responseStream: false,
3955
+ requestSerialize: (value) => Buffer.from(exports.GetBillingHistoryRequest.encode(value).finish()),
3956
+ requestDeserialize: (value) => exports.GetBillingHistoryRequest.decode(value),
3957
+ responseSerialize: (value) => Buffer.from(exports.GetBillingHistoryResponse.encode(value).finish()),
3958
+ responseDeserialize: (value) => exports.GetBillingHistoryResponse.decode(value),
3959
+ },
3960
+ /** Get upcoming invoice preview */
3961
+ getUpcomingInvoice: {
3962
+ path: "/weaveapi.payment.v1.Payment/GetUpcomingInvoice",
3963
+ requestStream: false,
3964
+ responseStream: false,
3965
+ requestSerialize: (value) => Buffer.from(exports.GetUpcomingInvoiceRequest.encode(value).finish()),
3966
+ requestDeserialize: (value) => exports.GetUpcomingInvoiceRequest.decode(value),
3967
+ responseSerialize: (value) => Buffer.from(exports.GetUpcomingInvoiceResponse.encode(value).finish()),
3968
+ responseDeserialize: (value) => exports.GetUpcomingInvoiceResponse.decode(value),
3969
+ },
3970
+ /** List payment methods */
3971
+ listPaymentMethods: {
3972
+ path: "/weaveapi.payment.v1.Payment/ListPaymentMethods",
3973
+ requestStream: false,
3974
+ responseStream: false,
3975
+ requestSerialize: (value) => Buffer.from(exports.ListPaymentMethodsRequest.encode(value).finish()),
3976
+ requestDeserialize: (value) => exports.ListPaymentMethodsRequest.decode(value),
3977
+ responseSerialize: (value) => Buffer.from(exports.ListPaymentMethodsResponse.encode(value).finish()),
3978
+ responseDeserialize: (value) => exports.ListPaymentMethodsResponse.decode(value),
3979
+ },
3980
+ /** Add payment method */
3981
+ addPaymentMethod: {
3982
+ path: "/weaveapi.payment.v1.Payment/AddPaymentMethod",
3983
+ requestStream: false,
3984
+ responseStream: false,
3985
+ requestSerialize: (value) => Buffer.from(exports.AddPaymentMethodRequest.encode(value).finish()),
3986
+ requestDeserialize: (value) => exports.AddPaymentMethodRequest.decode(value),
3987
+ responseSerialize: (value) => Buffer.from(exports.AddPaymentMethodResponse.encode(value).finish()),
3988
+ responseDeserialize: (value) => exports.AddPaymentMethodResponse.decode(value),
3989
+ },
3990
+ /** Set default payment method */
3991
+ setDefaultPaymentMethod: {
3992
+ path: "/weaveapi.payment.v1.Payment/SetDefaultPaymentMethod",
3993
+ requestStream: false,
3994
+ responseStream: false,
3995
+ requestSerialize: (value) => Buffer.from(exports.SetDefaultPaymentMethodRequest.encode(value).finish()),
3996
+ requestDeserialize: (value) => exports.SetDefaultPaymentMethodRequest.decode(value),
3997
+ responseSerialize: (value) => Buffer.from(exports.SetDefaultPaymentMethodResponse.encode(value).finish()),
3998
+ responseDeserialize: (value) => exports.SetDefaultPaymentMethodResponse.decode(value),
3999
+ },
4000
+ /** Remove payment method */
4001
+ removePaymentMethod: {
4002
+ path: "/weaveapi.payment.v1.Payment/RemovePaymentMethod",
4003
+ requestStream: false,
4004
+ responseStream: false,
4005
+ requestSerialize: (value) => Buffer.from(exports.RemovePaymentMethodRequest.encode(value).finish()),
4006
+ requestDeserialize: (value) => exports.RemovePaymentMethodRequest.decode(value),
4007
+ responseSerialize: (value) => Buffer.from(exports.RemovePaymentMethodResponse.encode(value).finish()),
4008
+ responseDeserialize: (value) => exports.RemovePaymentMethodResponse.decode(value),
4009
+ },
4010
+ /** Create Stripe customer portal session */
4011
+ createPortalSession: {
4012
+ path: "/weaveapi.payment.v1.Payment/CreatePortalSession",
4013
+ requestStream: false,
4014
+ responseStream: false,
4015
+ requestSerialize: (value) => Buffer.from(exports.CreatePortalSessionRequest.encode(value).finish()),
4016
+ requestDeserialize: (value) => exports.CreatePortalSessionRequest.decode(value),
4017
+ responseSerialize: (value) => Buffer.from(exports.CreatePortalSessionResponse.encode(value).finish()),
4018
+ responseDeserialize: (value) => exports.CreatePortalSessionResponse.decode(value),
4019
+ },
4020
+ /** Get available pricing plans */
4021
+ getPricingPlans: {
4022
+ path: "/weaveapi.payment.v1.Payment/GetPricingPlans",
4023
+ requestStream: false,
4024
+ responseStream: false,
4025
+ requestSerialize: (value) => Buffer.from(exports.GetPricingPlansRequest.encode(value).finish()),
4026
+ requestDeserialize: (value) => exports.GetPricingPlansRequest.decode(value),
4027
+ responseSerialize: (value) => Buffer.from(exports.GetPricingPlansResponse.encode(value).finish()),
4028
+ responseDeserialize: (value) => exports.GetPricingPlansResponse.decode(value),
4029
+ },
4030
+ /** Apply promo code */
4031
+ applyPromoCode: {
4032
+ path: "/weaveapi.payment.v1.Payment/ApplyPromoCode",
4033
+ requestStream: false,
4034
+ responseStream: false,
4035
+ requestSerialize: (value) => Buffer.from(exports.ApplyPromoCodeRequest.encode(value).finish()),
4036
+ requestDeserialize: (value) => exports.ApplyPromoCodeRequest.decode(value),
4037
+ responseSerialize: (value) => Buffer.from(exports.ApplyPromoCodeResponse.encode(value).finish()),
4038
+ responseDeserialize: (value) => exports.ApplyPromoCodeResponse.decode(value),
4039
+ },
4040
+ /** Handle Stripe webhook events */
4041
+ handleStripeWebhook: {
4042
+ path: "/weaveapi.payment.v1.Payment/HandleStripeWebhook",
4043
+ requestStream: false,
4044
+ responseStream: false,
4045
+ requestSerialize: (value) => Buffer.from(exports.HandleStripeWebhookRequest.encode(value).finish()),
4046
+ requestDeserialize: (value) => exports.HandleStripeWebhookRequest.decode(value),
4047
+ responseSerialize: (value) => Buffer.from(exports.HandleStripeWebhookResponse.encode(value).finish()),
4048
+ responseDeserialize: (value) => exports.HandleStripeWebhookResponse.decode(value),
4049
+ },
4050
+ /** Get usage summary for billing period */
4051
+ getUsageSummary: {
4052
+ path: "/weaveapi.payment.v1.Payment/GetUsageSummary",
4053
+ requestStream: false,
4054
+ responseStream: false,
4055
+ requestSerialize: (value) => Buffer.from(exports.GetUsageSummaryRequest.encode(value).finish()),
4056
+ requestDeserialize: (value) => exports.GetUsageSummaryRequest.decode(value),
4057
+ responseSerialize: (value) => Buffer.from(exports.GetUsageSummaryResponse.encode(value).finish()),
4058
+ responseDeserialize: (value) => exports.GetUsageSummaryResponse.decode(value),
4059
+ },
4060
+ /** Get credit balance (if applicable) */
4061
+ getCreditBalance: {
4062
+ path: "/weaveapi.payment.v1.Payment/GetCreditBalance",
4063
+ requestStream: false,
4064
+ responseStream: false,
4065
+ requestSerialize: (value) => Buffer.from(exports.GetCreditBalanceRequest.encode(value).finish()),
4066
+ requestDeserialize: (value) => exports.GetCreditBalanceRequest.decode(value),
4067
+ responseSerialize: (value) => Buffer.from(exports.GetCreditBalanceResponse.encode(value).finish()),
4068
+ responseDeserialize: (value) => exports.GetCreditBalanceResponse.decode(value),
4069
+ },
4070
+ /** Update tax information */
4071
+ updateTaxInfo: {
4072
+ path: "/weaveapi.payment.v1.Payment/UpdateTaxInfo",
4073
+ requestStream: false,
4074
+ responseStream: false,
4075
+ requestSerialize: (value) => Buffer.from(exports.UpdateTaxInfoRequest.encode(value).finish()),
4076
+ requestDeserialize: (value) => exports.UpdateTaxInfoRequest.decode(value),
4077
+ responseSerialize: (value) => Buffer.from(exports.UpdateTaxInfoResponse.encode(value).finish()),
4078
+ responseDeserialize: (value) => exports.UpdateTaxInfoResponse.decode(value),
4079
+ },
4080
+ /** Download invoice PDF */
4081
+ downloadInvoice: {
4082
+ path: "/weaveapi.payment.v1.Payment/DownloadInvoice",
4083
+ requestStream: false,
4084
+ responseStream: false,
4085
+ requestSerialize: (value) => Buffer.from(exports.DownloadInvoiceRequest.encode(value).finish()),
4086
+ requestDeserialize: (value) => exports.DownloadInvoiceRequest.decode(value),
4087
+ responseSerialize: (value) => Buffer.from(exports.DownloadInvoiceResponse.encode(value).finish()),
4088
+ responseDeserialize: (value) => exports.DownloadInvoiceResponse.decode(value),
4089
+ },
4090
+ };
4091
+ exports.PaymentClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.PaymentService, "weaveapi.payment.v1.Payment");
4092
+ function bytesFromBase64(b64) {
4093
+ if (globalThis.Buffer) {
4094
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
4095
+ }
4096
+ else {
4097
+ const bin = globalThis.atob(b64);
4098
+ const arr = new Uint8Array(bin.length);
4099
+ for (let i = 0; i < bin.length; ++i) {
4100
+ arr[i] = bin.charCodeAt(i);
4101
+ }
4102
+ return arr;
4103
+ }
4104
+ }
4105
+ function base64FromBytes(arr) {
4106
+ if (globalThis.Buffer) {
4107
+ return globalThis.Buffer.from(arr).toString("base64");
4108
+ }
4109
+ else {
4110
+ const bin = [];
4111
+ arr.forEach((byte) => {
4112
+ bin.push(globalThis.String.fromCharCode(byte));
4113
+ });
4114
+ return globalThis.btoa(bin.join(""));
4115
+ }
4116
+ }
4117
+ function toTimestamp(date) {
4118
+ const seconds = Math.trunc(date.getTime() / 1000);
4119
+ const nanos = (date.getTime() % 1000) * 1000000;
4120
+ return { seconds, nanos };
4121
+ }
4122
+ function fromTimestamp(t) {
4123
+ let millis = (t.seconds || 0) * 1000;
4124
+ millis += (t.nanos || 0) / 1000000;
4125
+ return new globalThis.Date(millis);
4126
+ }
4127
+ function fromJsonTimestamp(o) {
4128
+ if (o instanceof globalThis.Date) {
4129
+ return o;
4130
+ }
4131
+ else if (typeof o === "string") {
4132
+ return new globalThis.Date(o);
4133
+ }
4134
+ else {
4135
+ return fromTimestamp(timestamp_pb_1.Timestamp.fromJSON(o));
4136
+ }
4137
+ }
4138
+ function longToNumber(int64) {
4139
+ const num = globalThis.Number(int64.toString());
4140
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
4141
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
4142
+ }
4143
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
4144
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
4145
+ }
4146
+ return num;
4147
+ }
4148
+ function isObject(value) {
4149
+ return typeof value === "object" && value !== null;
4150
+ }
4151
+ function isSet(value) {
4152
+ return value !== null && value !== undefined;
4153
+ }