// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from 'flatbuffers';



export class DeviceSessionView implements flatbuffers.IUnpackableObject<DeviceSessionViewT> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):DeviceSessionView {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsDeviceSessionView(bb:flatbuffers.ByteBuffer, obj?:DeviceSessionView):DeviceSessionView {
  return (obj || new DeviceSessionView()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsDeviceSessionView(bb:flatbuffers.ByteBuffer, obj?:DeviceSessionView):DeviceSessionView {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new DeviceSessionView()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

deviceSessionId():string|null
deviceSessionId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
deviceSessionId(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

userId():string|null
userId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
userId(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

status():string|null
status(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
status(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

clientPublicKey():string|null
clientPublicKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
clientPublicKey(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 10);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

createdAtMs():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 12);
  return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

revokedAtMs():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 14);
  return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

lastSeenAtMs():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 16);
  return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

static startDeviceSessionView(builder:flatbuffers.Builder) {
  builder.startObject(7);
}

static addDeviceSessionId(builder:flatbuffers.Builder, deviceSessionIdOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, deviceSessionIdOffset, 0);
}

static addUserId(builder:flatbuffers.Builder, userIdOffset:flatbuffers.Offset) {
  builder.addFieldOffset(1, userIdOffset, 0);
}

static addStatus(builder:flatbuffers.Builder, statusOffset:flatbuffers.Offset) {
  builder.addFieldOffset(2, statusOffset, 0);
}

static addClientPublicKey(builder:flatbuffers.Builder, clientPublicKeyOffset:flatbuffers.Offset) {
  builder.addFieldOffset(3, clientPublicKeyOffset, 0);
}

static addCreatedAtMs(builder:flatbuffers.Builder, createdAtMs:bigint) {
  builder.addFieldInt64(4, createdAtMs, BigInt('0'));
}

static addRevokedAtMs(builder:flatbuffers.Builder, revokedAtMs:bigint) {
  builder.addFieldInt64(5, revokedAtMs, BigInt('0'));
}

static addLastSeenAtMs(builder:flatbuffers.Builder, lastSeenAtMs:bigint) {
  builder.addFieldInt64(6, lastSeenAtMs, BigInt('0'));
}

static endDeviceSessionView(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}

static createDeviceSessionView(builder:flatbuffers.Builder, deviceSessionIdOffset:flatbuffers.Offset, userIdOffset:flatbuffers.Offset, statusOffset:flatbuffers.Offset, clientPublicKeyOffset:flatbuffers.Offset, createdAtMs:bigint, revokedAtMs:bigint, lastSeenAtMs:bigint):flatbuffers.Offset {
  DeviceSessionView.startDeviceSessionView(builder);
  DeviceSessionView.addDeviceSessionId(builder, deviceSessionIdOffset);
  DeviceSessionView.addUserId(builder, userIdOffset);
  DeviceSessionView.addStatus(builder, statusOffset);
  DeviceSessionView.addClientPublicKey(builder, clientPublicKeyOffset);
  DeviceSessionView.addCreatedAtMs(builder, createdAtMs);
  DeviceSessionView.addRevokedAtMs(builder, revokedAtMs);
  DeviceSessionView.addLastSeenAtMs(builder, lastSeenAtMs);
  return DeviceSessionView.endDeviceSessionView(builder);
}

unpack(): DeviceSessionViewT {
  return new DeviceSessionViewT(
    this.deviceSessionId(),
    this.userId(),
    this.status(),
    this.clientPublicKey(),
    this.createdAtMs(),
    this.revokedAtMs(),
    this.lastSeenAtMs()
  );
}


unpackTo(_o: DeviceSessionViewT): void {
  _o.deviceSessionId = this.deviceSessionId();
  _o.userId = this.userId();
  _o.status = this.status();
  _o.clientPublicKey = this.clientPublicKey();
  _o.createdAtMs = this.createdAtMs();
  _o.revokedAtMs = this.revokedAtMs();
  _o.lastSeenAtMs = this.lastSeenAtMs();
}
}

export class DeviceSessionViewT implements flatbuffers.IGeneratedObject {
constructor(
  public deviceSessionId: string|Uint8Array|null = null,
  public userId: string|Uint8Array|null = null,
  public status: string|Uint8Array|null = null,
  public clientPublicKey: string|Uint8Array|null = null,
  public createdAtMs: bigint = BigInt('0'),
  public revokedAtMs: bigint = BigInt('0'),
  public lastSeenAtMs: bigint = BigInt('0')
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  const deviceSessionId = (this.deviceSessionId !== null ? builder.createString(this.deviceSessionId!) : 0);
  const userId = (this.userId !== null ? builder.createString(this.userId!) : 0);
  const status = (this.status !== null ? builder.createString(this.status!) : 0);
  const clientPublicKey = (this.clientPublicKey !== null ? builder.createString(this.clientPublicKey!) : 0);

  return DeviceSessionView.createDeviceSessionView(builder,
    deviceSessionId,
    userId,
    status,
    clientPublicKey,
    this.createdAtMs,
    this.revokedAtMs,
    this.lastSeenAtMs
  );
}
}
