Files
threshold-ui/addons/api/addon/serializers/credential-library.js
T

30 lines
837 B
JavaScript
Raw Normal View History

2021-07-08 11:38:41 -04:00
import ApplicationSerializer from './application';
2023-02-01 13:46:23 -05:00
import { TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC } from '../models/credential-library';
2021-07-08 11:38:41 -04:00
2022-06-28 19:30:26 -04:00
export default class CredentialLibrarySerializer extends ApplicationSerializer {
// =properties
/**
* @type {boolean}
*/
serializeScopeID = false;
2022-06-28 19:30:26 -04:00
/**
* @override
* @method serialize
* @param {Snapshot} snapshot
*/
serialize() {
const serialized = super.serialize(...arguments);
if (serialized.attributes) {
2023-02-01 13:46:23 -05:00
if (serialized.type !== TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC) {
delete serialized.attributes.http_method;
}
2022-06-28 19:30:26 -04:00
// Serialize `http_request_body` only if `http_method` is POST
if (!serialized.attributes?.http_method?.match(/post/i))
delete serialized.attributes.http_request_body;
}
return serialized;
}
}