lib/pushpad/notification.rb in pushpad-1.0.0 vs lib/pushpad/notification.rb in pushpad-1.1.0
- old
+ new
@@ -6,10 +6,13 @@
class DeliveryError < RuntimeError
end
class FindError < RuntimeError
end
+
+ class CancelError < RuntimeError
+ end
class ReadonlyError < RuntimeError
end
attr_accessor :body, :title, :target_url, :icon_url, :badge_url, :image_url, :ttl, :require_interaction, :silent, :urgent, :custom_data, :custom_metrics, :actions, :starred, :send_at
@@ -84,9 +87,17 @@
users.collect {|u| u.respond_to?(:id) ? u.id : u }
else
[users.respond_to?(:id) ? users.id : users]
end
deliver req_body(uids, options[:tags]), options
+ end
+
+ def cancel
+ response = Request.delete("https://pushpad.xyz/api/v1/notifications/#{id}/cancel")
+
+ unless response.code == "204"
+ raise CancelError, "Response #{response.code} #{response.message}: #{response.body}"
+ end
end
private
def deliver(req_body, options = {})