Class: Exa::Services::Websets::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/exa/services/websets/create.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, **params) ⇒ Create

Returns a new instance of Create.



10
11
12
13
# File 'lib/exa/services/websets/create.rb', line 10

def initialize(connection, **params)
  @connection = connection
  @params = params
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/exa/services/websets/create.rb', line 15

def call
  # Validate parameters before making the API call
  CreateValidator.validate!(@params)

  # Convert Ruby snake_case params to API camelCase
  converted_params = WebsetsParameterConverter.convert(@params)

  response = @connection.post("/websets/v0/websets", converted_params)
  body = response.body

  Resources::Webset.new(
    id: body["id"],
    object: body["object"],
    status: body["status"],
    external_id: body["externalId"],
    title: body["title"],
    searches: body["searches"],
    imports: body["imports"],
    enrichments: body["enrichments"],
    monitors: body["monitors"],
    excludes: body["excludes"],
    metadata: body["metadata"],
    created_at: body["createdAt"],
    updated_at: body["updatedAt"],
    items: body["items"]
  )
end