Lines of Code | 70 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | "use strict"; |
||
2 | |||
3 | class Request { |
||
4 | /** |
||
5 | * @param {string} uri |
||
6 | * @param {string} method |
||
7 | * @param {Object} payload |
||
8 | * @param {Object} queryString |
||
9 | * @param {Object} headers |
||
10 | * @param {boolean} json |
||
11 | */ |
||
12 | constructor(uri, method = 'GET', payload = {}, queryString = {}, headers = {}, json = true) { |
||
13 | 10 | this.uri = uri; |
|
14 | 10 | this.method = method; |
|
15 | 10 | this.payload = payload; |
|
16 | 10 | this.queryString = queryString; |
|
17 | 10 | this.headers = headers; |
|
18 | 10 | this.json = json; |
|
19 | } |
||
20 | |||
21 | /** |
||
22 | * @public |
||
23 | * @returns {string} |
||
24 | */ |
||
25 | getUri() { |
||
26 | 14 | return this.uri; |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * @public |
||
31 | * @returns {Object} |
||
32 | */ |
||
33 | getPayload() { |
||
34 | 23 | return this.payload; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @public |
||
39 | * @returns {Object} |
||
40 | */ |
||
41 | getQueryString() { |
||
42 | 22 | return this.queryString; |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * @public |
||
47 | * @returns {Object} |
||
48 | */ |
||
49 | getHeaders() { |
||
50 | 14 | return this.headers; |
|
51 | } |
||
52 | |||
53 | /** |
||
54 | * @public |
||
55 | * @returns {string} |
||
56 | */ |
||
57 | getMethod() { |
||
58 | 14 | return this.method; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * @public |
||
63 | * @returns {boolean} |
||
64 | */ |
||
65 | isJson() { |
||
66 | 14 | return this.json; |
|
67 | } |
||
68 | } |
||
69 | |||
70 | module.exports = Request; |
||
71 |