lib/contactology/campaign.rb in contactology-0.1.1 vs lib/contactology/campaign.rb in contactology-0.1.2
- old
+ new
@@ -73,11 +73,14 @@
query('Campaign_Find', options.merge({
'searchParameters' => {
'campaignName' => name
},
:on_success => Proc.new { |r|
- new_campaign_from_response(r.values.first) unless r.nil?
+ unless r.nil?
+ data = r.values.max { |a,b| a['startTime'] <=> b['startTime'] }
+ new_campaign_from_response(data)
+ end
}
}))
end
@@ -111,9 +114,15 @@
# Returns the campaign instance when successful.
# Raises InvalidObjectError when unsuccessful.
#
def save!(options = {})
save(options) || raise(InvalidObjectError)
+ end
+
+ def start_time
+ if self['start_time']
+ Time.strptime(self['start_time'] + 'Z', '%Y-%m-%d %H:%M:%S%Z')
+ end
end
def preview(options = {})
self.class.query('Campaign_Preview', options.merge({
'campaignId' => id,