forgeplus/app/services/notice/write/delete_service.rb

33 lines
670 B
Ruby
Raw Normal View History

2021-09-13 17:51:34 +08:00
class Notice::Write::DeleteService < Notice::Write::ClientService
2021-09-14 13:59:23 +08:00
attr_accessor :notification_ids, :receiver, :type
2021-09-13 17:51:34 +08:00
2021-09-14 13:59:23 +08:00
def initialize(notification_ids, receiver, type=-1)
2021-09-13 17:51:34 +08:00
@notification_ids = notification_ids
@receiver = receiver
2021-09-14 13:59:23 +08:00
@type = type
2021-09-13 17:51:34 +08:00
end
def call
2021-09-22 14:25:56 +08:00
result = delete(url, request_params)
2021-09-13 17:51:34 +08:00
response = render_response(result)
end
private
def request_notification_ids
notification_ids.join(",")
end
def request_params
Hash.new.merge(data: {
notificationIds: request_notification_ids,
2021-09-14 13:59:23 +08:00
receiver: receiver,
type: type
2021-09-13 17:51:34 +08:00
}.stringify_keys)
end
2021-09-22 14:25:56 +08:00
def url
"/notification/#{platform}".freeze
end
2021-09-13 17:51:34 +08:00
end