// Path: src/main/java/net/atos/entng/rbs/models/Availability.java
// public class Availability {
// 	private final Integer availability_id;
// 	private final JsonObject json;
// 	private String selectedDaysBitString;
// 	private final ZonedDateTime start_date;
// 	private final ZonedDateTime end_date;
// 	private final ZonedDateTime start_time;
// 	private final ZonedDateTime end_time;
// 	DateTimeFormatter sqlDateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 	DateTimeFormatter sqlTimeFormatter = DateTimeFormatter.ofPattern("HH:mm");
// 
// 	public Availability(JsonObject json) {
// 		this(json, json.getString("iana"), null);
// 	}
// 
// 	public Availability(JsonObject json, Integer id) {
// 		this(json, json.getString("iana"), id);
// 	}
// 
// 	public Availability(JsonObject json, String iana, Integer id) {
// 		super();
// 		this.json = json;
// 		this.availability_id = id > 0 ? id : null;
// 		this.start_date = BookingDateUtils.localDateTimeForTimestampSecondsAndIana(json.getLong("start_date", 0l), iana);
// 		this.end_date = BookingDateUtils.localDateTimeForTimestampSecondsAndIana(json.getLong("end_date", 0l), iana);
// 		this.start_time = BookingDateUtils.localDateTimeForTimestampSecondsAndIana(json.getLong("start_time", 0l), iana);
// 		this.end_time = BookingDateUtils.localDateTimeForTimestampSecondsAndIana(json.getLong("end_time", 0l), iana);
// 	}
// 
// 
// 
// 	public Integer getId() {
// 		return availability_id;
// 	}
// 
// 	public Integer getResourceId() {
// 		return json.getInteger("resource_id");
// 	}
// 
// 	public Integer getQuantity() {
// 		return json.getInteger("quantity");
// 	}
// 
// 	public Boolean isUnavailability() {
// 		return json.getBoolean("is_unavailability");
// 	}
// 
// 	public String getStartDate() {
// 		return sqlDateFormatter.format(this.start_date);
// 	}
// 
// 	public String getEndDate() {
// 		return sqlDateFormatter.format(this.end_date);
// 	}
// 
// 	public String getStartTime() {
// 		return sqlTimeFormatter.format(this.start_time);
// 	}
// 
// 	public String getEndTime() {
// 		return sqlTimeFormatter.format(this.end_time);
// 	}
// 
// 	public Optional<JsonArray> getDays() {
// 		return Optional.ofNullable(json.getJsonArray("days", null));
// 	}
// 
// 	public String getSelectedDaysBitString() {
// 		if (selectedDaysBitString == null) {
// 			computeSelectedDaysAsBitString();
// 		}
// 		return selectedDaysBitString;
// 	}
// 
// 	public void computeSelectedDaysAsBitString() {
// 		JsonArray selectedDaysArray = getDays().get();
// 		StringBuilder selectedDays = new StringBuilder();
// 		for (Object day : selectedDaysArray) {
// 			int isSelectedDay = ((Boolean) day) ? 1 : 0;
// 			selectedDays.append(isSelectedDay);
// 		}
// 		selectedDaysBitString = selectedDays.toString();
// 	}
// }


import fr.wseduc.webutils.Either;
import net.atos.entng.rbs.models.Availability;
import org.entcore.common.service.CrudService;
import org.entcore.common.user.UserInfos;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
/*
 * Copyright © Région Nord Pas de Calais-Picardie,  Département 91, Région Aquitaine-Limousin-Poitou-Charentes, 2016.
 *
 * This file is part of OPEN ENT NG. OPEN ENT NG is a versatile ENT Project based on the JVM and ENT Core Project.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation (version 3 of the License).
 *
 * For the sake of explanation, any module that communicate over native
 * Web protocols, such as HTTP, with OPEN ENT NG is outside the scope of this
 * license and could be license under its own terms. This is merely considered
 * normal use of OPEN ENT NG, and does not fall under the heading of "covered work".
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

package net.atos.entng.rbs.service;


public interface AvailabilityService extends CrudService {
	/**
	 * List all the (un)availabilities of a user
	 *
	 * @param resourceIds : resources' id
	 * @param user     : information of current user logged
	 * @param handler  : handler which contains the response
	 */
	void listAvailabilities(JsonArray resourceIds, UserInfos user, Handler<Either<String, JsonArray>> handler);

	/**
	 * List all the (un)availabilities of a resource
	 *
	 * @param resourceId : resource id
	 * @param is_unavailability : type of (un)availability to list
	 * @param user     : information of current user logged
	 * @param handler  : handler which contains the response
	 */
	void listResourceAvailability(Integer resourceId, boolean is_unavailability, UserInfos user, Handler<Either<String, JsonArray>> handler);

	/**
	 * Create an (un)availability
	 *
	 * @param availability : current (un)availability
	 * @param user     : information of current user logged
	 * @param handler  : handler which contains the response
	 */
	void createAvailability(Availability availability, UserInfos user, Handler<Either<String, JsonObject>> handler);

	/**
	 * Update an (un)availability
	 *
	 * @param availability : current (un)availability
	 * @param user     : information of current user logged
	 * @param handler  : handler which contains the response
	 */
