box-typescript-sdk-gen
Version:
Official Box TypeScript Generated SDK
121 lines • 4.09 kB
JavaScript
import { serializeCommentFull } from './commentFull.generated.js';
import { deserializeCommentFull } from './commentFull.generated.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 function serializeCommentsOrderDirectionField(val) {
return val;
}
export function deserializeCommentsOrderDirectionField(val) {
if (val == 'ASC') {
return val;
}
if (val == 'DESC') {
return val;
}
if (sdIsString(val)) {
return val;
}
throw new BoxSdkError({
message: "Can't deserialize CommentsOrderDirectionField",
});
}
export function serializeCommentsOrderField(val) {
return {
['by']: val.by,
['direction']: val.direction == void 0
? val.direction
: serializeCommentsOrderDirectionField(val.direction),
};
}
export function deserializeCommentsOrderField(val) {
if (!sdIsMap(val)) {
throw new BoxSdkError({
message: 'Expecting a map for "CommentsOrderField"',
});
}
if (!(val.by == void 0) && !sdIsString(val.by)) {
throw new BoxSdkError({
message: 'Expecting string for "by" of type "CommentsOrderField"',
});
}
const by = val.by == void 0 ? void 0 : val.by;
const direction = val.direction == void 0
? void 0
: deserializeCommentsOrderDirectionField(val.direction);
return { by: by, direction: direction };
}
export function serializeComments(val) {
return {
['total_count']: val.totalCount,
['limit']: val.limit,
['offset']: val.offset,
['order']: val.order == void 0
? val.order
: val.order.map(function (item) {
return serializeCommentsOrderField(item);
}),
['entries']: val.entries == void 0
? val.entries
: val.entries.map(function (item) {
return serializeCommentFull(item);
}),
};
}
export function deserializeComments(val) {
if (!sdIsMap(val)) {
throw new BoxSdkError({ message: 'Expecting a map for "Comments"' });
}
if (!(val.total_count == void 0) && !sdIsNumber(val.total_count)) {
throw new BoxSdkError({
message: 'Expecting number for "total_count" of type "Comments"',
});
}
const totalCount = val.total_count == void 0 ? void 0 : val.total_count;
if (!(val.limit == void 0) && !sdIsNumber(val.limit)) {
throw new BoxSdkError({
message: 'Expecting number for "limit" of type "Comments"',
});
}
const limit = val.limit == void 0 ? void 0 : val.limit;
if (!(val.offset == void 0) && !sdIsNumber(val.offset)) {
throw new BoxSdkError({
message: 'Expecting number for "offset" of type "Comments"',
});
}
const offset = val.offset == void 0 ? void 0 : val.offset;
if (!(val.order == void 0) && !sdIsList(val.order)) {
throw new BoxSdkError({
message: 'Expecting array for "order" of type "Comments"',
});
}
const order = val.order == void 0
? void 0
: sdIsList(val.order)
? val.order.map(function (itm) {
return deserializeCommentsOrderField(itm);
})
: [];
if (!(val.entries == void 0) && !sdIsList(val.entries)) {
throw new BoxSdkError({
message: 'Expecting array for "entries" of type "Comments"',
});
}
const entries = val.entries == void 0
? void 0
: sdIsList(val.entries)
? val.entries.map(function (itm) {
return deserializeCommentFull(itm);
})
: [];
return {
totalCount: totalCount,
limit: limit,
offset: offset,
order: order,
entries: entries,
};
}
//# sourceMappingURL=comments.generated.js.map