btrz-api-client 9.26.0 → 9.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client-standalone-min.js +7 -7
- package/lib/endpoints/reports/custom-reports.js +62 -1
- package/package.json +1 -1
- package/src/endpoints/reports/custom-reports.js +39 -1
- package/test/endpoints/reports/custom-reports.test.js +21 -0
- package/test-integration/endpoints/reports/custom-reports.test.js +19 -0
- package/types/endpoints/reports/custom-reports.d.ts +3 -1
|
@@ -15,7 +15,7 @@ const {
|
|
|
15
15
|
* @param {Object} deps
|
|
16
16
|
* @param {import("axios").AxiosInstance} deps.client
|
|
17
17
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
18
|
-
* @returns {{ create: function, all: function, remove: function }}
|
|
18
|
+
* @returns {{ create: function, all: function, get: function, update: function, remove: function }}
|
|
19
19
|
*/
|
|
20
20
|
function customReportsFactory({
|
|
21
21
|
client,
|
|
@@ -78,6 +78,65 @@ function customReportsFactory({
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* GET /custom-report/:customReportId - get one custom report.
|
|
83
|
+
* @param {Object} opts
|
|
84
|
+
* @param {string} [opts.token] - API key
|
|
85
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
86
|
+
* @param {string} opts.customReportId - Custom report id
|
|
87
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
88
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
89
|
+
*/
|
|
90
|
+
function get({
|
|
91
|
+
token,
|
|
92
|
+
jwtToken,
|
|
93
|
+
customReportId,
|
|
94
|
+
headers
|
|
95
|
+
}) {
|
|
96
|
+
return client({
|
|
97
|
+
url: `/custom-report/${customReportId}`,
|
|
98
|
+
headers: authorizationHeaders({
|
|
99
|
+
token,
|
|
100
|
+
jwtToken,
|
|
101
|
+
internalAuthTokenProvider,
|
|
102
|
+
headers
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* PUT /custom-reports/:customReportId - update a custom report.
|
|
109
|
+
* Today the API only accepts deliveryMethod inside customReport.
|
|
110
|
+
* @param {Object} opts
|
|
111
|
+
* @param {string} [opts.token] - API key
|
|
112
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
113
|
+
* @param {string} opts.customReportId - Custom report id
|
|
114
|
+
* @param {Object} opts.customReport - Fields to update
|
|
115
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
116
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
117
|
+
*/
|
|
118
|
+
function update({
|
|
119
|
+
token,
|
|
120
|
+
jwtToken,
|
|
121
|
+
customReportId,
|
|
122
|
+
customReport,
|
|
123
|
+
headers
|
|
124
|
+
}) {
|
|
125
|
+
return client({
|
|
126
|
+
url: `/custom-reports/${customReportId}`,
|
|
127
|
+
method: "put",
|
|
128
|
+
headers: authorizationHeaders({
|
|
129
|
+
token,
|
|
130
|
+
jwtToken,
|
|
131
|
+
internalAuthTokenProvider,
|
|
132
|
+
headers
|
|
133
|
+
}),
|
|
134
|
+
data: {
|
|
135
|
+
customReport
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
81
140
|
/**
|
|
82
141
|
* DELETE /custom-reports/:customReportId - remove custom report.
|
|
83
142
|
* @param {Object} opts
|
|
@@ -107,6 +166,8 @@ function customReportsFactory({
|
|
|
107
166
|
return {
|
|
108
167
|
create,
|
|
109
168
|
all,
|
|
169
|
+
get,
|
|
170
|
+
update,
|
|
110
171
|
remove
|
|
111
172
|
};
|
|
112
173
|
}
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
|
13
13
|
* @param {Object} deps
|
|
14
14
|
* @param {import("axios").AxiosInstance} deps.client
|
|
15
15
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
16
|
-
* @returns {{ create: function, all: function, remove: function }}
|
|
16
|
+
* @returns {{ create: function, all: function, get: function, update: function, remove: function }}
|
|
17
17
|
*/
|
|
18
18
|
function customReportsFactory({client, internalAuthTokenProvider}) {
|
|
19
19
|
/**
|
|
@@ -51,6 +51,42 @@ function customReportsFactory({client, internalAuthTokenProvider}) {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* GET /custom-report/:customReportId - get one custom report.
|
|
56
|
+
* @param {Object} opts
|
|
57
|
+
* @param {string} [opts.token] - API key
|
|
58
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
59
|
+
* @param {string} opts.customReportId - Custom report id
|
|
60
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
61
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
62
|
+
*/
|
|
63
|
+
function get({token, jwtToken, customReportId, headers}) {
|
|
64
|
+
return client({
|
|
65
|
+
url: `/custom-report/${customReportId}`,
|
|
66
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* PUT /custom-reports/:customReportId - update a custom report.
|
|
72
|
+
* Today the API only accepts deliveryMethod inside customReport.
|
|
73
|
+
* @param {Object} opts
|
|
74
|
+
* @param {string} [opts.token] - API key
|
|
75
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
76
|
+
* @param {string} opts.customReportId - Custom report id
|
|
77
|
+
* @param {Object} opts.customReport - Fields to update
|
|
78
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
79
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
80
|
+
*/
|
|
81
|
+
function update({token, jwtToken, customReportId, customReport, headers}) {
|
|
82
|
+
return client({
|
|
83
|
+
url: `/custom-reports/${customReportId}`,
|
|
84
|
+
method: "put",
|
|
85
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
86
|
+
data: {customReport}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
54
90
|
/**
|
|
55
91
|
* DELETE /custom-reports/:customReportId - remove custom report.
|
|
56
92
|
* @param {Object} opts
|
|
@@ -71,6 +107,8 @@ function customReportsFactory({client, internalAuthTokenProvider}) {
|
|
|
71
107
|
return {
|
|
72
108
|
create,
|
|
73
109
|
all,
|
|
110
|
+
get,
|
|
111
|
+
update,
|
|
74
112
|
remove
|
|
75
113
|
};
|
|
76
114
|
}
|
|
@@ -28,4 +28,25 @@ describe("reports/custom-reports", () => {
|
|
|
28
28
|
axiosMock.onDelete(`/custom-reports/${customReportId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
29
29
|
return api.reports.customReports.remove({jwtToken, token, customReportId});
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
it("should get a custom report by id", () => {
|
|
33
|
+
axiosMock.onGet(`/custom-report/${customReportId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
34
|
+
return api.reports.customReports.get({token, jwtToken, customReportId});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should update a custom report", () => {
|
|
38
|
+
const customReport = {
|
|
39
|
+
deliveryMethod: {
|
|
40
|
+
method: "S3",
|
|
41
|
+
options: {bucket: "507f1f77bcf86cd799439011"}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
axiosMock.onPut(`/custom-reports/${customReportId}`).reply(expectRequest({
|
|
45
|
+
statusCode: 200,
|
|
46
|
+
token,
|
|
47
|
+
jwtToken,
|
|
48
|
+
body: {customReport}
|
|
49
|
+
}));
|
|
50
|
+
return api.reports.customReports.update({token, jwtToken, customReportId, customReport});
|
|
51
|
+
});
|
|
31
52
|
});
|
|
@@ -68,4 +68,23 @@ describe("reports/custom-report", () => {
|
|
|
68
68
|
assert.deepStrictEqual(err.response.status, 401);
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
|
+
|
|
72
|
+
it("should not get a custom report when unauthorized", () => {
|
|
73
|
+
return api.reports.customReports.get({token, jwtToken, customReportId: "5a959a4aa7114ffd7f000001"})
|
|
74
|
+
.catch((err) => {
|
|
75
|
+
assert.deepStrictEqual(err.response.status, 401);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should not update a custom report when unauthorized", () => {
|
|
80
|
+
return api.reports.customReports.update({
|
|
81
|
+
token,
|
|
82
|
+
jwtToken,
|
|
83
|
+
customReportId: "5a959a4aa7114ffd7f000001",
|
|
84
|
+
customReport: {deliveryMethod: {method: "S3", options: {bucket: "bucket-1"}}}
|
|
85
|
+
})
|
|
86
|
+
.catch((err) => {
|
|
87
|
+
assert.deepStrictEqual(err.response.status, 401);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
71
90
|
});
|
|
@@ -10,7 +10,7 @@ export = customReportsFactory;
|
|
|
10
10
|
* @param {Object} deps
|
|
11
11
|
* @param {import("axios").AxiosInstance} deps.client
|
|
12
12
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
13
|
-
* @returns {{ create: function, all: function, remove: function }}
|
|
13
|
+
* @returns {{ create: function, all: function, get: function, update: function, remove: function }}
|
|
14
14
|
*/
|
|
15
15
|
declare function customReportsFactory({ client, internalAuthTokenProvider }: {
|
|
16
16
|
client: import("axios").AxiosInstance;
|
|
@@ -20,6 +20,8 @@ declare function customReportsFactory({ client, internalAuthTokenProvider }: {
|
|
|
20
20
|
}): {
|
|
21
21
|
create: Function;
|
|
22
22
|
all: Function;
|
|
23
|
+
get: Function;
|
|
24
|
+
update: Function;
|
|
23
25
|
remove: Function;
|
|
24
26
|
};
|
|
25
27
|
declare namespace customReportsFactory {
|