summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/related_issues/services/related_issues_service.js
blob: 3c19f63157e3e9d0a1d26517337c7cd297ae328b (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
29
30
31
32
33
34
import axios from '~/lib/utils/axios_utils';
import { linkedIssueTypesMap } from '../constants';

class RelatedIssuesService {
  constructor(endpoint) {
    this.endpoint = endpoint;
  }

  fetchRelatedIssues() {
    return axios.get(this.endpoint);
  }

  addRelatedIssues(newIssueReferences, linkType = linkedIssueTypesMap.RELATES_TO) {
    return axios.post(this.endpoint, {
      issuable_references: newIssueReferences,
      link_type: linkType,
    });
  }

  static saveOrder({ endpoint, move_before_id, move_after_id }) {
    return axios.put(endpoint, {
      epic: {
        move_before_id,
        move_after_id,
      },
    });
  }

  static remove(endpoint) {
    return axios.delete(endpoint);
  }
}

export default RelatedIssuesService;