lara-sdk 1.5.0 → 1.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 260e413029ef25a896fb6eb641e9ca827fca770534b9510abf7ce95f6f7f9692
4
- data.tar.gz: 27c8ffbed846d88f167a67ba5ba2c178528fcf47246f3288c25bd2e0e2cb773d
3
+ metadata.gz: 62e105c3ffc01c98306c18210a43776511f1bde4564b8b74adf6a6b1386b0db5
4
+ data.tar.gz: 94bf072420119b0a757e7f7ea06fc8323d7a2c6b0b36c5c4f0293fd05007945e
5
5
  SHA512:
6
- metadata.gz: '0874bcc119ba9fb65b3deb2604fc5581b48022b3a4849a5faeeb61c48357baedb77d41d1523b31d5bbdf28e700f21fb2dd63c3e903aae9ed5dd9f47215c52974'
7
- data.tar.gz: 88a93cf1701ba776261cec4dca86ff8468e46aec29e5328babb6912103b392c25c66935bea20c53e3a5ae804e398a5581125d50c5a70b460301fd4f3847d2ae7
6
+ metadata.gz: 11eccbd54efe8c818365d53355f5ff48da6069d2ee6bd1d4f609f340ac6b9ff3ef6579b8623b25fdaf5f62442f3e1f3cf38397d2a56970791f6e207eaf3d0076
7
+ data.tar.gz: 951b8a2d41a38b019192e35b451186f07924b85c845167a096a96ee6b46437c2af4411282cc85b5222e70f1daa52452a76f9492507c08ec1dcf0067040fd1962
@@ -18,6 +18,7 @@ module Lara
18
18
  all.include?(format)
19
19
  end
20
20
  end
21
+
21
22
  def initialize(client)
22
23
  @client = client
23
24
  @polling_interval = 2
@@ -62,26 +63,35 @@ module Lara
62
63
  end
63
64
 
64
65
  # @param content_type [String] Either FileFormat::UNIDIRECTIONAL or FileFormat::MULTIDIRECTIONAL
66
+ # @param gzip [Boolean] When true, compress the CSV before upload and set compression=gzip
67
+ # @param callback_url [String,nil] Optional URL notified when the import completes
65
68
  # @return [Lara::Models::GlossaryImport]
66
- def import_csv(id, csv_path, content_type: FileFormat::UNIDIRECTIONAL, gzip: true)
69
+ def import_csv(id, csv_path, content_type: FileFormat::UNIDIRECTIONAL, gzip: false,
70
+ callback_url: nil)
67
71
  unless FileFormat.valid?(content_type)
68
72
  raise ArgumentError, "Invalid content_type. Supported formats: #{FileFormat.all.join(', ')}"
69
73
  end
70
74
 
71
- require "stringio"
72
- require "zlib"
73
75
  basename = File.basename(csv_path)
76
+ if gzip
77
+ require "stringio"
78
+ require "zlib"
79
+
80
+ buffer = StringIO.new
81
+ gz = Zlib::GzipWriter.new(buffer, 7, Zlib::DEFAULT_STRATEGY)
82
+ File.open(csv_path, "rb") { |_f| IO.copy_stream(_f, gz) }
83
+ gz.finish
84
+ buffer.rewind
85
+
86
+ body = { "compression" => "gzip" }
87
+ files = { "csv" => Faraday::UploadIO.new(buffer, "application/gzip", "#{basename}.gz") }
88
+ else
89
+ body = {}
90
+ files = { "csv" => Faraday::UploadIO.new(csv_path, "text/csv", basename) }
91
+ end
74
92
 
75
- buffer = StringIO.new
76
- gz = Zlib::GzipWriter.new(buffer, 7, Zlib::DEFAULT_STRATEGY)
77
- File.open(csv_path, "rb") { |_f| IO.copy_stream(_f, gz) }
78
- gz.finish
79
- buffer.rewind
80
-
81
- body = { "compression" => "gzip" }
82
93
  body["content_type"] = content_type unless content_type == FileFormat::UNIDIRECTIONAL
83
-
84
- files = { "csv" => Faraday::UploadIO.new(buffer, "application/gzip", "#{basename}.gz") }
94
+ body["callback_url"] = callback_url if callback_url
85
95
  Lara::Models::GlossaryImport.new(**@client.post("/v2/glossaries/#{id}/import",
86
96
  body: body, files: files).transform_keys(&:to_sym))
87
97
  end
@@ -120,6 +130,21 @@ module Lara
120
130
  params: { content_type: content_type, source: source }.compact)
121
131
  end
122
132
 
133
+ # @param callback_url [String] URL notified when the export is ready
134
+ # @param content_type [String] Either FileFormat::UNIDIRECTIONAL or FileFormat::MULTIDIRECTIONAL
135
+ # @param source [String, nil] Optional source language (unidirectional exports only)
136
+ # @return [Lara::Models::GlossaryExport]
137
+ def export_async(id, callback_url:, content_type: FileFormat::UNIDIRECTIONAL, source: nil)
138
+ unless FileFormat.valid?(content_type)
139
+ raise ArgumentError, "Invalid content_type. Supported formats: #{FileFormat.all.join(', ')}"
140
+ end
141
+
142
+ params = { callback_url: callback_url, content_type: content_type }
143
+ params[:source] = source if source
144
+ Lara::Models::GlossaryExport.new(**@client.get("/v2/glossaries/#{id}/export/async",
145
+ params: params).transform_keys(&:to_sym))
146
+ end
147
+
123
148
  # @param glossary_id [String] The glossary ID
124
149
  # @param terms [Array<Hash>] Array of term hashes with :language and :value keys
125
150
  # @param guid [String, nil] Optional unique identifier for multidirectional glossary units
@@ -128,7 +153,8 @@ module Lara
128
153
  body = { terms: terms }
129
154
  body[:guid] = guid if guid
130
155
 
131
- Lara::Models::GlossaryImport.new(**@client.put("/v2/glossaries/#{glossary_id}/content", body: body).transform_keys(&:to_sym))
156
+ Lara::Models::GlossaryImport.new(**@client.put("/v2/glossaries/#{glossary_id}/content",
157
+ body: body).transform_keys(&:to_sym))
132
158
  end
133
159
 
134
160
  # @param glossary_id [String] The glossary ID
@@ -140,7 +166,8 @@ module Lara
140
166
  body[:guid] = guid if guid
141
167
  body[:term] = term if term
142
168
 
143
- Lara::Models::GlossaryImport.new(**@client.delete("/v2/glossaries/#{glossary_id}/content", body: body).transform_keys(&:to_sym))
169
+ Lara::Models::GlossaryImport.new(**@client.delete("/v2/glossaries/#{glossary_id}/content",
170
+ body: body).transform_keys(&:to_sym))
144
171
  end
145
172
  end
146
173
  end
@@ -43,5 +43,14 @@ module Lara
43
43
  @multidirectional = multidirectional
44
44
  end
45
45
  end
46
+
47
+ class GlossaryExport < Base
48
+ attr_reader :job_id
49
+
50
+ def initialize(job_id:, **_kwargs)
51
+ super()
52
+ @job_id = job_id
53
+ end
54
+ end
46
55
  end
47
56
  end
data/lib/lara/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lara
4
- VERSION = "1.5.0"
4
+ VERSION = "1.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lara-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Translated
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-01 00:00:00.000000000 Z
11
+ date: 2026-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday