Server/project/src/callbacks/WeatherCallbacks.ts
2024-07-05 14:21:30 +01:00

32 lines
1.3 KiB
TypeScript

import { inject, injectable } from "tsyringe";
import { WeatherController } from "@spt/controllers/WeatherController";
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
import { IWeatherData } from "@spt/models/eft/weather/IWeatherData";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { IGetLocalWeatherResponseData } from "@spt/models/spt/weather/IGetLocalWeatherResponseData";
@injectable()
export class WeatherCallbacks
{
constructor(
@inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil,
@inject("WeatherController") protected weatherController: WeatherController,
)
{}
/**
* Handle client/weather
* @returns IWeatherData
*/
public getWeather(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IWeatherData>
{
return this.httpResponse.getBody(this.weatherController.generate());
}
public getLocalWeather(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IGetLocalWeatherResponseData>
{
return this.httpResponse.getBody(this.weatherController.generateLocal(sessionID));
}
}