Class: Exa::Resources::Research

Inherits:
Base
  • Object
show all
Defined in:
lib/exa/resources/research.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Exa::Resources::Base

Instance Method Details

#cancel(research_id) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/exa/resources/research.rb', line 41

def cancel(research_id)
  client.request(
    method: :post,
    path: ["research", research_id, "cancel"],
    response_model: Exa::Responses::Research
  )
end

#create(params) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/exa/resources/research.rb', line 8

def create(params)
  payload = serialize(Exa::Types::ResearchCreateRequest, params)
  client.request(
    method: :post,
    path: "research",
    body: payload,
    response_model: Exa::Responses::Research
  )
end

#get(research_id, stream: false, events: nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/exa/resources/research.rb', line 27

def get(research_id, stream: false, events: nil)
  query = {}
  query[:events] = events unless events.nil?
  query[:stream] = stream ? "true" : nil
  response_model = stream ? nil : Exa::Responses::Research
  client.request(
    method: :get,
    path: ["research", research_id],
    query: query.compact,
    stream: stream,
    response_model: response_model
  )
end

#list(params = nil) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/exa/resources/research.rb', line 18

def list(params = nil)
  client.request(
    method: :get,
    path: "research",
    query: params,
    response_model: Exa::Responses::ResearchListResponse
  )
end