exa-ai 0.4.1 → 0.6.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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/exe/exa-ai +61 -7
  4. data/exe/exa-ai-answer +9 -8
  5. data/exe/exa-ai-context +6 -5
  6. data/exe/exa-ai-enrichment-cancel +1 -0
  7. data/exe/exa-ai-enrichment-create +1 -0
  8. data/exe/exa-ai-enrichment-delete +1 -0
  9. data/exe/exa-ai-enrichment-get +1 -0
  10. data/exe/exa-ai-enrichment-list +1 -0
  11. data/exe/exa-ai-enrichment-update +1 -0
  12. data/exe/exa-ai-find-similar +1 -0
  13. data/exe/exa-ai-get-contents +9 -8
  14. data/exe/exa-ai-import-create +235 -0
  15. data/exe/exa-ai-import-delete +92 -0
  16. data/exe/exa-ai-import-get +92 -0
  17. data/exe/exa-ai-import-list +72 -0
  18. data/exe/exa-ai-import-update +164 -0
  19. data/exe/exa-ai-monitor-create +223 -0
  20. data/exe/exa-ai-monitor-delete +101 -0
  21. data/exe/exa-ai-monitor-get +92 -0
  22. data/exe/exa-ai-monitor-list +90 -0
  23. data/exe/exa-ai-monitor-runs-get +103 -0
  24. data/exe/exa-ai-monitor-runs-list +110 -0
  25. data/exe/exa-ai-monitor-update +207 -0
  26. data/exe/exa-ai-research-get +7 -7
  27. data/exe/exa-ai-research-list +5 -5
  28. data/exe/exa-ai-research-start +8 -7
  29. data/exe/exa-ai-search +20 -13
  30. data/exe/exa-ai-webset-cancel +1 -0
  31. data/exe/exa-ai-webset-create +44 -6
  32. data/exe/exa-ai-webset-delete +1 -0
  33. data/exe/exa-ai-webset-get +1 -0
  34. data/exe/exa-ai-webset-item-get +1 -0
  35. data/exe/exa-ai-webset-item-list +1 -0
  36. data/exe/exa-ai-webset-list +1 -0
  37. data/exe/exa-ai-webset-search-cancel +1 -0
  38. data/exe/exa-ai-webset-search-create +1 -0
  39. data/exe/exa-ai-webset-search-get +1 -0
  40. data/exe/exa-ai-webset-update +1 -0
  41. data/lib/exa/cli/base.rb +8 -2
  42. data/lib/exa/cli/formatters/answer_formatter.rb +2 -0
  43. data/lib/exa/cli/formatters/contents_formatter.rb +2 -0
  44. data/lib/exa/cli/formatters/context_formatter.rb +2 -0
  45. data/lib/exa/cli/formatters/enrichment_formatter.rb +4 -0
  46. data/lib/exa/cli/formatters/import_formatter.rb +85 -0
  47. data/lib/exa/cli/formatters/monitor_formatter.rb +81 -0
  48. data/lib/exa/cli/formatters/monitor_run_formatter.rb +75 -0
  49. data/lib/exa/cli/formatters/research_formatter.rb +4 -0
  50. data/lib/exa/cli/formatters/search_formatter.rb +2 -0
  51. data/lib/exa/cli/formatters/webset_formatter.rb +4 -0
  52. data/lib/exa/cli/formatters/webset_item_formatter.rb +4 -0
  53. data/lib/exa/client.rb +137 -0
  54. data/lib/exa/constants/websets.rb +19 -0
  55. data/lib/exa/middleware/raise_error.rb +5 -0
  56. data/lib/exa/resources/import.rb +86 -0
  57. data/lib/exa/resources/import_collection.rb +33 -0
  58. data/lib/exa/resources/monitor.rb +48 -0
  59. data/lib/exa/resources/monitor_collection.rb +30 -0
  60. data/lib/exa/resources/monitor_run.rb +52 -0
  61. data/lib/exa/resources/monitor_run_collection.rb +30 -0
  62. data/lib/exa/services/search.rb +21 -1
  63. data/lib/exa/services/websets/create_validator.rb +5 -3
  64. data/lib/exa/services/websets/import_create.rb +40 -0
  65. data/lib/exa/services/websets/import_delete.rb +37 -0
  66. data/lib/exa/services/websets/import_get.rb +37 -0
  67. data/lib/exa/services/websets/import_list.rb +25 -0
  68. data/lib/exa/services/websets/import_update.rb +38 -0
  69. data/lib/exa/services/websets/import_upload.rb +58 -0
  70. data/lib/exa/services/websets/monitors/create.rb +42 -0
  71. data/lib/exa/services/websets/monitors/delete.rb +32 -0
  72. data/lib/exa/services/websets/monitors/get.rb +33 -0
  73. data/lib/exa/services/websets/monitors/list.rb +27 -0
  74. data/lib/exa/services/websets/monitors/runs/get.rb +37 -0
  75. data/lib/exa/services/websets/monitors/runs/list.rb +30 -0
  76. data/lib/exa/services/websets/monitors/update.rb +33 -0
  77. data/lib/exa/version.rb +1 -1
  78. data/lib/exa.rb +23 -0
  79. metadata +50 -1
