File size: 851 Bytes
097eaf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Firecrawl
  module Models
    # Options for mapping (discovering URLs on) a website.
    class MapOptions
      FIELDS = %i[
        search sitemap include_subdomains ignore_query_parameters
        limit timeout integration location
      ].freeze

      attr_reader(*FIELDS)

      def initialize(**kwargs)
        FIELDS.each { |f| instance_variable_set(:"@#{f}", kwargs[f]) }
      end

      def to_h
        {
          "search" => search,
          "sitemap" => sitemap,
          "includeSubdomains" => include_subdomains,
          "ignoreQueryParameters" => ignore_query_parameters,
          "limit" => limit,
          "timeout" => timeout,
          "integration" => integration,
          "location" => location.is_a?(Hash) ? location : location&.to_h,
        }.compact
      end
    end
  end
end