gitlink-forgeplus/app/services/notice/write/create_service.rb

37 lines
867 B
Ruby

class Notice::Write::CreateService < Notice::Write::ClientService
attr_accessor :receivers, :sender, :content, :notification_url, :source, :extra, :type
def initialize(receivers, content, notification_url, source, type=1, extra={},sender=-1)
@receivers = receivers
@sender = sender
@content = content
@notification_url = notification_url
@source = source
@extra = extra
@type = type
end
def call
result = post("", request_params)
response = render_response(result)
end
private
def request_receivers
receivers.join(",")
end
def request_params
Hash.new.merge(data: {
receivers: request_receivers,
sender: sender,
content: content,
notification_url: notification_url,
source: source,
extra: extra.to_json.to_s,
type: type
}.stringify_keys)
end
end