Passed
Push — master ( a52040...8805a7 )
by Benjamin
12:48 queued 06:14
created

src/web/assets/videos/src/js/api/videos.js   A

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 53
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 28
c 0
b 0
f 0
dl 0
loc 53
rs 10
wmc 5
mnd 1
bc 1
fnc 4
bpm 0.25
cpm 1.25
noi 0
1
/* global Craft */
2
3
import axios from 'axios'
4
5
export default {
6
  getGateways() {
7
    return axios.get(Craft.getActionUrl('videos/explorer/get-gateways'), {
8
      headers: {
9
        'X-CSRF-Token': Craft.csrfTokenValue,
10
      }
11
    })
12
  },
13
14
  getVideos(gateway, method, options) {
15
    const data = {
16
      gateway,
17
      method,
18
    }
19
20
    if (options) {
21
      data.options = options
22
    }
23
24
    return axios.post(Craft.getActionUrl('videos/explorer/get-videos'), data, {
25
      headers: {
26
        'X-CSRF-Token': Craft.csrfTokenValue,
27
      }
28
    })
29
  },
30
31
  getVideo(url) {
32
    const data = {
33
      url
34
    }
35
36
    return axios.post(Craft.getActionUrl('videos/explorer/get-video'), data, {
37
      headers: {
38
        'X-CSRF-Token': Craft.csrfTokenValue,
39
      }
40
    })
41
  },
42
43
  getVideoEmbedHtml(video) {
44
    const data = {
45
      gateway: video.gatewayHandle,
46
      videoId: video.id,
47
    }
48
49
    return axios.post(Craft.getActionUrl('videos/explorer/get-video-embed-html'), data, {
50
      headers: {
51
        'X-CSRF-Token': Craft.csrfTokenValue,
52
      }
53
    })
54
  }
55
}
56