# automatically generated by the FlatBuffers compiler, do not modify

# namespace: xbr

import flatbuffers

# /// Request to have the market maker open a paying channel (which is a payment channel from the market maker to the data seller).
class PayingChannelRequest(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAsPayingChannelRequest(cls, buf, offset):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = PayingChannelRequest()
        x.Init(buf, n + offset)
        return x

    # PayingChannelRequest
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

# /// ID of the paying channel request.
    # PayingChannelRequest
    def Request(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PayingChannelRequest
    def RequestAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PayingChannelRequest
    def RequestLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Offer transaction time (epoch time in ns)
    # PayingChannelRequest
    def Timestamp(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

# /// ID of the market this request for a paying channel is associated with.
    # PayingChannelRequest
    def Market(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PayingChannelRequest
    def MarketAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PayingChannelRequest
    def MarketLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// The sender address of the Ethereum transaction submitting the paying channel request.
    # PayingChannelRequest
    def Sender(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PayingChannelRequest
    def SenderAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PayingChannelRequest
    def SenderLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// The address of the buyer delegate allowed to consume the payment channel balance.
    # PayingChannelRequest
    def Delegate(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PayingChannelRequest
    def DelegateAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PayingChannelRequest
    def DelegateLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// The ultimate recipient of this payment channel (for a XBR buyer, this will be the XBR market maker address; for a XBR seller, this will be the seller address).
    # PayingChannelRequest
    def Recipient(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PayingChannelRequest
    def RecipientAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PayingChannelRequest
    def RecipientLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// The initial amount in the (off-chain) payment channel.
    # PayingChannelRequest
    def Amount(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PayingChannelRequest
    def AmountAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PayingChannelRequest
    def AmountLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// The timeout knob for a non-cooperative close of the payment channel.
    # PayingChannelRequest
    def Timeout(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PayingChannelRequest
    def TimeoutAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PayingChannelRequest
    def TimeoutLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Paying channel request current state.
    # PayingChannelRequest
    def State(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
        return 0

# /// When state is PayingChannelRequestState.FAILED, an optional error message.
    # PayingChannelRequest
    def ErrorMsg(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

# /// When this request has been fulfulled, the address to the contract of the created payment channel (from the market maker to the data seller).
    # PayingChannelRequest
    def Channel(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PayingChannelRequest
    def ChannelAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PayingChannelRequest
    def ChannelLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

def PayingChannelRequestStart(builder): builder.StartObject(11)
def PayingChannelRequestAddRequest(builder, request): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(request), 0)
def PayingChannelRequestStartRequestVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PayingChannelRequestAddTimestamp(builder, timestamp): builder.PrependUint64Slot(1, timestamp, 0)
def PayingChannelRequestAddMarket(builder, market): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(market), 0)
def PayingChannelRequestStartMarketVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PayingChannelRequestAddSender(builder, sender): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(sender), 0)
def PayingChannelRequestStartSenderVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PayingChannelRequestAddDelegate(builder, delegate): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(delegate), 0)
def PayingChannelRequestStartDelegateVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PayingChannelRequestAddRecipient(builder, recipient): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(recipient), 0)
def PayingChannelRequestStartRecipientVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PayingChannelRequestAddAmount(builder, amount): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(amount), 0)
def PayingChannelRequestStartAmountVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PayingChannelRequestAddTimeout(builder, timeout): builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(timeout), 0)
def PayingChannelRequestStartTimeoutVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PayingChannelRequestAddState(builder, state): builder.PrependUint8Slot(8, state, 0)
def PayingChannelRequestAddErrorMsg(builder, errorMsg): builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(errorMsg), 0)
def PayingChannelRequestAddChannel(builder, channel): builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(channel), 0)
def PayingChannelRequestStartChannelVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PayingChannelRequestEnd(builder): return builder.EndObject()
