public override void validate() { if (Resource != null) { foreach (ResourceEvent e in Events) { if (!supportedEvents[(ResourceType)Resource].Contains(e)) { var unsupportedEvent = ClientUtils.EnumMemberAttr <ResourceEvent>((ResourceEvent)e); var resourceType = ClientUtils.EnumMemberAttr <ResourceType>((ResourceType)Resource); var error = "Event [" + unsupportedEvent + "] is unsupported for " + resourceType + " resource, supported events are: " + supportedEvents[(ResourceType)Resource].ToPrettyString(); throw new ModelValidationException(new ErrorMessage { Message = error }); } } } }
/// <summary> /// Upload media file to account /// </summary> /// <param name="fileData">binary file data to upload</param> /// <param name="type">media type for file uploaded</param> /// <param name="name">name for file uploaded</param> /// <returns>ResourceId object with sound id</returns> /// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception> /// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception> /// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception> /// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception> /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception> /// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception> /// <exception cref="CallfireClientException"> in case error has occurred in client.</exception> public ResourceId Upload(byte[] fileData, MediaType type, string name = null) { return(Client.PostFile <ResourceId>(MEDIA_PATH, fileData, name, ClientUtils.EnumMemberAttr <MediaType>(type))); }
/// <summary> /// Upload media file to account /// </summary> /// <param name="file">file to upload</param> /// <param name="name">name for file uploaded</param> /// <returns>ResourceId object with sound id</returns> /// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception> /// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception> /// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception> /// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception> /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception> /// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception> /// <exception cref="CallfireClientException"> in case error has occurred in client.</exception> public ResourceId Upload(string pathToFile, string name = null) { MediaType type = ClientUtils.EnumFromDescription <MediaType>((Path.GetExtension(pathToFile).Replace(".", ""))); return(Client.PostFile <ResourceId>(MEDIA_PATH, name, pathToFile, ClientUtils.EnumMemberAttr <MediaType>(type))); }