var FilmSvc = function ($http, $q, API_URL) {
	return {
		searchFilms: function (titre, options) {
			var deferred = $q.defer();
			var params = { "s": titre };
			if (options) {
				if (options.type) {
					params["type"] = options.type;
				}
				if (options.annee) {
					params["y"] = options.annee;
				}
				if (options.page) {
					params["page"] = options.page;
				}
			}
			$http({
				method: "GET",
				url: API_URL,
				params: params
			}).then(function success(response) {
				deferred.resolve(response.data);
			}, function error(error) {
				deferred.reject(error.status, error.statusText);
			});
			return deferred.promise;
		},
		getDetailsFilm: function (idFilm) {
			var deferred = $q.defer();
			$http({
				method: "GET",
				url: API_URL,
				params: { "i": idFilm, "plot": "full" }
			}).then(function success(response) {
				deferred.resolve(response.data);
			}, function error(error) {
				deferred.reject(error.status, error.statusText);
			});
			return deferred.promise;
		}
	};
};