/*
 * Solidarity Mobility API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * API version: 1.0.0
 * Generated by: OpenAPI Generator (https://openapi-generator.tech)
 */

package Solidarity_api

import (
	"github.com/spf13/viper"
	"log"
	"net/http"
	"solidarity-service/handler"
	"solidarity-service/interoperability/solidarity-api/server/openapi"
	"solidarity-service/storage"
)

func Run(cfg *viper.Viper, handler *handler.SolidarityServiceHandler, storage storage.Storage) {
	BookingsFilterAPIService := openapi.NewBookingsFilterAPIService(cfg, handler, storage)
	BookingsFilterAPIController := openapi.NewBookingsFilterAPIController(BookingsFilterAPIService)

	DriverAvailabilityAndScheduleAPIService := openapi.NewDriverAvailabilityAndScheduleAPIService(cfg, handler, storage)
	DriverAvailabilityAndScheduleAPIController := openapi.NewDriverAvailabilityAndScheduleAPIController(DriverAvailabilityAndScheduleAPIService)

	InteractAPIService := openapi.NewInteractAPIService(cfg, handler, storage)
	InteractAPIController := openapi.NewInteractAPIController(InteractAPIService)

	PassengerTripRequestAPIService := openapi.NewPassengerTripRequestAPIService(cfg, handler, storage)
	PassengerTripRequestAPIController := openapi.NewPassengerTripRequestAPIController(PassengerTripRequestAPIService)

	SearchAPIService := openapi.NewSearchAPIService(cfg, handler, storage)
	SearchAPIController := openapi.NewSearchAPIController(SearchAPIService)

	router := openapi.NewRouter(BookingsFilterAPIController, DriverAvailabilityAndScheduleAPIController, InteractAPIController, PassengerTripRequestAPIController, SearchAPIController)

	log.Fatal(http.ListenAndServe(cfg.GetString("services.solidarity-api.address"), router))
}