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 {
|
2022-09-20 18:24:18 -04:00
|
|
|
// =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;
|
|
|
|
|
}
|
|
|
|
|
}
|