1# frozen_string_literal: true
2
3class UserAgentDetailService
4  def initialize(spammable:, spam_params:)
5    @spammable = spammable
6    @spam_params = spam_params
7  end
8
9  def create
10    unless spam_params&.user_agent && spam_params&.ip_address
11      messasge = 'Skipped UserAgentDetail creation because necessary spam_params were not provided'
12      return ServiceResponse.success(message: messasge)
13    end
14
15    spammable.create_user_agent_detail(user_agent: spam_params.user_agent, ip_address: spam_params.ip_address)
16  end
17
18  private
19
20  attr_reader :spammable, :spam_params
21end
22