box-typescript-sdk-gen
Version:
Official Box TypeScript Generated SDK
101 lines • 3.52 kB
JavaScript
import { deserializeFileBaseTypeField } from './fileBase.generated.js';
import { serializeFileBase } from './fileBase.generated.js';
import { serializeFileVersionMini } from './fileVersionMini.generated.js';
import { deserializeFileVersionMini } from './fileVersionMini.generated.js';
import { FileBase } from './fileBase.generated.js';
import { BoxSdkError } from '../box/errors.js';
import { sdIsString } from '../serialization/json.js';
import { sdIsMap } from '../serialization/json.js';
export class FileMini extends FileBase {
constructor(fields) {
super(fields);
if (fields.sequenceId !== undefined) {
this.sequenceId = fields.sequenceId;
}
if (fields.name !== undefined) {
this.name = fields.name;
}
if (fields.sha1 !== undefined) {
this.sha1 = fields.sha1;
}
if (fields.fileVersion !== undefined) {
this.fileVersion = fields.fileVersion;
}
}
}
export function serializeFileMini(val) {
const base = serializeFileBase(val);
if (!sdIsMap(base)) {
throw new BoxSdkError({ message: 'Expecting a map for "FileMini"' });
}
return {
...base,
...{
['sequence_id']: val.sequenceId,
['name']: val.name,
['sha1']: val.sha1,
['file_version']: val.fileVersion == void 0
? val.fileVersion
: serializeFileVersionMini(val.fileVersion),
},
};
}
export function deserializeFileMini(val) {
if (!sdIsMap(val)) {
throw new BoxSdkError({ message: 'Expecting a map for "FileMini"' });
}
if (!(val.sequence_id == void 0) && !sdIsString(val.sequence_id)) {
throw new BoxSdkError({
message: 'Expecting string for "sequence_id" of type "FileMini"',
});
}
const sequenceId = val.sequence_id == void 0 ? void 0 : val.sequence_id;
if (!(val.name == void 0) && !sdIsString(val.name)) {
throw new BoxSdkError({
message: 'Expecting string for "name" of type "FileMini"',
});
}
const name = val.name == void 0 ? void 0 : val.name;
if (!(val.sha1 == void 0) && !sdIsString(val.sha1)) {
throw new BoxSdkError({
message: 'Expecting string for "sha1" of type "FileMini"',
});
}
const sha1 = val.sha1 == void 0 ? void 0 : val.sha1;
const fileVersion = val.file_version == void 0
? void 0
: deserializeFileVersionMini(val.file_version);
if (val.id == void 0) {
throw new BoxSdkError({
message: 'Expecting "id" of type "FileMini" to be defined',
});
}
if (!sdIsString(val.id)) {
throw new BoxSdkError({
message: 'Expecting string for "id" of type "FileMini"',
});
}
const id = val.id;
if (!(val.etag == void 0) && !sdIsString(val.etag)) {
throw new BoxSdkError({
message: 'Expecting string for "etag" of type "FileMini"',
});
}
const etag = val.etag == void 0 ? void 0 : val.etag;
if (val.type == void 0) {
throw new BoxSdkError({
message: 'Expecting "type" of type "FileMini" to be defined',
});
}
const type = deserializeFileBaseTypeField(val.type);
return {
sequenceId: sequenceId,
name: name,
sha1: sha1,
fileVersion: fileVersion,
id: id,
etag: etag,
type: type,
};
}
//# sourceMappingURL=fileMini.generated.js.map