Skip to content

Commit 890c967

Browse files
resources(Projects): use API_PREFIX from config, rename Http to
ApiRequest.
1 parent 1ace4d3 commit 890c967

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/lib/resources/projects.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
* LICENSE file in the root directory.
77
*/
88

9-
const Http = require('../http/http')
9+
const ApiRequest = require('../request/api')
1010

1111
const Params = require('../../util/params')
1212

13+
const { API_PREFIX } = require('../../config/config')
14+
1315
class Projects {
1416
/**
1517
* @param {Object} [payload]
@@ -20,10 +22,10 @@ class Projects {
2022
const qs = Params.destructParams(payload, ['limit', 'offset'])
2123

2224
const options = {
23-
endpoint: `${Projects.API_PREFIX}/projects`,
25+
endpoint: `${API_PREFIX}/projects`,
2426
qs
2527
}
26-
return Http.authorizedRequest(options)
28+
return ApiRequest.authorizedRequest(options)
2729
}
2830

2931
/**
@@ -36,10 +38,10 @@ class Projects {
3638

3739
const options = {
3840
method: 'POST',
39-
endpoint: `${Projects.API_PREFIX}/projects`,
41+
endpoint: `${API_PREFIX}/projects`,
4042
body
4143
}
42-
return Http.authorizedRequest(options)
44+
return ApiRequest.authorizedRequest(options)
4345
}
4446

4547
/**
@@ -51,10 +53,10 @@ class Projects {
5153
const qs = Params.destructParams(payload, ['templateId'])
5254

5355
const options = {
54-
endpoint: `${Projects.API_PREFIX}/projects/trial`,
56+
endpoint: `${API_PREFIX}/projects/trial`,
5557
qs
5658
}
57-
return Http.unauthorizedRequest(options)
59+
return ApiRequest.unauthorizedRequest(options)
5860
}
5961

6062
/**
@@ -66,9 +68,9 @@ class Projects {
6668
const projectId = Params.destructURLParam(payload, 'projectId')
6769

6870
const options = {
69-
endpoint: `${Projects.API_PREFIX}/projects/${projectId}`
71+
endpoint: `${API_PREFIX}/projects/${projectId}`
7072
}
71-
return Http.authorizedRequest(options)
73+
return ApiRequest.authorizedRequest(options)
7274
}
7375

7476
/**
@@ -82,10 +84,10 @@ class Projects {
8284

8385
const options = {
8486
method: 'PATCH',
85-
endpoint: `${Projects.API_PREFIX}/projects/${projectId}`,
87+
endpoint: `${API_PREFIX}/projects/${projectId}`,
8688
body
8789
}
88-
return Http.authorizedRequest(options)
90+
return ApiRequest.authorizedRequest(options)
8991
}
9092

9193
/**
@@ -98,9 +100,9 @@ class Projects {
98100

99101
const options = {
100102
method: 'DELETE',
101-
endpoint: `${Projects.API_PREFIX}/projects/${projectId}`
103+
endpoint: `${API_PREFIX}/projects/${projectId}`
102104
}
103-
return Http.authorizedRequest(options)
105+
return ApiRequest.authorizedRequest(options)
104106
}
105107

106108
/**
@@ -114,10 +116,10 @@ class Projects {
114116

115117
const options = {
116118
method: 'POST',
117-
endpoint: `${Projects.API_PREFIX}/projects/${projectId}/apply-template-preset`,
119+
endpoint: `${API_PREFIX}/projects/${projectId}/apply-template-preset`,
118120
body
119121
}
120-
return Http.authorizedRequest(options)
122+
return ApiRequest.authorizedRequest(options)
121123
}
122124

123125
/**
@@ -130,9 +132,9 @@ class Projects {
130132

131133
const options = {
132134
method: 'POST',
133-
endpoint: `${Projects.API_PREFIX}/projects/${projectId}/duplicate`
135+
endpoint: `${API_PREFIX}/projects/${projectId}/duplicate`
134136
}
135-
return Http.authorizedRequest(options)
137+
return ApiRequest.authorizedRequest(options)
136138
}
137139

138140
/**
@@ -146,13 +148,11 @@ class Projects {
146148

147149
const options = {
148150
method: 'POST',
149-
endpoint: `${Projects.API_PREFIX}/projects/${projectId}/render`,
151+
endpoint: `${API_PREFIX}/projects/${projectId}/render`,
150152
body
151153
}
152-
return Http.authorizedRequest(options)
154+
return ApiRequest.authorizedRequest(options)
153155
}
154156
}
155157

156-
Projects.API_PREFIX = '/api/v1'
157-
158158
module.exports = Projects

0 commit comments

Comments
 (0)