Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._metadata = attributes.metadata;
this._fileSize = attributes.file_size;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._hasTrack = !!attributes.track;
this._trackJSON = attributes.track;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
this._duration = null;
this._bitRate = null;
if (attributes.metadata && attributes.metadata.format) {
if (attributes.metadata.format.duration != null) {
this._duration = +attributes.metadata.format.duration;
}
if (attributes.metadata.format.bit_rate != null) {
this._bitRate = +attributes.metadata.format.bit_rate;
}
}
updateFromAPIAttributes(attrs) {
const attributes = attrs || {};
this._id = attributes.id;
this._firstName = attributes.first_name;
this._lastName = attributes.last_name;
this._userID = attributes.user_id;
this._email = attributes.email;
this._roleID = attributes.role_id;
this._createdAt = DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = DateUtils.parseISOTimestamp(attributes.updated_at);
}
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._exif = attributes.exif;
this._fileSize = attributes.file_size;
this._latitude = attributes.latitude;
this._longitude = attributes.longitude;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
if (attributes.exif) {
const {exif} = attributes;
this._altitude = exif.gps_altitude;
this._direction = exif.gps_img_direction;
this._accuracy = exif.gps_dop;
this._width = this.integerValue(exif.pixel_x_dimension);
this._height = this.integerValue(exif.pixel_y_dimension);
this._make = exif.make;
this._model = exif.model;
this._software = exif.software;
this._dateTime = exif.date_time_original || exif.date_time;
async process(object, attributes) {
const isChanged = !object.isPersisted ||
DateUtils.parseISOTimestamp(attributes.updated_at).getTime() !== object.updatedAt.getTime();
object.updateFromAPIAttributes(attributes);
if (object._deletedAt != null) {
object._deletedAt = null;
}
await this.loadObject(object, attributes);
await object.save();
if (isChanged) {
await this.triggerEvent('save', {[this.propertyName]: object});
}
}
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._fileSize = attributes.file_size;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
}
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._metadata = attributes.metadata;
this._fileSize = attributes.file_size;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._hasTrack = !!attributes.track;
this._trackJSON = attributes.track;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
this._duration = null;
this._bitRate = null;
if (attributes.metadata && attributes.metadata.format) {
if (attributes.metadata.format.duration != null) {
this._duration = +attributes.metadata.format.duration;
}
if (attributes.metadata.format.bit_rate != null) {
this._bitRate = +attributes.metadata.format.bit_rate;
}
}
}
async process(object, attributes) {
const isChanged = !object.isPersisted ||
DateUtils.parseISOTimestamp(attributes.updated_at).getTime() !== object.updatedAt.getTime();
object.updateFromAPIAttributes(attributes);
if (object.isDownloaded == null) {
object.isDownloaded = false;
}
await this.lookup(object, attributes.form_id, '_formRowID', 'getForm');
await this.lookup(object, attributes.created_by_id, '_createdByRowID', 'getUser');
await this.lookup(object, attributes.updated_by_id, '_updatedByRowID', 'getUser');
if (object._formRowID) {
const record = await this.account.findFirstRecord({resource_id: attributes.record_id});
if (record) {
object._recordRowID = record.rowID;
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._exif = attributes.exif;
this._fileSize = attributes.file_size;
this._latitude = attributes.latitude;
this._longitude = attributes.longitude;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
if (attributes.exif) {
const {exif} = attributes;
this._altitude = exif.gps_altitude;
this._direction = exif.gps_img_direction;
this._accuracy = exif.gps_dop;
this._width = this.integerValue(exif.pixel_x_dimension);
this._height = this.integerValue(exif.pixel_y_dimension);
this._make = exif.make;
this._model = exif.model;
this._software = exif.software;
this._dateTime = exif.date_time_original || exif.date_time;
}
updateFromAPIAttributes(attrs) {
const attributes = attrs || {};
this._id = attributes.id;
this._firstName = attributes.first_name;
this._lastName = attributes.last_name;
this._userID = attributes.user_id;
this._email = attributes.email;
this._roleID = attributes.role_id;
this._createdAt = DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = DateUtils.parseISOTimestamp(attributes.updated_at);
}