{"size": 890, "ext": "js", "max_stars_repo_path": "resources/assets/js/services/tasklists.js", "max_stars_repo_name": "rupertjeff/reactjs-play", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "resources/assets/js/services/tasklists.js", "max_issues_repo_name": "rupertjeff/reactjs-play", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "resources/assets/js/services/tasklists.js", "max_forks_repo_name": "rupertjeff/reactjs-play", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.9696969697, "max_line_length": 85, "alphanum_fraction": 0.5337078652}
import BaseService from './base';
import isArray from '../helpers/isArray';

class TaskListService extends BaseService {
    constructor() {
        super('tasklists');

        this.server.interceptors.response.use((response) => {
            if (isArray(response.data)) {
                return Promise.resolve({
                    data: response.data.map((tasklist) => {
                        tasklist.tasks = tasklist.tasks.data;

                        return tasklist;
                    })
                });
            }

            response.data.tasks = response.data.tasks.data;

            return Promise.resolve(response.data);
        }, (error) => {
            return Promise.reject(error);
        });
    }

    sort(orderedTaskLists) {
        return this.server.patch([this.baseUrl, 'sort'].join('/'), orderedTaskLists);
    }
}

export default TaskListService;