// Path: src/main/java/net/atos/entng/rbs/models/Availability.java
// public class Availability {
// 	private final Integer availability_id;
// 	private final JsonObject json;
// 	private String selectedDaysBitString;
// 	private final ZonedDateTime start_date;
// 	private final ZonedDateTime end_date;
// 	private final ZonedDateTime start_time;
// 	private final ZonedDateTime end_time;
// 	DateTimeFormatter sqlDateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 	DateTimeFormatter sqlTimeFormatter = DateTimeFormatter.ofPattern("HH:mm");
// 
// 	public Availability(JsonObject json) {
// 		this(json, json.getString("iana"), null);
// 	}
// 
// 	public Availability(JsonObject json, Integer id) {
// 		this(json, json.getString("iana"), id);
// 	}
// 
// 	public Availability(JsonObject json, String iana, Integer id) {
// 		super();
// 		this.json = json;
// 		this.availability_id = id > 0 ? id : null;
// 		this.start_date = BookingDateUtils.localDateTimeForTimestampSecondsAndIana(json.getLong("start_date", 0l), iana);
// 		this.end_date = BookingDateUtils.localDateTimeForTimestampSecondsAndIana(json.getLong("end_date", 0l), iana);
// 		this.start_time = BookingDateUtils.localDateTimeForTimestampSecondsAndIana(json.getLong("start_time", 0l), iana);
// 		this.end_time = BookingDateUtils.localDateTimeForTimestampSecondsAndIana(json.getLong("end_time", 0l), iana);
// 	}
// 
// 
// 
// 	public Integer getId() {
// 		return availability_id;
// 	}
// 
// 	public Integer getResourceId() {
// 		return json.getInteger("resource_id");
// 	}
// 
// 	public Integer getQuantity() {
// 		return json.getInteger("quantity");
// 	}
// 
// 	public Boolean isUnavailability() {
// 		return json.getBoolean("is_unavailability");
// 	}
// 
// 	public String getStartDate() {
// 		return sqlDateFormatter.format(this.start_date);
// 	}
// 
// 	public String getEndDate() {
// 		return sqlDateFormatter.format(this.end_date);
// 	}
// 
// 	public String getStartTime() {
// 		return sqlTimeFormatter.format(this.start_time);
// 	}
// 
// 	public String getEndTime() {
// 		return sqlTimeFormatter.format(this.end_time);
// 	}
// 
// 	public Optional<JsonArray> getDays() {
// 		return Optional.ofNullable(json.getJsonArray("days", null));
// 	}
// 
// 	public String getSelectedDaysBitString() {
// 		if (selectedDaysBitString == null) {
// 			computeSelectedDaysAsBitString();
// 		}
// 		return selectedDaysBitString;
// 	}
// 
// 	public void computeSelectedDaysAsBitString() {
// 		JsonArray selectedDaysArray = getDays().get();
// 		StringBuilder selectedDays = new StringBuilder();
// 		for (Object day : selectedDaysArray) {
// 			int isSelectedDay = ((Boolean) day) ? 1 : 0;
// 			selectedDays.append(isSelectedDay);
// 		}
// 		selectedDaysBitString = selectedDays.toString();
// 	}
// }


// Path: src/main/java/net/atos/entng/rbs/service/AvailabilityService.java
import fr.wseduc.webutils.Either;
import net.atos.entng.rbs.models.Availability;
import org.entcore.common.service.CrudService;
import org.entcore.common.user.UserInfos;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;

/*
 * Copyright © Région Nord Pas de Calais-Picardie,  Département 91, Région Aquitaine-Limousin-Poitou-Charentes, 2016.
 *
 * This file is part of OPEN ENT NG. OPEN ENT NG is a versatile ENT Project based on the JVM and ENT Core Project.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation (version 3 of the License).
 *
 * For the sake of explanation, any module that communicate over native
 * Web protocols, such as HTTP, with OPEN ENT NG is outside the scope of this
 * license and could be license under its own terms. This is merely considered
 * normal use of OPEN ENT NG, and does not fall under the heading of "covered work".
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

package net.atos.entng.rbs.service;


public interface AvailabilityService extends CrudService {
	/**
	 * List all the (un)availabilities of a user
	 *
	 * @param resourceIds : resources' id
	 * @param user     : information of current user logged
	 * @param handler  : handler which contains the response
	 */
	void listAvailabilities(JsonArray resourceIds, UserInfos user, Handler<Either<String, JsonArray>> handler);

	/**
	 * List all the (un)availabilities of a resource
	 *
	 * @param resourceId : resource id
	 * @param is_unavailability : type of (un)availability to list
	 * @param user     : information of current user logged
	 * @param handler  : handler which contains the response
	 */
	void listResourceAvailability(Integer resourceId, boolean is_unavailability, UserInfos user, Handler<Either<String, JsonArray>> handler);

	/**
	 * Create an (un)availability
	 *
	 * @param availability : current (un)availability
	 * @param user     : information of current user logged
	 * @param handler  : handler which contains the response
	 */
	void createAvailability(Availability availability, UserInfos user, Handler<Either<String, JsonObject>> handler);

	/**
	 * Update an (un)availability
	 *
	 * @param availability : current (un)availability
	 * @param user     : information of current user logged
	 * @param handler  : handler which contains the response
	 */
	void updateAvailability(Availability availability, UserInfos user, Handler<Either<String, JsonObject>> handler);