box-node-sdk
Version:
Official SDK for Box Platform APIs
164 lines • 5.83 kB
JavaScript
import { serializeHubDocumentBlockEntryV2025R0 } from './hubDocumentBlockEntryV2025R0.js';
import { deserializeHubDocumentBlockEntryV2025R0 } from './hubDocumentBlockEntryV2025R0.js';
import { BoxSdkError } from '../../box/errors.js';
import { sdIsNumber } from '../../serialization/json.js';
import { sdIsString } from '../../serialization/json.js';
import { sdIsList } from '../../serialization/json.js';
import { sdIsMap } from '../../serialization/json.js';
export class HubDocumentBlocksV2025R0 {
/**
* Ordered list of blocks. */
entries;
/**
* The value will always be `document_blocks`. */
type = 'document_blocks';
/**
* 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. */
limit;
/**
* The marker for the start of the next page of results. */
nextMarker;
rawData;
constructor(fields) {
if (fields.entries !== undefined) {
this.entries = fields.entries;
}
if (fields.type !== undefined) {
this.type = fields.type;
}
if (fields.limit !== undefined) {
this.limit = fields.limit;
}
if (fields.nextMarker !== undefined) {
this.nextMarker = fields.nextMarker;
}
if (fields.rawData !== undefined) {
this.rawData = fields.rawData;
}
}
}
export function serializeHubDocumentBlocksV2025R0TypeField(val) {
return val;
}
export function deserializeHubDocumentBlocksV2025R0TypeField(val) {
if (val == 'document_blocks') {
return val;
}
throw new BoxSdkError({
message: "Can't deserialize HubDocumentBlocksV2025R0TypeField",
});
}
export function serializeHubDocumentBlocksV2025R0(val) {
return {
['entries']: val.entries.map(function (item) {
return serializeHubDocumentBlockEntryV2025R0(item);
}),
['type']: serializeHubDocumentBlocksV2025R0TypeField(val.type),
['limit']: val.limit,
['next_marker']: val.nextMarker,
};
}
export function deserializeHubDocumentBlocksV2025R0(val) {
if (!sdIsMap(val)) {
throw new BoxSdkError({
message: 'Expecting a map for "HubDocumentBlocksV2025R0"',
});
}
if (val.entries == void 0) {
throw new BoxSdkError({
message: 'Expecting "entries" of type "HubDocumentBlocksV2025R0" to be defined',
});
}
if (!sdIsList(val.entries)) {
throw new BoxSdkError({
message: 'Expecting array for "entries" of type "HubDocumentBlocksV2025R0"',
});
}
const entries = sdIsList(val.entries)
? val.entries.map(function (itm) {
return deserializeHubDocumentBlockEntryV2025R0(itm);
})
: [];
if (val.type == void 0) {
throw new BoxSdkError({
message: 'Expecting "type" of type "HubDocumentBlocksV2025R0" to be defined',
});
}
const type = deserializeHubDocumentBlocksV2025R0TypeField(val.type);
if (!(val.limit == void 0) && !sdIsNumber(val.limit)) {
throw new BoxSdkError({
message: 'Expecting number for "limit" of type "HubDocumentBlocksV2025R0"',
});
}
const limit = 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 "HubDocumentBlocksV2025R0"',
});
}
const nextMarker = val.next_marker == void 0 ? void 0 : val.next_marker;
return {
entries: entries,
type: type,
limit: limit,
nextMarker: nextMarker,
};
}
export function serializeHubDocumentBlocksV2025R0Input(val) {
return {
['entries']: val.entries.map(function (item) {
return serializeHubDocumentBlockEntryV2025R0(item);
}),
['type']: val.type == void 0
? val.type
: serializeHubDocumentBlocksV2025R0TypeField(val.type),
['limit']: val.limit,
['next_marker']: val.nextMarker,
};
}
export function deserializeHubDocumentBlocksV2025R0Input(val) {
if (!sdIsMap(val)) {
throw new BoxSdkError({
message: 'Expecting a map for "HubDocumentBlocksV2025R0Input"',
});
}
if (val.entries == void 0) {
throw new BoxSdkError({
message: 'Expecting "entries" of type "HubDocumentBlocksV2025R0Input" to be defined',
});
}
if (!sdIsList(val.entries)) {
throw new BoxSdkError({
message: 'Expecting array for "entries" of type "HubDocumentBlocksV2025R0Input"',
});
}
const entries = sdIsList(val.entries)
? val.entries.map(function (itm) {
return deserializeHubDocumentBlockEntryV2025R0(itm);
})
: [];
const type = val.type == void 0
? void 0
: deserializeHubDocumentBlocksV2025R0TypeField(val.type);
if (!(val.limit == void 0) && !sdIsNumber(val.limit)) {
throw new BoxSdkError({
message: 'Expecting number for "limit" of type "HubDocumentBlocksV2025R0Input"',
});
}
const limit = 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 "HubDocumentBlocksV2025R0Input"',
});
}
const nextMarker = val.next_marker == void 0 ? void 0 : val.next_marker;
return {
entries: entries,
type: type,
limit: limit,
nextMarker: nextMarker,
};
}
//# sourceMappingURL=hubDocumentBlocksV2025R0.js.map