@@ -12,6 +12,8 @@ module Exa
12
12
  JSON.pretty_generate(webset.to_h)
13
13
  when "text"
14
14
  format_as_text(webset)
15
+ when "toon"
16
+ Exa::CLI::Base.encode_as_toon(webset.to_h)
15
17
  else
16
18
  raise ArgumentError, "Unknown output format: #{output_format}"
17
19
  end
@@ -25,6 +27,8 @@ module Exa
25
27
  JSON.pretty_generate(collection.to_h)
26
28
  when "text"
27
29
  format_collection_as_text(collection)
30
+ when "toon"
31
+ Exa::CLI::Base.encode_as_toon(collection.to_h)
28
32
  else
29
33
  raise ArgumentError, "Unknown output format: #{output_format}"
30
34
  end
@@ -12,6 +12,8 @@ module Exa
12
12
  JSON.pretty_generate(item)
13
13
  when "text"
14
14
  format_as_text(item)
15
+ when "toon"
16
+ Exa::CLI::Base.encode_as_toon(item)
15
17
  else
16
18
  raise ArgumentError, "Unknown output format: #{output_format}"
17
19
  end
@@ -25,6 +27,8 @@ module Exa
25
27
  JSON.pretty_generate(items)
26
28
  when "text"
27
29
  format_collection_as_text(items)
30
+ when "toon"
31
+ Exa::CLI::Base.encode_as_toon(items)
28
32
  else
29
33
  raise ArgumentError, "Unknown output format: #{output_format}"
30
34
  end
data/lib/exa/client.rb CHANGED
@@ -319,6 +319,143 @@ module Exa
319
319
  Services::Websets::ListItems.new(connection, webset_id: webset_id).call
320
320
  end
321
321
 
