Clean audit log endpoint code
This commit is contained in:
parent
29aa2cc936
commit
42c3a54104
|
@ -14,48 +14,13 @@ export interface AuditLogEndpoints {
|
|||
getDownloadUrl: (opts: DownloadAuditLogsRequest) => string
|
||||
}
|
||||
|
||||
const buildOpts = (opts: SearchAuditLogsRequest) => {
|
||||
const { bookmark, startDate, endDate, fullSearch, events, userIds, appIds } =
|
||||
opts
|
||||
const parsedOpts: SearchAuditLogsRequest = {}
|
||||
|
||||
if (bookmark) {
|
||||
parsedOpts.bookmark = bookmark
|
||||
}
|
||||
|
||||
if (opts.startDate && endDate) {
|
||||
parsedOpts.startDate = startDate
|
||||
parsedOpts.endDate = endDate
|
||||
} else if (startDate && !endDate) {
|
||||
parsedOpts.startDate = startDate
|
||||
}
|
||||
|
||||
if (fullSearch) {
|
||||
parsedOpts.fullSearch = fullSearch
|
||||
}
|
||||
|
||||
if (events?.length) {
|
||||
parsedOpts.events = events
|
||||
}
|
||||
|
||||
if (userIds?.length) {
|
||||
parsedOpts.userIds = userIds
|
||||
}
|
||||
|
||||
if (appIds?.length) {
|
||||
parsedOpts.appIds = appIds
|
||||
}
|
||||
|
||||
return parsedOpts
|
||||
}
|
||||
|
||||
export const buildAuditLogEndpoints = (
|
||||
API: BaseAPIClient
|
||||
): AuditLogEndpoints => ({
|
||||
searchAuditLogs: async opts => {
|
||||
return await API.post({
|
||||
url: `/api/global/auditlogs/search`,
|
||||
body: buildOpts(opts),
|
||||
body: opts,
|
||||
})
|
||||
},
|
||||
getEventDefinitions: async () => {
|
||||
|
|
Loading…
Reference in New Issue