Class: Exa::Services::ResearchList

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

Instance Method Summary collapse

Constructor Details

#initialize(connection, **params) ⇒ ResearchList



4
5
6
7
# File 'lib/exa/services/research_list.rb', line 4

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

Instance Method Details

#callObject



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
34
# File 'lib/exa/services/research_list.rb', line 9

def call
  response = @connection.get("/research/v1", @params)
  body = response.body

  data = body["data"].map do |task_data|
    Resources::ResearchTask.new(
      research_id: task_data["researchId"],
      created_at: task_data["createdAt"],
      status: task_data["status"],
      instructions: task_data["instructions"],
      model: task_data["model"],
      output_schema: task_data["outputSchema"],
      events: task_data["events"],
      output: task_data["output"],
      cost_dollars: task_data["costDollars"],
      finished_at: task_data["finishedAt"],
      error: task_data["error"]
    )
  end

  Resources::ResearchList.new(
    data: data,
    has_more: body["hasMore"],
    next_cursor: body["nextCursor"]
  )
end