2018-07-05 06:18:17 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-27 20:03:06 -04:00
|
|
|
class UserAgentDetailService
|
2021-06-21 08:07:45 -04:00
|
|
|
def initialize(spammable:, spam_params:)
|
2021-04-19 17:09:27 -04:00
|
|
|
@spammable = spammable
|
2021-06-21 08:07:45 -04:00
|
|
|
@spam_params = spam_params
|
2016-07-27 20:03:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2021-06-21 08:07:45 -04:00
|
|
|
unless spam_params&.user_agent && spam_params&.ip_address
|
|
|
|
messasge = 'Skipped UserAgentDetail creation because necessary spam_params were not provided'
|
|
|
|
return ServiceResponse.success(message: messasge)
|
|
|
|
end
|
2016-08-09 13:43:47 -04:00
|
|
|
|
2021-06-21 08:07:45 -04:00
|
|
|
spammable.create_user_agent_detail(user_agent: spam_params.user_agent, ip_address: spam_params.ip_address)
|
2016-07-27 20:03:06 -04:00
|
|
|
end
|
2021-06-21 08:07:45 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :spammable, :spam_params
|
2016-07-27 20:03:06 -04:00
|
|
|
end
|