322
+ # List all imports
323
+ #
324
+ # @param params [Hash] Pagination parameters
325
+ # @option params [String] :cursor Cursor for pagination
326
+ # @option params [Integer] :limit Maximum number of imports to return
327
+ # @return [Resources::ImportCollection] Paginated list of imports
328
+ def list_imports(**params)
329
+ Services::Websets::ListImports.new(connection, **params).call
330
+ end
331
+
332
+ # Create a new import
333
+ #
334
+ # @param params [Hash] Import parameters
335
+ # @option params [Integer] :size Size of the import file
336
+ # @option params [Integer] :count Number of items to import
337
+ # @option params [String] :title Import title
338
+ # @option params [String] :format Import format (e.g., "csv")
339
+ # @option params [Hash] :entity Entity type specification
340
+ # @option params [Hash] :metadata Custom metadata
341
+ # @option params [Hash] :csv CSV-specific configuration
342
+ # @return [Resources::Import] The newly created import
343
+ def create_import(**params)
344
+ Services::Websets::CreateImport.new(connection, **params).call
345
+ end
346
+
347
+ # Upload a file for import (creates import and uploads file)
348
+ #
349
+ # @param file_path [String] Path to the file to upload
350
+ # @param params [Hash] Import parameters
351
+ # @option params [Integer] :count Number of items to import
352
+ # @option params [String] :title Import title
353
+ # @option params [String] :format Import format (e.g., "csv")
354
+ # @option params [Hash] :entity Entity type specification
355
+ # @option params [Hash] :metadata Custom metadata
356
+ # @option params [Hash] :csv CSV-specific configuration
357
+ # @return [Resources::Import] The created import (file size is inferred automatically)
358
+ def upload_import(file_path:, **params)
359
+ Services::Websets::UploadImport.new(connection, file_path: file_path, **params).call
360
+ end
361
+
362
+ # Get a specific import by ID
363
+ #
364
+ # @param id [String] Import ID
365
+ # @return [Resources::Import] The requested import
366
+ def get_import(id)
367
+ Services::Websets::GetImport.new(connection, id: id).call
368
+ end
369
+
370
+ # Update an import
371
+ #
372
+ # @param id [String] Import ID
373
+ # @param params [Hash] Update parameters
374
+ # @option params [String] :title Updated title
375
+ # @option params [Hash] :metadata Updated metadata
376
+ # @return [Resources::Import] The updated import
377
+ def update_import(id, **params)
378
+ Services::Websets::UpdateImport.new(connection, id: id, **params).call
379
+ end
380
+
381
+ # Delete an import
382
+ #
383
+ # @param id [String] Import ID
384
+ # @return [Resources::Import] The deleted import
385
+ def delete_import(id)
386
+ Services::Websets::DeleteImport.new(connection, id: id).call
387
+ end
388
+
389
+ # Create a new monitor for a webset
390
+ #
391
+ # @param webset_id [String] Webset ID
392
+ # @param cadence [Hash] Schedule configuration with :cron and :timezone
393
+ # @param behavior [Hash] Behavior configuration (type, query, etc.)
394
+ # @param params [Hash] Additional monitor parameters
395
+ # @option params [Hash] :metadata Custom metadata
396
+ # @return [Resources::Monitor] The newly created monitor
397
+ def create_monitor(webset_id:, cadence:, behavior:, **params)
398
+ Services::Websets::Monitors::Create.new(connection, webset_id: webset_id, cadence: cadence, behavior: behavior, **params).call
399
+ end
400
+
401
+ # List all monitors
402
+ #
403
+ # @param params [Hash] Pagination parameters
404
+ # @option params [String] :cursor Cursor for pagination
405
+ # @option params [Integer] :limit Maximum number of monitors to return
406
+ # @return [Resources::MonitorCollection] Paginated list of monitors
407
+ def list_monitors(**params)
408
+ Services::Websets::Monitors::List.new(connection, **params).call
409
+ end
410
+
411
+ # Get a specific monitor by ID
412
+ #
413
+ # @param id [String] Monitor ID
414
+ # @return [Resources::Monitor] The requested monitor
415
+ def get_monitor(id:)
416
+ Services::Websets::Monitors::Get.new(connection, id: id).call
417
+ end
418
+
419
+ # Update a monitor
420
+ #
421
+ # @param id [String] Monitor ID
422
+ # @param params [Hash] Update parameters
423
+ # @option params [Hash] :cadence Updated schedule configuration
424
+ # @option params [Hash] :behavior Updated behavior configuration
425
+ # @option params [Hash] :metadata Updated metadata
426
+ # @return [Resources::Monitor] The updated monitor
427
+ def update_monitor(id:, **params)
428
+ Services::Websets::Monitors::Update.new(connection, id: id, **params).call
429
+ end
430
+
431
+ # Delete a monitor
432
+ #
433
+ # @param id [String] Monitor ID
434
+ # @return [Resources::Monitor] The deleted monitor
435
+ def delete_monitor(id:)
436
+ Services::Websets::Monitors::Delete.new(connection, id: id).call
437
+ end
438
+
439
+ # List all runs for a specific monitor
440
+ #
441
+ # @param monitor_id [String] Monitor ID
442
+ # @param params [Hash] Pagination parameters
443
+ # @option params [String] :cursor Cursor for pagination
444
+ # @option params [Integer] :limit Maximum number of runs to return
445
+ # @return [Resources::MonitorRunCollection] Paginated list of monitor runs
446
+ def list_monitor_runs(monitor_id:, **params)
447
+ Services::Websets::Monitors::Runs::List.new(connection, monitor_id: monitor_id, **params).call
448
+ end
449
+
450
+ # Get a specific monitor run by ID
451
+ #
452
+ # @param monitor_id [String] Monitor ID
453
+ # @param id [String] Run ID
454
+ # @return [Resources::MonitorRun] The requested monitor run
455
+ def get_monitor_run(monitor_id:, id:)
456
+ Services::Websets::Monitors::Runs::Get.new(connection, monitor_id: monitor_id, id: id).call
457
+ end
458
+
322
459
  private
