# automatically generated by the FlatBuffers compiler, do not modify

# namespace: fb

from __future__ import annotations

from typing import Any, Optional

import flatbuffers
from flatbuffers.compat import import_numpy

from openmeteo_sdk.fb.WeatherCurrent import WeatherCurrent
from openmeteo_sdk.fb.WeatherDaily import WeatherDaily
from openmeteo_sdk.fb.WeatherHourly import WeatherHourly

np = import_numpy()


class WeatherApiResponse:
    __slots__ = ["_tab"]

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

    @classmethod
    def GetRootAsWeatherApiResponse(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)

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

    # WeatherApiResponse
    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

    # WeatherApiResponse
    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

    # WeatherApiResponse
    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

    # WeatherApiResponse
    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

    # WeatherApiResponse
    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

    # WeatherApiResponse
    def UtcOffsetSeconds(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
        return 0

    # WeatherApiResponse
    def Timezone(self) -> str | None:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # WeatherApiResponse
    def TimezoneAbbreviation(self) -> str | None:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # WeatherApiResponse
    def Daily(self) -> WeatherDaily | None:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = WeatherDaily()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # WeatherApiResponse
    def Hourly(self) -> WeatherHourly | None:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = WeatherHourly()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # WeatherApiResponse
    def SixHourly(self) -> WeatherHourly | None:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = WeatherHourly()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # WeatherApiResponse
    def Minutely15(self) -> WeatherHourly | None:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = WeatherHourly()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # WeatherApiResponse
    def Current(self) -> WeatherCurrent | None:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = WeatherCurrent()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None


def WeatherApiResponseStart(builder: flatbuffers.Builder):
    builder.StartObject(13)


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


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


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


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


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


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


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


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


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


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


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


def WeatherApiResponseAddUtcOffsetSeconds(builder: flatbuffers.Builder, utcOffsetSeconds: int):
    builder.PrependInt32Slot(5, utcOffsetSeconds, 0)


def AddUtcOffsetSeconds(builder: flatbuffers.Builder, utcOffsetSeconds: int):
    WeatherApiResponseAddUtcOffsetSeconds(builder, utcOffsetSeconds)


def WeatherApiResponseAddTimezone(builder: flatbuffers.Builder, timezone: int):
    builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(timezone), 0)


def AddTimezone(builder: flatbuffers.Builder, timezone: int):
    WeatherApiResponseAddTimezone(builder, timezone)


def WeatherApiResponseAddTimezoneAbbreviation(builder: flatbuffers.Builder, timezoneAbbreviation: int):
    builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(timezoneAbbreviation), 0)


def AddTimezoneAbbreviation(builder: flatbuffers.Builder, timezoneAbbreviation: int):
    WeatherApiResponseAddTimezoneAbbreviation(builder, timezoneAbbreviation)


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


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


def WeatherApiResponseAddHourly(builder: flatbuffers.Builder, hourly: int):
    builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(hourly), 0)


def AddHourly(builder: flatbuffers.Builder, hourly: int):
    WeatherApiResponseAddHourly(builder, hourly)


def WeatherApiResponseAddSixHourly(builder: flatbuffers.Builder, sixHourly: int):
    builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(sixHourly), 0)


def AddSixHourly(builder: flatbuffers.Builder, sixHourly: int):
    WeatherApiResponseAddSixHourly(builder, sixHourly)


def WeatherApiResponseAddMinutely15(builder: flatbuffers.Builder, minutely15: int):
    builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(minutely15), 0)


def AddMinutely15(builder: flatbuffers.Builder, minutely15: int):
    WeatherApiResponseAddMinutely15(builder, minutely15)


def WeatherApiResponseAddCurrent(builder: flatbuffers.Builder, current: int):
    builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(current), 0)


def AddCurrent(builder: flatbuffers.Builder, current: int):
    WeatherApiResponseAddCurrent(builder, current)


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


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