lib/flapjack/gateways/api/contact_methods.rb in flapjack-0.7.27 vs lib/flapjack/gateways/api/contact_methods.rb in flapjack-0.7.28

- old
+ new

@@ -195,13 +195,15 @@ contact = find_contact(params[:contact_id]) media = contact.media media_intervals = contact.media_intervals + media_rollup_thresholds = contact.media_rollup_thresholds media_addr_int = hashify(*media.keys) {|k| - [k, {'address' => media[k], - 'interval' => media_intervals[k] }] + [k, {'address' => media[k], + 'interval' => media_intervals[k], + 'rollup_threshold' => media_rollup_thresholds[k] }] } media_addr_int.to_json end # Returns the specified media of a contact @@ -216,12 +218,14 @@ end interval = contact.media_intervals[params[:id]] if interval.nil? halt err(403, "no #{params[:id]} interval for contact '#{params[:contact_id]}'") end - {'address' => media, - 'interval' => interval}.to_json + rollup_threshold = contact.media_rollup_thresholds[params[:id]] + {'address' => media, + 'interval' => interval, + 'rollup_threshold' => rollup_threshold }.to_json end # Creates or updates a media of a contact # https://github.com/flpjck/flapjack/wiki/API#wiki-put_contacts_id_media_media app.put('/contacts/:contact_id/media/:id') do @@ -235,12 +239,14 @@ halt err(403, *errors) unless errors.empty? contact.set_address_for_media(params[:id], params[:address]) contact.set_interval_for_media(params[:id], params[:interval]) + contact.set_rollup_threshold_for_media(params[:id], params[:rollup_threshold]) - {'address' => contact.media[params[:id]], - 'interval' => contact.media_intervals[params[:id]]}.to_json + {'address' => contact.media[params[:id]], + 'interval' => contact.media_intervals[params[:id]], + 'rollup_threshold' => contact.media_rollup_thresholds[params[:id]]}.to_json end # delete a media of a contact app.delete('/contacts/:contact_id/media/:id') do contact = find_contact(params[:contact_id])