# automatically generated by the FlatBuffers compiler, do not modify

# namespace: openmeteo_sdk

import flatbuffers
from flatbuffers.compat import import_numpy
from typing import Any
from openmeteo_sdk.ClimateDaily import ClimateDaily
from typing import Optional
np = import_numpy()

class ClimateApiResponse(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset: int = 0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = ClimateApiResponse()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsClimateApiResponse(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # ClimateApiResponse
    def Init(self, buf: bytes, pos: int):
        self._tab = flatbuffers.table.Table(buf, pos)

    # ClimateApiResponse
    def Latitude(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
        return 0.0

    # ClimateApiResponse
    def Longitude(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
        return 0.0

    # ClimateApiResponse
    def Elevation(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
        return 0.0

    # ClimateApiResponse
    def Model(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
        return 0

    # ClimateApiResponse
    def GenerationtimeMs(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
        return 0.0

    # ClimateApiResponse
    def Daily(self) -> Optional[ClimateDaily]:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = ClimateDaily()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def ClimateApiResponseStart(builder: flatbuffers.Builder):
    builder.StartObject(6)

def Start(builder: flatbuffers.Builder):
    ClimateApiResponseStart(builder)

def ClimateApiResponseAddLatitude(builder: flatbuffers.Builder, latitude: float):
    builder.PrependFloat32Slot(0, latitude, 0.0)

def AddLatitude(builder: flatbuffers.Builder, latitude: float):
    ClimateApiResponseAddLatitude(builder, latitude)

def ClimateApiResponseAddLongitude(builder: flatbuffers.Builder, longitude: float):
    builder.PrependFloat32Slot(1, longitude, 0.0)

def AddLongitude(builder: flatbuffers.Builder, longitude: float):
    ClimateApiResponseAddLongitude(builder, longitude)

def ClimateApiResponseAddElevation(builder: flatbuffers.Builder, elevation: float):
    builder.PrependFloat32Slot(2, elevation, 0.0)

def AddElevation(builder: flatbuffers.Builder, elevation: float):
    ClimateApiResponseAddElevation(builder, elevation)

def ClimateApiResponseAddModel(builder: flatbuffers.Builder, model: int):
    builder.PrependInt8Slot(3, model, 0)

def AddModel(builder: flatbuffers.Builder, model: int):
    ClimateApiResponseAddModel(builder, model)

def ClimateApiResponseAddGenerationtimeMs(builder: flatbuffers.Builder, generationtimeMs: float):
    builder.PrependFloat32Slot(4, generationtimeMs, 0.0)

def AddGenerationtimeMs(builder: flatbuffers.Builder, generationtimeMs: float):
    ClimateApiResponseAddGenerationtimeMs(builder, generationtimeMs)

def ClimateApiResponseAddDaily(builder: flatbuffers.Builder, daily: int):
    builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(daily), 0)

def AddDaily(builder: flatbuffers.Builder, daily: int):
    ClimateApiResponseAddDaily(builder, daily)

def ClimateApiResponseEnd(builder: flatbuffers.Builder) -> int:
    return builder.EndObject()

def End(builder: flatbuffers.Builder) -> int:
    return ClimateApiResponseEnd(builder)
