exa-ai 0.12.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +120 -83
- data/exe/exa-ai +45 -152
- data/exe/exa-ai-agent-run-create +55 -20
- data/exe/exa-ai-agent-run-delete +1 -8
- data/exe/exa-ai-agent-run-events +21 -1
- data/exe/exa-ai-agent-run-list +1 -1
- data/exe/{exa-ai-research-list → exa-ai-agent-run-stop} +31 -32
- data/exe/exa-ai-answer +25 -0
- data/exe/exa-ai-context +6 -2
- data/exe/exa-ai-find-similar +26 -68
- data/exe/exa-ai-get-contents +138 -42
- data/exe/exa-ai-search +27 -104
- data/exe/exa-ai-search-monitor-batch +93 -0
- data/exe/exa-ai-search-monitor-create +104 -0
- data/exe/exa-ai-search-monitor-delete +69 -0
- data/exe/exa-ai-search-monitor-get +69 -0
- data/exe/exa-ai-search-monitor-list +73 -0
- data/exe/exa-ai-search-monitor-runs-get +68 -0
- data/exe/exa-ai-search-monitor-runs-list +75 -0
- data/exe/exa-ai-search-monitor-trigger +69 -0
- data/exe/exa-ai-search-monitor-update +102 -0
- data/lib/exa/cli/base.rb +57 -0
- data/lib/exa/cli/contents_flags.rb +199 -0
- data/lib/exa/cli/formatters/agent_run_formatter.rb +79 -3
- data/lib/exa/cli/formatters/search_formatter.rb +18 -2
- data/lib/exa/cli/formatters/search_monitor_formatter.rb +98 -0
- data/lib/exa/cli/search_parser.rb +46 -87
- data/lib/exa/client.rb +183 -333
- data/lib/exa/middleware/raise_error.rb +14 -0
- data/lib/exa/resources/agent_run.rb +5 -3
- data/lib/exa/resources/agent_run_deletion.rb +17 -0
- data/lib/exa/resources/answer.rb +3 -3
- data/lib/exa/resources/contents_result.rb +5 -1
- data/lib/exa/resources/find_similar_result.rb +5 -1
- data/lib/exa/resources/search_monitor.rb +42 -0
- data/lib/exa/resources/search_monitor_batch_result.rb +11 -0
- data/lib/exa/resources/{research_list.rb → search_monitor_list.rb} +3 -2
- data/lib/exa/resources/search_monitor_run.rb +46 -0
- data/lib/exa/resources/search_monitor_trigger_result.rb +11 -0
- data/lib/exa/resources/search_result.rb +11 -1
- data/lib/exa/services/agent_run_cancel.rb +1 -12
- data/lib/exa/services/agent_run_create.rb +1 -12
- data/lib/exa/services/agent_run_delete.rb +6 -14
- data/lib/exa/services/agent_run_events.rb +33 -4
- data/lib/exa/services/agent_run_get.rb +1 -12
- data/lib/exa/services/agent_run_list.rb +1 -12
- data/lib/exa/services/agent_run_stop.rb +21 -0
- data/lib/exa/services/agent_run_stream.rb +56 -52
- data/lib/exa/services/answer.rb +5 -2
- data/lib/exa/services/answer_stream.rb +57 -46
- data/lib/exa/services/context.rb +3 -1
- data/lib/exa/services/find_similar.rb +9 -2
- data/lib/exa/services/get_contents.rb +14 -15
- data/lib/exa/services/parameter_converter.rb +128 -111
- data/lib/exa/services/search.rb +58 -19
- data/lib/exa/services/search_monitors/batch.rb +36 -0
- data/lib/exa/services/search_monitors/create.rb +37 -0
- data/lib/exa/services/search_monitors/delete.rb +22 -0
- data/lib/exa/services/search_monitors/get.rb +22 -0
- data/lib/exa/services/search_monitors/list.rb +29 -0
- data/lib/exa/services/search_monitors/runs_get.rb +23 -0
- data/lib/exa/services/search_monitors/runs_list.rb +29 -0
- data/lib/exa/services/search_monitors/trigger.rb +22 -0
- data/lib/exa/services/search_monitors/update.rb +42 -0
- data/lib/exa/services/search_stream.rb +38 -0
- data/lib/exa/version.rb +1 -1
- data/lib/exa.rb +18 -56
- metadata +31 -94
- data/exe/exa-ai-enrichment-cancel +0 -108
- data/exe/exa-ai-enrichment-create +0 -226
- data/exe/exa-ai-enrichment-delete +0 -122
- data/exe/exa-ai-enrichment-get +0 -104
- data/exe/exa-ai-enrichment-list +0 -99
- data/exe/exa-ai-enrichment-update +0 -171
- data/exe/exa-ai-import-create +0 -253
- data/exe/exa-ai-import-delete +0 -92
- data/exe/exa-ai-import-get +0 -92
- data/exe/exa-ai-import-list +0 -72
- data/exe/exa-ai-import-update +0 -164
- data/exe/exa-ai-monitor-create +0 -223
- data/exe/exa-ai-monitor-delete +0 -101
- data/exe/exa-ai-monitor-get +0 -92
- data/exe/exa-ai-monitor-list +0 -90
- data/exe/exa-ai-monitor-runs-get +0 -103
- data/exe/exa-ai-monitor-runs-list +0 -110
- data/exe/exa-ai-monitor-update +0 -207
- data/exe/exa-ai-research-get +0 -109
- data/exe/exa-ai-research-start +0 -174
- data/exe/exa-ai-webset-cancel +0 -97
- data/exe/exa-ai-webset-create +0 -254
- data/exe/exa-ai-webset-delete +0 -111
- data/exe/exa-ai-webset-get +0 -93
- data/exe/exa-ai-webset-item-delete +0 -111
- data/exe/exa-ai-webset-item-get +0 -105
- data/exe/exa-ai-webset-item-list +0 -108
- data/exe/exa-ai-webset-list +0 -91
- data/exe/exa-ai-webset-search-cancel +0 -104
- data/exe/exa-ai-webset-search-create +0 -247
- data/exe/exa-ai-webset-search-get +0 -105
- data/exe/exa-ai-webset-update +0 -143
- data/lib/exa/cli/formatters/enrichment_formatter.rb +0 -125
- data/lib/exa/cli/formatters/import_formatter.rb +0 -153
- data/lib/exa/cli/formatters/monitor_formatter.rb +0 -144
- data/lib/exa/cli/formatters/monitor_run_formatter.rb +0 -126
- data/lib/exa/cli/formatters/research_formatter.rb +0 -124
- data/lib/exa/cli/formatters/webset_formatter.rb +0 -134
- data/lib/exa/cli/formatters/webset_item_formatter.rb +0 -131
- data/lib/exa/cli/formatters/webset_search_formatter.rb +0 -57
- data/lib/exa/constants/websets.rb +0 -19
- data/lib/exa/resources/import.rb +0 -86
- data/lib/exa/resources/import_collection.rb +0 -33
- data/lib/exa/resources/monitor.rb +0 -48
- data/lib/exa/resources/monitor_collection.rb +0 -30
- data/lib/exa/resources/monitor_run.rb +0 -52
- data/lib/exa/resources/monitor_run_collection.rb +0 -30
- data/lib/exa/resources/research_task.rb +0 -39
- data/lib/exa/resources/webset.rb +0 -74
- data/lib/exa/resources/webset_collection.rb +0 -33
- data/lib/exa/resources/webset_enrichment.rb +0 -71
- data/lib/exa/resources/webset_enrichment_collection.rb +0 -28
- data/lib/exa/resources/webset_item_collection.rb +0 -33
- data/lib/exa/resources/webset_search.rb +0 -112
- data/lib/exa/services/research_get.rb +0 -30
- data/lib/exa/services/research_list.rb +0 -37
- data/lib/exa/services/research_start.rb +0 -26
- data/lib/exa/services/websets/cancel.rb +0 -36
- data/lib/exa/services/websets/cancel_enrichment.rb +0 -35
- data/lib/exa/services/websets/cancel_search.rb +0 -44
- data/lib/exa/services/websets/create.rb +0 -45
- data/lib/exa/services/websets/create_enrichment.rb +0 -35
- data/lib/exa/services/websets/create_search.rb +0 -48
- data/lib/exa/services/websets/create_search_validator.rb +0 -128
- data/lib/exa/services/websets/create_validator.rb +0 -213
- data/lib/exa/services/websets/delete.rb +0 -36
- data/lib/exa/services/websets/delete_enrichment.rb +0 -35
- data/lib/exa/services/websets/delete_item.rb +0 -20
- data/lib/exa/services/websets/get_item.rb +0 -20
- data/lib/exa/services/websets/get_search.rb +0 -43
- data/lib/exa/services/websets/import_create.rb +0 -40
- data/lib/exa/services/websets/import_delete.rb +0 -37
- data/lib/exa/services/websets/import_get.rb +0 -37
- data/lib/exa/services/websets/import_list.rb +0 -25
- data/lib/exa/services/websets/import_update.rb +0 -38
- data/lib/exa/services/websets/import_upload.rb +0 -58
- data/lib/exa/services/websets/list.rb +0 -25
- data/lib/exa/services/websets/list_items.rb +0 -26
- data/lib/exa/services/websets/monitors/create.rb +0 -42
- data/lib/exa/services/websets/monitors/delete.rb +0 -32
- data/lib/exa/services/websets/monitors/get.rb +0 -33
- data/lib/exa/services/websets/monitors/list.rb +0 -27
- data/lib/exa/services/websets/monitors/runs/get.rb +0 -37
- data/lib/exa/services/websets/monitors/runs/list.rb +0 -30
- data/lib/exa/services/websets/monitors/update.rb +0 -33
- data/lib/exa/services/websets/retrieve.rb +0 -47
- data/lib/exa/services/websets/retrieve_enrichment.rb +0 -35
- data/lib/exa/services/websets/update.rb +0 -37
- data/lib/exa/services/websets/update_enrichment.rb +0 -36
- data/lib/exa/services/websets_parameter_converter.rb +0 -45
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "faraday"
|
|
4
|
-
|
|
5
|
-
module Exa
|
|
6
|
-
module Services
|
|
7
|
-
module Websets
|
|
8
|
-
class UploadImport
|
|
9
|
-
def initialize(connection, file_path:, **params)
|
|
10
|
-
@connection = connection
|
|
11
|
-
@file_path = file_path
|
|
12
|
-
@params = params
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def call
|
|
16
|
-
validate_file!
|
|
17
|
-
|
|
18
|
-
# Infer file size
|
|
19
|
-
file_size = File.size(@file_path)
|
|
20
|
-
|
|
21
|
-
# Create import with inferred size
|
|
22
|
-
import = CreateImport.new(@connection, size: file_size, **@params).call
|
|
23
|
-
|
|
24
|
-
# Upload file to the upload URL
|
|
25
|
-
upload_file(import.upload_url)
|
|
26
|
-
|
|
27
|
-
# Return the import resource
|
|
28
|
-
import
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
def validate_file!
|
|
34
|
-
unless File.exist?(@file_path)
|
|
35
|
-
raise Error, "File not found: #{@file_path}"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
unless File.readable?(@file_path)
|
|
39
|
-
raise Error, "Permission denied: file is not readable: #{@file_path}"
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def upload_file(upload_url)
|
|
44
|
-
file_content = File.read(@file_path)
|
|
45
|
-
|
|
46
|
-
upload_connection = Faraday.new do |f|
|
|
47
|
-
f.adapter Faraday.default_adapter
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
upload_connection.put(upload_url) do |req|
|
|
51
|
-
req.headers["Content-Type"] = "text/csv"
|
|
52
|
-
req.body = file_content
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class List
|
|
7
|
-
def initialize(connection, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@params = params
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def call
|
|
13
|
-
response = @connection.get("/websets/v0/websets", @params)
|
|
14
|
-
body = response.body
|
|
15
|
-
|
|
16
|
-
Resources::WebsetCollection.new(
|
|
17
|
-
data: body["data"],
|
|
18
|
-
has_more: body["hasMore"],
|
|
19
|
-
next_cursor: body["nextCursor"]
|
|
20
|
-
)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class ListItems
|
|
7
|
-
def initialize(connection, webset_id:, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@webset_id = webset_id
|
|
10
|
-
@params = params
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.get("/websets/v0/websets/#{@webset_id}/items", @params)
|
|
15
|
-
body = response.body
|
|
16
|
-
|
|
17
|
-
Resources::WebsetItemCollection.new(
|
|
18
|
-
data: body["data"] || [],
|
|
19
|
-
has_more: body["hasMore"] || false,
|
|
20
|
-
next_cursor: body["nextCursor"]
|
|
21
|
-
)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
module Monitors
|
|
7
|
-
class Create
|
|
8
|
-
def initialize(connection, webset_id:, cadence:, behavior:, **params)
|
|
9
|
-
@connection = connection
|
|
10
|
-
@webset_id = webset_id
|
|
11
|
-
@cadence = cadence
|
|
12
|
-
@behavior = behavior
|
|
13
|
-
@params = params
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def call
|
|
17
|
-
response = @connection.post(
|
|
18
|
-
"/websets/v0/monitors",
|
|
19
|
-
{
|
|
20
|
-
websetId: @webset_id,
|
|
21
|
-
cadence: @cadence,
|
|
22
|
-
behavior: @behavior
|
|
23
|
-
}.merge(@params)
|
|
24
|
-
)
|
|
25
|
-
body = response.body
|
|
26
|
-
|
|
27
|
-
Resources::Monitor.new(
|
|
28
|
-
id: body["id"],
|
|
29
|
-
object: body["object"],
|
|
30
|
-
status: body["status"],
|
|
31
|
-
webset_id: body["websetId"],
|
|
32
|
-
cadence: body["cadence"],
|
|
33
|
-
behavior: body["behavior"],
|
|
34
|
-
created_at: body["createdAt"],
|
|
35
|
-
updated_at: body["updatedAt"]
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
module Monitors
|
|
7
|
-
class Delete
|
|
8
|
-
def initialize(connection, id:)
|
|
9
|
-
@connection = connection
|
|
10
|
-
@id = id
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.delete("/websets/v0/monitors/#{@id}")
|
|
15
|
-
body = response.body
|
|
16
|
-
|
|
17
|
-
Resources::Monitor.new(
|
|
18
|
-
id: body["id"],
|
|
19
|
-
object: body["object"],
|
|
20
|
-
status: body["status"],
|
|
21
|
-
webset_id: body["websetId"],
|
|
22
|
-
cadence: body["cadence"],
|
|
23
|
-
behavior: body["behavior"],
|
|
24
|
-
created_at: body["createdAt"],
|
|
25
|
-
updated_at: body["updatedAt"]
|
|
26
|
-
)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
module Monitors
|
|
7
|
-
class Get
|
|
8
|
-
def initialize(connection, id:, **params)
|
|
9
|
-
@connection = connection
|
|
10
|
-
@id = id
|
|
11
|
-
@params = params
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def call
|
|
15
|
-
response = @connection.get("/websets/v0/monitors/#{@id}", @params)
|
|
16
|
-
body = response.body
|
|
17
|
-
|
|
18
|
-
Resources::Monitor.new(
|
|
19
|
-
id: body["id"],
|
|
20
|
-
object: body["object"],
|
|
21
|
-
status: body["status"],
|
|
22
|
-
webset_id: body["websetId"],
|
|
23
|
-
cadence: body["cadence"],
|
|
24
|
-
behavior: body["behavior"],
|
|
25
|
-
created_at: body["createdAt"],
|
|
26
|
-
updated_at: body["updatedAt"]
|
|
27
|
-
)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
module Monitors
|
|
7
|
-
class List
|
|
8
|
-
def initialize(connection, **params)
|
|
9
|
-
@connection = connection
|
|
10
|
-
@params = params
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.get("/websets/v0/monitors", @params)
|
|
15
|
-
body = response.body
|
|
16
|
-
|
|
17
|
-
Resources::MonitorCollection.new(
|
|
18
|
-
data: body["data"],
|
|
19
|
-
has_more: body["hasMore"],
|
|
20
|
-
next_cursor: body["nextCursor"]
|
|
21
|
-
)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
module Monitors
|
|
7
|
-
module Runs
|
|
8
|
-
class Get
|
|
9
|
-
def initialize(connection, monitor_id:, id:, **params)
|
|
10
|
-
@connection = connection
|
|
11
|
-
@monitor_id = monitor_id
|
|
12
|
-
@id = id
|
|
13
|
-
@params = params
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def call
|
|
17
|
-
response = @connection.get("/websets/v0/monitors/#{@monitor_id}/runs/#{@id}", @params)
|
|
18
|
-
body = response.body
|
|
19
|
-
|
|
20
|
-
Resources::MonitorRun.new(
|
|
21
|
-
id: body["id"],
|
|
22
|
-
object: body["object"],
|
|
23
|
-
monitor_id: body["monitorId"],
|
|
24
|
-
status: body["status"],
|
|
25
|
-
created_at: body["createdAt"],
|
|
26
|
-
updated_at: body["updatedAt"],
|
|
27
|
-
completed_at: body["completedAt"],
|
|
28
|
-
failed_at: body["failedAt"],
|
|
29
|
-
failed_reason: body["failedReason"]
|
|
30
|
-
)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
module Monitors
|
|
7
|
-
module Runs
|
|
8
|
-
class List
|
|
9
|
-
def initialize(connection, monitor_id:, **params)
|
|
10
|
-
@connection = connection
|
|
11
|
-
@monitor_id = monitor_id
|
|
12
|
-
@params = params
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def call
|
|
16
|
-
response = @connection.get("/websets/v0/monitors/#{@monitor_id}/runs", @params)
|
|
17
|
-
body = response.body
|
|
18
|
-
|
|
19
|
-
Resources::MonitorRunCollection.new(
|
|
20
|
-
data: body["data"],
|
|
21
|
-
has_more: body["hasMore"],
|
|
22
|
-
next_cursor: body["nextCursor"]
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
module Monitors
|
|
7
|
-
class Update
|
|
8
|
-
def initialize(connection, id:, **params)
|
|
9
|
-
@connection = connection
|
|
10
|
-
@id = id
|
|
11
|
-
@params = params
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def call
|
|
15
|
-
response = @connection.patch("/websets/v0/monitors/#{@id}", @params)
|
|
16
|
-
body = response.body
|
|
17
|
-
|
|
18
|
-
Resources::Monitor.new(
|
|
19
|
-
id: body["id"],
|
|
20
|
-
object: body["object"],
|
|
21
|
-
status: body["status"],
|
|
22
|
-
webset_id: body["websetId"],
|
|
23
|
-
cadence: body["cadence"],
|
|
24
|
-
behavior: body["behavior"],
|
|
25
|
-
created_at: body["createdAt"],
|
|
26
|
-
updated_at: body["updatedAt"]
|
|
27
|
-
)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class Retrieve
|
|
7
|
-
def initialize(connection, id:, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@id = id
|
|
10
|
-
@params = normalize_params(params)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.get("/websets/v0/websets/#{@id}", @params)
|
|
15
|
-
body = response.body
|
|
16
|
-
|
|
17
|
-
Resources::Webset.new(
|
|
18
|
-
id: body["id"],
|
|
19
|
-
object: body["object"],
|
|
20
|
-
status: body["status"],
|
|
21
|
-
external_id: body["externalId"],
|
|
22
|
-
title: body["title"],
|
|
23
|
-
searches: body["searches"],
|
|
24
|
-
imports: body["imports"],
|
|
25
|
-
enrichments: body["enrichments"],
|
|
26
|
-
monitors: body["monitors"],
|
|
27
|
-
excludes: body["excludes"],
|
|
28
|
-
metadata: body["metadata"],
|
|
29
|
-
created_at: body["createdAt"],
|
|
30
|
-
updated_at: body["updatedAt"],
|
|
31
|
-
items: body["items"]
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def normalize_params(params)
|
|
38
|
-
# Convert expand array to comma-separated string for API compatibility
|
|
39
|
-
if params[:expand].is_a?(Array)
|
|
40
|
-
params[:expand] = params[:expand].join(",")
|
|
41
|
-
end
|
|
42
|
-
params
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class RetrieveEnrichment
|
|
7
|
-
def initialize(connection, webset_id:, id:)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@webset_id = webset_id
|
|
10
|
-
@id = id
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.get("/websets/v0/websets/#{@webset_id}/enrichments/#{@id}")
|
|
15
|
-
body = response.body
|
|
16
|
-
|
|
17
|
-
Resources::WebsetEnrichment.new(
|
|
18
|
-
id: body["id"],
|
|
19
|
-
object: body["object"],
|
|
20
|
-
status: body["status"],
|
|
21
|
-
webset_id: body["websetId"],
|
|
22
|
-
title: body["title"],
|
|
23
|
-
description: body["description"],
|
|
24
|
-
format: body["format"],
|
|
25
|
-
options: body["options"],
|
|
26
|
-
instructions: body["instructions"],
|
|
27
|
-
metadata: body["metadata"],
|
|
28
|
-
created_at: body["createdAt"],
|
|
29
|
-
updated_at: body["updatedAt"]
|
|
30
|
-
)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class Update
|
|
7
|
-
def initialize(connection, id:, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@id = id
|
|
10
|
-
@params = params
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call
|
|
14
|
-
response = @connection.post("/websets/v0/websets/#{@id}", @params)
|
|
15
|
-
body = response.body
|
|
16
|
-
|
|
17
|
-
Resources::Webset.new(
|
|
18
|
-
id: body["id"],
|
|
19
|
-
object: body["object"],
|
|
20
|
-
status: body["status"],
|
|
21
|
-
external_id: body["externalId"],
|
|
22
|
-
title: body["title"],
|
|
23
|
-
searches: body["searches"],
|
|
24
|
-
imports: body["imports"],
|
|
25
|
-
enrichments: body["enrichments"],
|
|
26
|
-
monitors: body["monitors"],
|
|
27
|
-
excludes: body["excludes"],
|
|
28
|
-
metadata: body["metadata"],
|
|
29
|
-
created_at: body["createdAt"],
|
|
30
|
-
updated_at: body["updatedAt"],
|
|
31
|
-
items: body["items"]
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
module Websets
|
|
6
|
-
class UpdateEnrichment
|
|
7
|
-
def initialize(connection, webset_id:, id:, **params)
|
|
8
|
-
@connection = connection
|
|
9
|
-
@webset_id = webset_id
|
|
10
|
-
@id = id
|
|
11
|
-
@params = params
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def call
|
|
15
|
-
response = @connection.patch("/websets/v0/websets/#{@webset_id}/enrichments/#{@id}", @params)
|
|
16
|
-
body = response.body
|
|
17
|
-
|
|
18
|
-
Resources::WebsetEnrichment.new(
|
|
19
|
-
id: body["id"],
|
|
20
|
-
object: body["object"],
|
|
21
|
-
status: body["status"],
|
|
22
|
-
webset_id: body["websetId"],
|
|
23
|
-
title: body["title"],
|
|
24
|
-
description: body["description"],
|
|
25
|
-
format: body["format"],
|
|
26
|
-
options: body["options"],
|
|
27
|
-
instructions: body["instructions"],
|
|
28
|
-
metadata: body["metadata"],
|
|
29
|
-
created_at: body["createdAt"],
|
|
30
|
-
updated_at: body["updatedAt"]
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Exa
|
|
4
|
-
module Services
|
|
5
|
-
# Converts Ruby parameter names (snake_case) to API format (camelCase) for Websets API
|
|
6
|
-
class WebsetsParameterConverter
|
|
7
|
-
def self.convert(params)
|
|
8
|
-
new.convert(params)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def convert(params)
|
|
12
|
-
converted = {}
|
|
13
|
-
|
|
14
|
-
params.each do |key, value|
|
|
15
|
-
converted_key = convert_key(key)
|
|
16
|
-
converted_value = convert_value(key, value)
|
|
17
|
-
converted[converted_key] = converted_value
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
converted
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def convert_key(key)
|
|
26
|
-
case key
|
|
27
|
-
when :external_id then :externalId
|
|
28
|
-
else
|
|
29
|
-
key
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def convert_value(key, value)
|
|
34
|
-
# Recursively convert nested hashes
|
|
35
|
-
if value.is_a?(Hash)
|
|
36
|
-
convert(value)
|
|
37
|
-
elsif value.is_a?(Array)
|
|
38
|
-
value.map { |item| item.is_a?(Hash) ? convert(item) : item }
|
|
39
|
-
else
|
|
40
|
-
value
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|