lib/cloud_convert/process.rb in cloudconvert-ruby-0.1.1 vs lib/cloud_convert/process.rb in cloudconvert-ruby-0.1.2
- old
+ new
@@ -54,20 +54,22 @@
end
return convert_response response
end
def status
+ raise CloudConvert::InvalidStep if @step == :awaiting_creation
url = process_url(include_process_id: true)
response = send_request(http_method: :get,
url: url) do |response|
create_parsed_response(:status_response, response.parsed_response)
@step = @status_response[:step].to_sym
end
return convert_response response
end
def download(path, file_name="")
+ raise CloudConvert::InvalidStep if @step == :awaiting_creation
response = HTTMultiParty.get(download_url(file_name))
return update_download_progress response unless response.response.code == "200"
file_name = response.response.header['content-disposition'][/filename=(\"?)(.+)\1/, 2] if file_name.strip.empty?
full_path = full_path(path, file_name)
return full_path.open("w") do |f|
@@ -76,16 +78,18 @@
full_path.to_s
end
end
def delete
+ raise CloudConvert::InvalidStep if @step == :awaiting_creation
url = construct_url(process_response[:subdomain], "process", process_response[:id])
response = HTTMultiParty.delete(url)
@step = :deleted if response.response.code == "200"
return convert_response response
end
def download_url(file = "")
+ raise CloudConvert::InvalidStep if @step == :awaiting_creation
file = "/#{file}" unless file.nil? or file.strip.empty?
return "https://#{@process_response[:subdomain]}.cloudconvert.com/download/#{@process_response[:id]}#{file}"
end