lib/flix_cloud/job.rb in zencoder-flix_cloud-gem-0.1.1 vs lib/flix_cloud/job.rb in zencoder-flix_cloud-gem-0.2.0
- old
+ new
@@ -1,8 +1,8 @@
class FlixCloud::Job < FlixCloud::Record
- attr_accessor :id, :initialized_at, :api_key, :recipe_id, :response
+ attr_accessor :id, :initialized_at, :api_key, :recipe_id, :recipe_name, :response
record_column :file_locations, 'FileLocations'
def initialize(attrs={})
super
@@ -18,12 +18,16 @@
end
else
self.errors << "file_locations is required"
end
- unless recipe_id
- self.errors << "recipe_id is required"
+ if recipe_id || recipe_name
+ if recipe_id && recipe_name
+ self.errors << "recipe_id and recipe_name cannot both be used"
+ end
+ else
+ self.errors << "recipe_id or recipe_name is required"
end
unless api_key
self.errors << "api_key is required"
end
@@ -32,11 +36,11 @@
end
def save
return false unless valid?
- self.response = FlixCloud::Response.new(post('jobs', to_xml))
+ self.response = post('jobs', to_xml)
if response.success?
self.id = response.body_as_hash['job']['id']
self.initialized_at = response.body_as_hash['job']['initialized_job_at']
else
@@ -68,10 +72,15 @@
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
xml.tag!("api-request") do
xml.tag!("api-key", api_key)
- xml.tag!("recipe-id", recipe_id)
+
+ if recipe_name
+ xml.tag!("recipe-name", recipe_name)
+ else
+ xml.tag!("recipe-id", recipe_id)
+ end
if file_locations
xml.tag!("file-locations") do
if file_locations.input
xml.input do