# typed: strict
class Domain::Inkbunny::Job::Base < Scraper::JobBase
  extend T::Sig

  discard_on ActiveJob::DeserializationError
  queue_as :inkbunny

  sig { override.returns(Symbol) }
  def self.http_factory_method
    :get_inkbunny_http_client
  end

  sig { returns(T.nilable(Domain::User::InkbunnyUser)) }
  def user_from_args
    T.cast(arguments[0][:user], T.nilable(Domain::User::InkbunnyUser))
  end

  sig { returns(T.nilable(Domain::UserAvatar)) }
  def avatar_from_args
    T.cast(arguments[0][:avatar], T.nilable(Domain::UserAvatar))
  end

  sig { returns(Domain::User::InkbunnyUser) }
  def user_from_args!
    user_from_args || raise("user must exist")
  end

  sig { returns(Domain::Post::InkbunnyPost) }
  def post_from_args!
    T.cast(arguments[0][:post], Domain::Post::InkbunnyPost)
  end
end
