box-node-sdk
Version:
Official SDK for Box Platform APIs
131 lines (130 loc) • 3.74 kB
text/typescript
import { BoxSdkError } from '../../box/errors';
import { SerializedData } from '../../serialization/json';
import { sdIsEmpty } from '../../serialization/json';
import { sdIsBoolean } from '../../serialization/json';
import { sdIsNumber } from '../../serialization/json';
import { sdIsString } from '../../serialization/json';
import { sdIsList } from '../../serialization/json';
import { sdIsMap } from '../../serialization/json';
export type GroupBaseV2025R0TypeField = 'group';
export class GroupBaseV2025R0 {
/**
* The unique identifier for this object. */
readonly id!: string;
/**
* The value will always be `group`. */
readonly type: GroupBaseV2025R0TypeField =
'group' as GroupBaseV2025R0TypeField;
readonly rawData?: SerializedData;
constructor(
fields: Omit<GroupBaseV2025R0, 'type'> &
Partial<Pick<GroupBaseV2025R0, 'type'>>,
) {
if (fields.id !== undefined) {
this.id = fields.id;
}
if (fields.type !== undefined) {
this.type = fields.type;
}
if (fields.rawData !== undefined) {
this.rawData = fields.rawData;
}
}
}
export interface GroupBaseV2025R0Input {
/**
* The unique identifier for this object. */
readonly id: string;
/**
* The value will always be `group`. */
readonly type?: GroupBaseV2025R0TypeField;
readonly rawData?: SerializedData;
}
export function serializeGroupBaseV2025R0TypeField(
val: GroupBaseV2025R0TypeField,
): SerializedData {
return val;
}
export function deserializeGroupBaseV2025R0TypeField(
val: SerializedData,
): GroupBaseV2025R0TypeField {
if (val == 'group') {
return val;
}
throw new BoxSdkError({
message: "Can't deserialize GroupBaseV2025R0TypeField",
});
}
export function serializeGroupBaseV2025R0(
val: GroupBaseV2025R0,
): SerializedData {
return {
['id']: val.id,
['type']: serializeGroupBaseV2025R0TypeField(val.type),
};
}
export function deserializeGroupBaseV2025R0(
val: SerializedData,
): GroupBaseV2025R0 {
if (!sdIsMap(val)) {
throw new BoxSdkError({
message: 'Expecting a map for "GroupBaseV2025R0"',
});
}
if (val.id == void 0) {
throw new BoxSdkError({
message: 'Expecting "id" of type "GroupBaseV2025R0" to be defined',
});
}
if (!sdIsString(val.id)) {
throw new BoxSdkError({
message: 'Expecting string for "id" of type "GroupBaseV2025R0"',
});
}
const id: string = val.id;
if (val.type == void 0) {
throw new BoxSdkError({
message: 'Expecting "type" of type "GroupBaseV2025R0" to be defined',
});
}
const type: GroupBaseV2025R0TypeField = deserializeGroupBaseV2025R0TypeField(
val.type,
);
return { id: id, type: type } satisfies GroupBaseV2025R0;
}
export function serializeGroupBaseV2025R0Input(
val: GroupBaseV2025R0Input,
): SerializedData {
return {
['id']: val.id,
['type']:
val.type == void 0
? val.type
: serializeGroupBaseV2025R0TypeField(val.type),
};
}
export function deserializeGroupBaseV2025R0Input(
val: SerializedData,
): GroupBaseV2025R0Input {
if (!sdIsMap(val)) {
throw new BoxSdkError({
message: 'Expecting a map for "GroupBaseV2025R0Input"',
});
}
if (val.id == void 0) {
throw new BoxSdkError({
message: 'Expecting "id" of type "GroupBaseV2025R0Input" to be defined',
});
}
if (!sdIsString(val.id)) {
throw new BoxSdkError({
message: 'Expecting string for "id" of type "GroupBaseV2025R0Input"',
});
}
const id: string = val.id;
const type: undefined | GroupBaseV2025R0TypeField =
val.type == void 0
? void 0
: deserializeGroupBaseV2025R0TypeField(val.type);
return { id: id, type: type } satisfies GroupBaseV2025R0Input;
}