public IDictionary<string, object> Serialize(JavaScriptSerializer serializer)
{
IDictionary<string, object> serialized = new Dictionary<string, object>();
serialized["customFields"] = CustomFields;
serialized["economics"] = Economics.ToBrightcoveName();
serialized["itemState"] = ItemState.ToBrightcoveName();
serialized["linkURL"] = LinkUrl;
serialized["linkText"] = LinkText;
serialized["longDescription"] = LongDescription;
serialized["name"] = Name;
serialized["referenceId"] = ReferenceId;
serialized["shortDescription"] = ShortDescription;
serialized["tags"] = Tags;
// if the date is MinValue, that means it hasn't been set, so don't include it
if (StartDate > DateTime.MinValue)
{
serialized["startDate"] = StartDate.ToUnixMillisecondsUtc();
}
if (EndDate > DateTime.MinValue)
{
serialized["endDate"] = EndDate.ToUnixMillisecondsUtc();
}
// When creating or updating a video, only one of either VideoFullLength and Renditions may
// be set. If both are set, we get the following error:
// "IllegalValueError - videoFullLength and renditions are mutually exclusive; you must set one or the other. (code 304)"
// To prevent this exception, only submit Renditions if both are set
// Additionally, Renditions may only be updated through the Media API in cases where they use a remote asset.
// Don't submit renditions that lack a RemoteUrl, or the API will return an error.
if (Renditions.Count > 0)
{
serialized["renditions"] = Renditions.Where(r => !String.IsNullOrEmpty(r.RemoteUrl));
}
else if (VideoFullLength != null && !String.IsNullOrEmpty(VideoFullLength.RemoteUrl))
{
serialized["videoFullLength"] = VideoFullLength;
}
if (CuePoints.Count > 0)
{
serialized["cuePoints"] = CuePoints;
}
// The Id must be non-0.
if (Id != 0)
{
serialized["id"] = Id;
}
return serialized;
}