summaryrefslogtreecommitdiffstats
path: root/models/import.js
blob: 2e58c90f73a91ce130e3765f7b665bfebdf19d46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { TrelloCreator } from './trelloCreator';
import { WekanCreator } from './wekanCreator';

Meteor.methods({
  importBoard(board, data, importSource) {
    check(board, Object);
    check(data, Object);
    check(importSource, String);
    let creator;
    switch (importSource) {
    case 'trello':
      creator = new TrelloCreator(data);
      break;
    case 'wekan':
      creator = new WekanCreator(data);
      break;
    }

    // 1. check all parameters are ok from a syntax point of view
    creator.check(board);

    // 2. check parameters are ok from a business point of view (exist &
    // authorized) nothing to check, everyone can import boards in their account

    // 3. create all elements
    return creator.create(board);
  },
});