// angular
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

// libs
import { Observable } from 'rxjs';

// app
import { ApiRoutes } from '../api-routes';
import { MotionModel } from '../model/motion.model';
import { AccountCategoryModel } from '../model/account.category.model';
import { MotionCategoryModel } from '../model/motion.category.model';

@Injectable()
export class MotionService {

	constructor(
		private httpClient: HttpClient,
	) {
	}

	public getCategories(category?: string): Observable<MotionCategoryModel[]> {
		return this.httpClient
			.get<MotionCategoryModel[]>(ApiRoutes.SettingsMotionCategories);
	}

	public getMotions(categoryId?: string): Observable<MotionModel[]> {
		var url = categoryId
			? ApiRoutes.SettingsMotions + "?category=" + categoryId
			: ApiRoutes.SettingsMotions;

		return this.httpClient
			.get<MotionCategoryModel[]>(url);
	}
}
