UNPKG

yc-types

Version:

TypeScript types and interfaces for YellowCard protobuf definitions

452 lines (451 loc) 17.2 kB
"use strict"; // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.2.7 // protoc v5.29.2 // source: issuer.proto Object.defineProperty(exports, "__esModule", { value: true }); exports.ListIssuersResponse = exports.CreateIssuerRequest = exports.Issuer = exports.protobufPackage = void 0; /* eslint-disable */ const wire_1 = require("@bufbuild/protobuf/wire"); const common_1 = require("./common"); const timestamp_1 = require("./google/protobuf/timestamp"); exports.protobufPackage = "pb"; function createBaseIssuer() { return { id: "", accreditedBy: undefined, registrationNumber: undefined, organizationName: undefined, address: undefined, contactEmail: undefined, contactPhone: undefined, createdAt: undefined, }; } exports.Issuer = { encode(message, writer = new wire_1.BinaryWriter()) { if (message.id !== "") { writer.uint32(10).string(message.id); } if (message.accreditedBy !== undefined) { writer.uint32(18).string(message.accreditedBy); } if (message.registrationNumber !== undefined) { writer.uint32(26).string(message.registrationNumber); } if (message.organizationName !== undefined) { writer.uint32(34).string(message.organizationName); } if (message.address !== undefined) { writer.uint32(42).bytes(message.address); } if (message.contactEmail !== undefined) { writer.uint32(50).string(message.contactEmail); } if (message.contactPhone !== undefined) { writer.uint32(58).string(message.contactPhone); } if (message.createdAt !== undefined) { timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(66).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseIssuer(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.id = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.accreditedBy = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.registrationNumber = reader.string(); continue; } case 4: { if (tag !== 34) { break; } message.organizationName = reader.string(); continue; } case 5: { if (tag !== 42) { break; } message.address = reader.bytes(); continue; } case 6: { if (tag !== 50) { break; } message.contactEmail = reader.string(); continue; } case 7: { if (tag !== 58) { break; } message.contactPhone = reader.string(); continue; } case 8: { if (tag !== 66) { break; } message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32())); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { id: isSet(object.id) ? globalThis.String(object.id) : "", accreditedBy: isSet(object.accreditedBy) ? globalThis.String(object.accreditedBy) : undefined, registrationNumber: isSet(object.registrationNumber) ? globalThis.String(object.registrationNumber) : undefined, organizationName: isSet(object.organizationName) ? globalThis.String(object.organizationName) : undefined, address: isSet(object.address) ? bytesFromBase64(object.address) : undefined, contactEmail: isSet(object.contactEmail) ? globalThis.String(object.contactEmail) : undefined, contactPhone: isSet(object.contactPhone) ? globalThis.String(object.contactPhone) : undefined, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, }; }, toJSON(message) { const obj = {}; if (message.id !== "") { obj.id = message.id; } if (message.accreditedBy !== undefined) { obj.accreditedBy = message.accreditedBy; } if (message.registrationNumber !== undefined) { obj.registrationNumber = message.registrationNumber; } if (message.organizationName !== undefined) { obj.organizationName = message.organizationName; } if (message.address !== undefined) { obj.address = base64FromBytes(message.address); } if (message.contactEmail !== undefined) { obj.contactEmail = message.contactEmail; } if (message.contactPhone !== undefined) { obj.contactPhone = message.contactPhone; } if (message.createdAt !== undefined) { obj.createdAt = message.createdAt.toISOString(); } return obj; }, create(base) { return exports.Issuer.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a, _b, _c, _d, _e, _f, _g, _h; const message = createBaseIssuer(); message.id = (_a = object.id) !== null && _a !== void 0 ? _a : ""; message.accreditedBy = (_b = object.accreditedBy) !== null && _b !== void 0 ? _b : undefined; message.registrationNumber = (_c = object.registrationNumber) !== null && _c !== void 0 ? _c : undefined; message.organizationName = (_d = object.organizationName) !== null && _d !== void 0 ? _d : undefined; message.address = (_e = object.address) !== null && _e !== void 0 ? _e : undefined; message.contactEmail = (_f = object.contactEmail) !== null && _f !== void 0 ? _f : undefined; message.contactPhone = (_g = object.contactPhone) !== null && _g !== void 0 ? _g : undefined; message.createdAt = (_h = object.createdAt) !== null && _h !== void 0 ? _h : undefined; return message; }, }; function createBaseCreateIssuerRequest() { return { accreditedBy: "", registrationNumber: "", organizationName: "", address: new Uint8Array(0), contactEmail: "", contactPhone: "", }; } exports.CreateIssuerRequest = { encode(message, writer = new wire_1.BinaryWriter()) { if (message.accreditedBy !== "") { writer.uint32(10).string(message.accreditedBy); } if (message.registrationNumber !== "") { writer.uint32(18).string(message.registrationNumber); } if (message.organizationName !== "") { writer.uint32(26).string(message.organizationName); } if (message.address.length !== 0) { writer.uint32(34).bytes(message.address); } if (message.contactEmail !== "") { writer.uint32(42).string(message.contactEmail); } if (message.contactPhone !== "") { writer.uint32(50).string(message.contactPhone); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCreateIssuerRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.accreditedBy = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.registrationNumber = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.organizationName = reader.string(); continue; } case 4: { if (tag !== 34) { break; } message.address = reader.bytes(); continue; } case 5: { if (tag !== 42) { break; } message.contactEmail = reader.string(); continue; } case 6: { if (tag !== 50) { break; } message.contactPhone = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { accreditedBy: isSet(object.accreditedBy) ? globalThis.String(object.accreditedBy) : "", registrationNumber: isSet(object.registrationNumber) ? globalThis.String(object.registrationNumber) : "", organizationName: isSet(object.organizationName) ? globalThis.String(object.organizationName) : "", address: isSet(object.address) ? bytesFromBase64(object.address) : new Uint8Array(0), contactEmail: isSet(object.contactEmail) ? globalThis.String(object.contactEmail) : "", contactPhone: isSet(object.contactPhone) ? globalThis.String(object.contactPhone) : "", }; }, toJSON(message) { const obj = {}; if (message.accreditedBy !== "") { obj.accreditedBy = message.accreditedBy; } if (message.registrationNumber !== "") { obj.registrationNumber = message.registrationNumber; } if (message.organizationName !== "") { obj.organizationName = message.organizationName; } if (message.address.length !== 0) { obj.address = base64FromBytes(message.address); } if (message.contactEmail !== "") { obj.contactEmail = message.contactEmail; } if (message.contactPhone !== "") { obj.contactPhone = message.contactPhone; } return obj; }, create(base) { return exports.CreateIssuerRequest.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a, _b, _c, _d, _e, _f; const message = createBaseCreateIssuerRequest(); message.accreditedBy = (_a = object.accreditedBy) !== null && _a !== void 0 ? _a : ""; message.registrationNumber = (_b = object.registrationNumber) !== null && _b !== void 0 ? _b : ""; message.organizationName = (_c = object.organizationName) !== null && _c !== void 0 ? _c : ""; message.address = (_d = object.address) !== null && _d !== void 0 ? _d : new Uint8Array(0); message.contactEmail = (_e = object.contactEmail) !== null && _e !== void 0 ? _e : ""; message.contactPhone = (_f = object.contactPhone) !== null && _f !== void 0 ? _f : ""; return message; }, }; function createBaseListIssuersResponse() { return { status: 0, issuers: [], meta: undefined }; } exports.ListIssuersResponse = { encode(message, writer = new wire_1.BinaryWriter()) { if (message.status !== 0) { writer.uint32(8).int32(message.status); } for (const v of message.issuers) { exports.Issuer.encode(v, writer.uint32(18).fork()).join(); } if (message.meta !== undefined) { common_1.Metadata.encode(message.meta, writer.uint32(26).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListIssuersResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.status = reader.int32(); continue; } case 2: { if (tag !== 18) { break; } message.issuers.push(exports.Issuer.decode(reader, reader.uint32())); continue; } case 3: { if (tag !== 26) { break; } message.meta = common_1.Metadata.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { status: isSet(object.status) ? globalThis.Number(object.status) : 0, issuers: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.issuers) ? object.issuers.map((e) => exports.Issuer.fromJSON(e)) : [], meta: isSet(object.meta) ? common_1.Metadata.fromJSON(object.meta) : undefined, }; }, toJSON(message) { var _a; const obj = {}; if (message.status !== 0) { obj.status = Math.round(message.status); } if ((_a = message.issuers) === null || _a === void 0 ? void 0 : _a.length) { obj.issuers = message.issuers.map((e) => exports.Issuer.toJSON(e)); } if (message.meta !== undefined) { obj.meta = common_1.Metadata.toJSON(message.meta); } return obj; }, create(base) { return exports.ListIssuersResponse.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a, _b; const message = createBaseListIssuersResponse(); message.status = (_a = object.status) !== null && _a !== void 0 ? _a : 0; message.issuers = ((_b = object.issuers) === null || _b === void 0 ? void 0 : _b.map((e) => exports.Issuer.fromPartial(e))) || []; message.meta = (object.meta !== undefined && object.meta !== null) ? common_1.Metadata.fromPartial(object.meta) : undefined; return message; }, }; function bytesFromBase64(b64) { if (globalThis.Buffer) { return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); } return arr; } } function base64FromBytes(arr) { if (globalThis.Buffer) { return globalThis.Buffer.from(arr).toString("base64"); } else { const bin = []; arr.forEach((byte) => { bin.push(globalThis.String.fromCharCode(byte)); }); return globalThis.btoa(bin.join("")); } } function toTimestamp(date) { const seconds = Math.trunc(date.getTime() / 1000); const nanos = (date.getTime() % 1000) * 1000000; return { seconds, nanos }; } function fromTimestamp(t) { let millis = (t.seconds || 0) * 1000; millis += (t.nanos || 0) / 1000000; return new globalThis.Date(millis); } function fromJsonTimestamp(o) { if (o instanceof globalThis.Date) { return o; } else if (typeof o === "string") { return new globalThis.Date(o); } else { return fromTimestamp(timestamp_1.Timestamp.fromJSON(o)); } } function isSet(value) { return value !== null && value !== undefined; }