Skip to content

Commit

Permalink
feat: support properties of type map
Browse files Browse the repository at this point in the history
  • Loading branch information
eransakal committed Aug 13, 2017
1 parent 243fe1e commit c866ca2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/kaltura-object-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,26 @@ export abstract class KalturaObjectBase{
throw new Error(`Failed to create kaltura object for property '${propertyName}' (type '${property.subType}'). provided response object is missing property 'objectType'.`);
}

break;
case 'm': // map
const parsedMap = {};
if (sourceValue instanceof Object) {
Object.keys(sourceValue).forEach(itemKey =>
{
const itemValue = sourceValue[itemKey];
const newItem = this._createKalturaObject(property.subType);

if (itemValue && newItem) {
newItem.fromResponseObject(itemValue);
parsedMap[itemKey] = newItem;
} else {
throw new Error(`Failed to create kaltura object for type '${property.subType}'`);
}

});
} else {
throw new Error(`failed to parse property '${propertyName}. Expected type object, got type '${typeof sourceValue}`);
}
break;
case 'a': // array
if (sourceValue instanceof Array) {
Expand Down

0 comments on commit c866ca2

Please sign in to comment.