box-node-sdk
Version:
Official SDK for Box Platform APIs
76 lines (75 loc) • 2.82 kB
text/typescript
import { serializeHubItemV2025R0 } from './hubItemV2025R0';
import { deserializeHubItemV2025R0 } from './hubItemV2025R0';
import { HubItemV2025R0 } from './hubItemV2025R0';
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 interface HubItemsV2025R0 {
/**
* A list of Box Hub items. */
readonly entries?: readonly HubItemV2025R0[];
/**
* The limit that was used for these entries. This will be the same as the
* `limit` query parameter unless that value exceeded the maximum value
* allowed. The maximum value varies by API. */
readonly limit?: number;
/**
* The marker for the start of the next page of results. */
readonly nextMarker?: string | null;
readonly rawData?: SerializedData;
}
export function serializeHubItemsV2025R0(val: HubItemsV2025R0): SerializedData {
return {
['entries']:
val.entries == void 0
? val.entries
: (val.entries.map(function (item: HubItemV2025R0): SerializedData {
return serializeHubItemV2025R0(item);
}) as readonly any[]),
['limit']: val.limit,
['next_marker']: val.nextMarker,
};
}
export function deserializeHubItemsV2025R0(
val: SerializedData,
): HubItemsV2025R0 {
if (!sdIsMap(val)) {
throw new BoxSdkError({ message: 'Expecting a map for "HubItemsV2025R0"' });
}
if (!(val.entries == void 0) && !sdIsList(val.entries)) {
throw new BoxSdkError({
message: 'Expecting array for "entries" of type "HubItemsV2025R0"',
});
}
const entries: undefined | readonly HubItemV2025R0[] =
val.entries == void 0
? void 0
: sdIsList(val.entries)
? (val.entries.map(function (itm: SerializedData): HubItemV2025R0 {
return deserializeHubItemV2025R0(itm);
}) as readonly any[])
: [];
if (!(val.limit == void 0) && !sdIsNumber(val.limit)) {
throw new BoxSdkError({
message: 'Expecting number for "limit" of type "HubItemsV2025R0"',
});
}
const limit: undefined | number = val.limit == void 0 ? void 0 : val.limit;
if (!(val.next_marker == void 0) && !sdIsString(val.next_marker)) {
throw new BoxSdkError({
message: 'Expecting string for "next_marker" of type "HubItemsV2025R0"',
});
}
const nextMarker: undefined | string =
val.next_marker == void 0 ? void 0 : val.next_marker;
return {
entries: entries,
limit: limit,
nextMarker: nextMarker,
} satisfies HubItemsV2025R0;
}