323
460
 
324
461
  def connection
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exa
4
+ module Constants
5
+ module Websets
6
+ # Valid entity types for websets
7
+ ENTITY_TYPES = %w[company person article research_paper custom].freeze
8
+
9
+ # Valid enrichment formats
10
+ ENRICHMENT_FORMATS = %w[text date number options url].freeze
11
+
12
+ # Valid source types for imports and exclusions
13
+ SOURCE_TYPES = %w[import webset].freeze
14
+
15
+ # Valid import formats
16
+ IMPORT_FORMATS = %w[csv].freeze
17
+ end
18
+ end
19
+ end
@@ -41,6 +41,11 @@ module Exa
41
41
  body = env[:body]
42
42
 
43
43
  if body.is_a?(Hash)
44
+ # Prioritize "message" field for detailed error descriptions
45
+ return body["message"] if body["message"]
46
+ return body[:message] if body[:message]
47
+
48
+ # Fall back to "error" field
44
49
  return body["error"] if body["error"]
45
50
  return body[:error] if body[:error]
46
51
  end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exa
4
+ module Resources
5
+ # Represents an import operation for bringing external data into Exa
6
+ #
7
+ # An import allows uploading CSV data containing entities (e.g., companies)
8
+ # to be processed and enriched within the Exa system.
9
+ class Import < Struct.new(
10
+ :id,
11
+ :object,
12
+ :status,
13
+ :format,
14
+ :entity,
15
+ :title,
16
+ :count,
17
+ :metadata,
18
+ :failed_reason,
19
+ :failed_at,
20
+ :failed_message,
21
+ :created_at,
22
+ :updated_at,
23
+ :upload_url,
24
+ :upload_valid_until,
25
+ keyword_init: true
26
+ )
27
+ def initialize(
28
+ id:,
29
+ object:,
30
+ status:,
31
+ format: nil,
32
+ entity: nil,
33
+ title: nil,
34
+ count: nil,
35
+ metadata: nil,
36
+ failed_reason: nil,
37
+ failed_at: nil,
38
+ failed_message: nil,
39
+ created_at: nil,
40
+ updated_at: nil,
41
+ upload_url: nil,
42
+ upload_valid_until: nil
43
+ )
44
+ super
45
+ freeze
46
+ end
47
+
48
+ # Status helper methods
49
+ def pending?
50
+ status == "pending"
51
+ end
52
+
53
+ def processing?
54
+ status == "processing"
55
+ end
56
+
57
+ def completed?
58
+ status == "completed"
59
+ end
60
+
61
+ def failed?
62
+ status == "failed"
63
+ end
64
+
65
+ def to_h
66
+ {
67
+ id: id,
68
+ object: object,
69
+ status: status,
70
+ format: format,
71
+ entity: entity,
72
+ title: title,
73
+ count: count,
74
+ metadata: metadata,
75
+ failed_reason: failed_reason,
76
+ failed_at: failed_at,
77
+ failed_message: failed_message,
78
+ created_at: created_at,
79
+ updated_at: updated_at,
80
+ upload_url: upload_url,
81
+ upload_valid_until: upload_valid_until
82
+ }.compact
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exa
4
+ module Resources
5
+ # Represents a paginated list of imports from the Exa API
6
+ #
7
+ # This class wraps the JSON response from the GET /websets/v0/imports endpoint
8
+ # and provides pagination support.
9
+ class ImportCollection < Struct.new(
10
+ :data,
11
+ :has_more,
12
+ :next_cursor,
13
+ keyword_init: true
14
+ )
15
+ def initialize(data:, has_more: false, next_cursor: nil)
16
+ super
17
+ freeze
18
+ end
19
+
20
+ def empty?
21
+ data.empty?
22
+ end
23
+
24
+ def to_h
25
+ {
26
+ data: data,
27
+ has_more: has_more,
28
+ next_cursor: next_cursor
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,48 @@
1
+ module Exa
2
+ module Resources
3
+ # Represents a webset monitor that automates updates on a schedule
4
+ Monitor = Struct.new(
5
+ :id,
6
+ :object,
7
+ :status,
8
+ :webset_id,
9
+ :cadence,
10
+ :behavior,
11
+ :created_at,
12
+ :updated_at,
13
+ keyword_init: true
14
+ ) do
15
+ def freeze
16
+ super
17
+ cadence.freeze if cadence
18
+ behavior.freeze if behavior
19
+ self
20
+ end
21
+
22
+ def pending?
23
+ status == "pending"
24
+ end
25
+
26
+ def active?
27
+ status == "active"
28
+ end
29
+
30
+ def paused?
31
+ status == "paused"
32
+ end
33
+
34
+ def to_h
35
+ {
36
+ id: id,
37
+ object: object,
38
+ status: status,
39
+ webset_id: webset_id,
40
+ cadence: cadence,
41
+ behavior: behavior,
42
+ created_at: created_at,
43
+ updated_at: updated_at
44
+ }.compact
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exa
4
+ module Resources
5
+ # Represents a paginated list of monitors from the Exa API
6
+ class MonitorCollection < Struct.new(
7
+ :data,
8
+ :has_more,
9
+ :next_cursor,
10
+ keyword_init: true
11
+ )
12
+ def initialize(data:, has_more: false, next_cursor: nil)
13
+ super
14
+ freeze
15
+ end
16
+
17
+ def empty?
18
+ data.empty?
19
+ end
20
+
21
+ def to_h
22
+ {
23
+ data: data,
24
+ has_more: has_more,
25
+ next_cursor: next_cursor
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,52 @@
1
+ module Exa
2
+ module Resources
3
+ # Represents a monitor run execution
4
+ MonitorRun = Struct.new(
5
+ :id,
6
+ :object,
7
+ :monitor_id,
8
+ :status,
9
+ :created_at,
10
+ :updated_at,
11
+ :completed_at,
12
+ :failed_at,
13
+ :failed_reason,
14
+ keyword_init: true
15
+ ) do
16
+ def freeze
17
+ super
18
+ self
19
+ end
20
+
21
+ def pending?
22
+ status == "pending"
23
+ end
24
+
25
+ def running?
26
+ status == "running"
27
+ end
28
+
29
+ def completed?
30
+ status == "completed"
31
+ end
32
+
33
+ def failed?
34
+ status == "failed"
35
+ end
36
+
37
+ def to_h
38
+ {
39
+ id: id,
40
+ object: object,
41
+ monitor_id: monitor_id,
42
+ status: status,
43
+ created_at: created_at,
44
+ updated_at: updated_at,
45
+ completed_at: completed_at,
46
+ failed_at: failed_at,
47
+ failed_reason: failed_reason
48
+ }.compact
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exa
4
+ module Resources
5
+ # Represents a paginated list of monitor runs from the Exa API
6
+ class MonitorRunCollection < Struct.new(
7
+ :data,
8
+ :has_more,
9
+ :next_cursor,
10
+ keyword_init: true
11
+ )
12
+ def initialize(data:, has_more: false, next_cursor: nil)
13
+ super
14
+ freeze
15
+ end
16
+
17
+ def empty?
18
+ data.empty?
19
+ end
20
+
21
+ def to_h
22
+ {
23
+ data: data,
24
+ has_more: has_more,
25
+ next_cursor: next_cursor
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -5,9 +5,13 @@ require_relative "parameter_converter"
5
5
  module Exa
6
6
  module Services
7
7
  class Search
8
+ VALID_SEARCH_TYPES = ["fast", "deep", "keyword", "auto"].freeze
9
+ DEFAULT_SEARCH_TYPE = "fast"
10
+
8
11
  def initialize(connection, **params)
9
12
  @connection = connection
10
- @params = params
13
+ @params = normalize_params(params)
14
+ validate_search_type!
11
15
  end
12
16
 
13
17
  def call
@@ -23,6 +27,22 @@ module Exa
23
27
  cost_dollars: body["costDollars"]
24
28
  )
25
29
  end
30
+
31
+ private
32
+
33
+ def normalize_params(params)
34
+ normalized = params.dup
35
+ # Set default search type if not provided
36
+ normalized[:type] = DEFAULT_SEARCH_TYPE unless normalized.key?(:type)
37
+ normalized
38
+ end
39
+
40
+ def validate_search_type!
41
+ search_type = @params[:type]
42
+ return if VALID_SEARCH_TYPES.include?(search_type)
43
+
44
+ raise ArgumentError, "Invalid search type: '#{search_type}'. Must be one of: #{VALID_SEARCH_TYPES.join(', ')}"
45
+ end
26
46
  end
27
47
  end
28
48
  end
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../../constants/websets"
4
+
3
5
  module Exa
4
6
  module Services
5
7
  module Websets
6
8
  # Validates parameters for webset creation
7
9
  class CreateValidator
8
- VALID_ENTITY_TYPES = %w[company person article research_paper custom].freeze
9
- VALID_ENRICHMENT_FORMATS = %w[text date number options url].freeze
10
- VALID_SOURCE_TYPES = %w[import webset].freeze
10
+ VALID_ENTITY_TYPES = Constants::Websets::ENTITY_TYPES
11
+ VALID_ENRICHMENT_FORMATS = Constants::Websets::ENRICHMENT_FORMATS
12
+ VALID_SOURCE_TYPES = Constants::Websets::SOURCE_TYPES
11
13
 
12
14
  class << self
13
15
  def validate!(params)
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exa
4
+ module Services
5
+ module Websets
6
+ class CreateImport
7
+ def initialize(connection, **params)
8
+ @connection = connection
9
+ @params = params
10
+ end
11
+
12
+ def call
13
+ response = @connection.post(
14
+ "/websets/v0/imports",
15
+ @params
16
+ )
17
+ body = response.body
18
+
19
+ Resources::Import.new(
20
+ id: body["id"],
21
+ object: body["object"],
22
+ status: body["status"],
23
+ format: body["format"],
24
+ entity: body["entity"],
25
+ title: body["title"],
26
+ count: body["count"],
27
+ metadata: body["metadata"],
28
+ failed_reason: body["failedReason"],
29
+ failed_at: body["failedAt"],
30
+ failed_message: body["failedMessage"],
31
+ created_at: body["createdAt"],
32
+ updated_at: body["updatedAt"],
33
+ upload_url: body["uploadUrl"],
34
+ upload_valid_until: body["uploadValidUntil"]
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exa
4
+ module Services
5
+ module Websets
6
+ class DeleteImport
7
+ def initialize(connection, id:)
8
+ @connection = connection
9
+ @id = id
10
+ end
11
+
12
+ def call
13
+ response = @connection.delete("/websets/v0/imports/#{@id}")
14
+ body = response.body
15
+
16
+ Resources::Import.new(
17
+ id: body["id"],
18
+ object: body["object"],
19
+ status: body["status"],
20
+ format: body["format"],
21
+ entity: body["entity"],
22
+ title: body["title"],
23
+ count: body["count"],
24
+ metadata: body["metadata"],
25
+ failed_reason: body["failedReason"],
26
+ failed_at: body["failedAt"],
27
+ failed_message: body["failedMessage"],
28
+ created_at: body["createdAt"],
29
+ updated_at: body["updatedAt"],
30
+ upload_url: body["uploadUrl"],
31
+ upload_valid_until: body["uploadValidUntil"]
32
+ )
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exa
4
+ module Services
5
+ module Websets
6
+ class GetImport
7
+ def initialize(connection, id:)
8
+ @connection = connection
9
+ @id = id
10
+ end
11
+
12
+ def call
13
+ response = @connection.get("/websets/v0/imports/#{@id}")
14
+ body = response.body
15
+
16
+ Resources::Import.new(
17
+ id: body["id"],
18
+ object: body["object"],
19
+ status: body["status"],
20
+ format: body["format"],
21
+ entity: body["entity"],
22
+ title: body["title"],
23
+ count: body["count"],
24
+ metadata: body["metadata"],
25
+ failed_reason: body["failedReason"],
26
+ failed_at: body["failedAt"],
27
+ failed_message: body["failedMessage"],
28
+ created_at: body["createdAt"],
29
+ updated_at: body["updatedAt"],
30
+ upload_url: body["uploadUrl"],
31
+ upload_valid_until: body["uploadValidUntil"]
32
+ )
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exa
4
+ module Services
5
+ module Websets
6
+ class ListImports
7
+ def initialize(connection, **params)
8
+ @connection = connection
9
+ @params = params
10
+ end
11
+
12
+ def call
13
+ response = @connection.get("/websets/v0/imports", @params)
14
+ body = response.body
15
+
16
+ Resources::ImportCollection.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