UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

124 lines 4.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FileBase = void 0; exports.serializeFileBaseTypeField = serializeFileBaseTypeField; exports.deserializeFileBaseTypeField = deserializeFileBaseTypeField; exports.serializeFileBase = serializeFileBase; exports.deserializeFileBase = deserializeFileBase; exports.serializeFileBaseInput = serializeFileBaseInput; exports.deserializeFileBaseInput = deserializeFileBaseInput; const errors_1 = require("../box/errors"); const json_1 = require("../serialization/json"); const json_2 = require("../serialization/json"); class FileBase { /** * The unique identifier that represent a file. * * The ID for any file can be determined * by visiting a file in the web application * and copying the ID from the URL. For example, * for the URL `https://*.app.box.com/files/123` * the `file_id` is `123`. */ id; /** * The HTTP `etag` of this file. This can be used within some API * endpoints in the `If-Match` and `If-None-Match` headers to only * perform changes on the file if (no) changes have happened. */ etag; /** * The value will always be `file`. */ type = 'file'; rawData; constructor(fields) { if (fields.id !== undefined) { this.id = fields.id; } if (fields.etag !== undefined) { this.etag = fields.etag; } if (fields.type !== undefined) { this.type = fields.type; } if (fields.rawData !== undefined) { this.rawData = fields.rawData; } } } exports.FileBase = FileBase; function serializeFileBaseTypeField(val) { return val; } function deserializeFileBaseTypeField(val) { if (val == 'file') { return val; } throw new errors_1.BoxSdkError({ message: "Can't deserialize FileBaseTypeField" }); } function serializeFileBase(val) { return { ['id']: val.id, ['etag']: val.etag, ['type']: serializeFileBaseTypeField(val.type), }; } function deserializeFileBase(val) { if (!(0, json_2.sdIsMap)(val)) { throw new errors_1.BoxSdkError({ message: 'Expecting a map for "FileBase"' }); } if (val.id == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "id" of type "FileBase" to be defined', }); } if (!(0, json_1.sdIsString)(val.id)) { throw new errors_1.BoxSdkError({ message: 'Expecting string for "id" of type "FileBase"', }); } const id = val.id; if (!(val.etag == void 0) && !(0, json_1.sdIsString)(val.etag)) { throw new errors_1.BoxSdkError({ message: 'Expecting string for "etag" of type "FileBase"', }); } const etag = val.etag == void 0 ? void 0 : val.etag; if (val.type == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "type" of type "FileBase" to be defined', }); } const type = deserializeFileBaseTypeField(val.type); return { id: id, etag: etag, type: type }; } function serializeFileBaseInput(val) { return { ['id']: val.id, ['etag']: val.etag, ['type']: val.type == void 0 ? val.type : serializeFileBaseTypeField(val.type), }; } function deserializeFileBaseInput(val) { if (!(0, json_2.sdIsMap)(val)) { throw new errors_1.BoxSdkError({ message: 'Expecting a map for "FileBaseInput"' }); } if (val.id == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "id" of type "FileBaseInput" to be defined', }); } if (!(0, json_1.sdIsString)(val.id)) { throw new errors_1.BoxSdkError({ message: 'Expecting string for "id" of type "FileBaseInput"', }); } const id = val.id; if (!(val.etag == void 0) && !(0, json_1.sdIsString)(val.etag)) { throw new errors_1.BoxSdkError({ message: 'Expecting string for "etag" of type "FileBaseInput"', }); } const etag = val.etag == void 0 ? void 0 : val.etag; const type = val.type == void 0 ? void 0 : deserializeFileBaseTypeField(val.type); return { id: id, etag: etag, type: type }; } //# sourceMappingURL=fileBase.js.map