deepl-rb 2.5.3 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/add_issues_to_kanban.yml +16 -0
- data/.gitlab-ci.yml +135 -0
- data/.rubocop.yml +27 -0
- data/CHANGELOG.md +39 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/CONTRIBUTING.md +37 -0
- data/Gemfile +3 -1
- data/LICENSE.md +1 -0
- data/README.md +115 -5
- data/Rakefile +7 -5
- data/SECURITY.md +58 -0
- data/VERSION +1 -1
- data/deepl-rb.gemspec +36 -20
- data/lib/deepl/api.rb +11 -1
- data/lib/deepl/configuration.rb +34 -3
- data/lib/deepl/document_api.rb +121 -0
- data/lib/deepl/exceptions/authorization_failed.rb +3 -0
- data/lib/deepl/exceptions/bad_request.rb +3 -0
- data/lib/deepl/exceptions/document_translation_error.rb +15 -0
- data/lib/deepl/exceptions/error.rb +6 -0
- data/lib/deepl/exceptions/limit_exceeded.rb +7 -0
- data/lib/deepl/exceptions/not_found.rb +3 -0
- data/lib/deepl/exceptions/not_supported.rb +3 -0
- data/lib/deepl/exceptions/quota_exceeded.rb +3 -0
- data/lib/deepl/exceptions/request_entity_too_large.rb +3 -0
- data/lib/deepl/exceptions/request_error.rb +4 -2
- data/lib/deepl/exceptions/server_error.rb +18 -0
- data/lib/deepl/glossary_api.rb +3 -0
- data/lib/deepl/requests/base.rb +89 -34
- data/lib/deepl/requests/document/download.rb +44 -0
- data/lib/deepl/requests/document/get_status.rb +44 -0
- data/lib/deepl/requests/document/upload.rb +64 -0
- data/lib/deepl/requests/glossary/create.rb +15 -1
- data/lib/deepl/requests/glossary/destroy.rb +8 -1
- data/lib/deepl/requests/glossary/entries.rb +8 -1
- data/lib/deepl/requests/glossary/find.rb +8 -1
- data/lib/deepl/requests/glossary/language_pairs.rb +9 -2
- data/lib/deepl/requests/glossary/list.rb +9 -2
- data/lib/deepl/requests/languages.rb +9 -2
- data/lib/deepl/requests/translate.rb +33 -11
- data/lib/deepl/requests/usage.rb +9 -2
- data/lib/deepl/resources/base.rb +3 -0
- data/lib/deepl/resources/document_handle.rb +57 -0
- data/lib/deepl/resources/document_translation_status.rb +54 -0
- data/lib/deepl/resources/glossary.rb +3 -0
- data/lib/deepl/resources/language.rb +3 -0
- data/lib/deepl/resources/language_pair.rb +3 -0
- data/lib/deepl/resources/text.rb +3 -0
- data/lib/deepl/resources/usage.rb +3 -0
- data/lib/deepl/utils/backoff_timer.rb +46 -0
- data/lib/deepl/utils/exception_builder.rb +18 -13
- data/lib/deepl.rb +47 -0
- data/lib/http_client_options.rb +22 -0
- data/license_checker.sh +8 -0
- data/spec/api/api_spec.rb +8 -4
- data/spec/api/configuration_spec.rb +92 -18
- data/spec/api/deepl_spec.rb +225 -86
- data/spec/fixtures/vcr_cassettes/deepl_document.yml +95 -0
- data/spec/fixtures/vcr_cassettes/deepl_document_download.yml +1214 -0
- data/spec/fixtures/vcr_cassettes/deepl_glossaries.yml +812 -23
- data/spec/fixtures/vcr_cassettes/deepl_languages.yml +28 -17
- data/spec/fixtures/vcr_cassettes/deepl_translate.yml +161 -53
- data/spec/fixtures/vcr_cassettes/deepl_usage.yml +93 -3
- data/spec/fixtures/vcr_cassettes/glossaries.yml +1237 -15
- data/spec/fixtures/vcr_cassettes/languages.yml +159 -44
- data/spec/fixtures/vcr_cassettes/translate_texts.yml +9742 -12
- data/spec/fixtures/vcr_cassettes/usage.yml +134 -2
- data/spec/integration_tests/document_api_spec.rb +155 -0
- data/spec/integration_tests/integration_test_utils.rb +170 -0
- data/spec/requests/glossary/create_spec.rb +23 -13
- data/spec/requests/glossary/destroy_spec.rb +33 -17
- data/spec/requests/glossary/entries_spec.rb +31 -17
- data/spec/requests/glossary/find_spec.rb +31 -17
- data/spec/requests/glossary/language_pairs_spec.rb +17 -7
- data/spec/requests/glossary/list_spec.rb +21 -11
- data/spec/requests/languages_spec.rb +31 -21
- data/spec/requests/translate_spec.rb +125 -131
- data/spec/requests/usage_spec.rb +17 -7
- data/spec/resources/glossary_spec.rb +15 -12
- data/spec/resources/language_pair_spec.rb +10 -7
- data/spec/resources/language_spec.rb +21 -18
- data/spec/resources/text_spec.rb +10 -7
- data/spec/resources/usage_spec.rb +16 -13
- data/spec/spec_helper.rb +63 -6
- metadata +32 -9
@@ -2,10 +2,10 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api
|
5
|
+
uri: https://api.deepl.com/v2/languages
|
6
6
|
body:
|
7
|
-
encoding:
|
8
|
-
string:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "{}"
|
9
9
|
headers:
|
10
10
|
Authorization:
|
11
11
|
- DeepL-Auth-Key VALID_TOKEN
|
@@ -13,102 +13,217 @@ http_interactions:
|
|
13
13
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
14
|
Accept:
|
15
15
|
- "*/*"
|
16
|
-
User-Agent:
|
17
|
-
- Ruby
|
18
16
|
response:
|
19
17
|
status:
|
20
18
|
code: 200
|
21
19
|
message: OK
|
22
20
|
headers:
|
23
|
-
Server:
|
24
|
-
- nginx
|
25
21
|
Date:
|
26
|
-
- Mon,
|
22
|
+
- Mon, 08 Jul 2024 09:58:27 GMT
|
27
23
|
Content-Type:
|
28
24
|
- application/json
|
29
|
-
|
30
|
-
-
|
31
|
-
|
32
|
-
-
|
25
|
+
Transfer-Encoding:
|
26
|
+
- chunked
|
27
|
+
Vary:
|
28
|
+
- Accept-Encoding
|
33
29
|
Access-Control-Allow-Origin:
|
34
30
|
- "*"
|
31
|
+
X-Cache-Status:
|
32
|
+
- MISS
|
33
|
+
Strict-Transport-Security:
|
34
|
+
- max-age=63072000; includeSubDomains; preload
|
35
|
+
Server-Timing:
|
36
|
+
- l7_lb_tls;dur=108, l7_lb_idle;dur=0, l7_lb_receive;dur=1, l7_lb_total;dur=111
|
37
|
+
Access-Control-Expose-Headers:
|
38
|
+
- Server-Timing, X-Trace-ID
|
39
|
+
X-Trace-Id:
|
40
|
+
- 219e287aedb54e73953a9e3efba26e13
|
35
41
|
body:
|
36
|
-
encoding:
|
37
|
-
string: '[{"language":"BG","name":"Bulgarian"},{"language":"CS","name":"Czech"},{"language":"DA","name":"Danish"},{"language":"DE","name":"German"},{"language":"EL","name":"Greek"},{"language":"EN","name":"English"},{"language":"ES","name":"Spanish"},{"language":"ET","name":"Estonian"},{"language":"FI","name":"Finnish"},{"language":"FR","name":"French"},{"language":"HU","name":"Hungarian"},{"language":"IT","name":"Italian"},{"language":"JA","name":"Japanese"},{"language":"LT","name":"Lithuanian"},{"language":"LV","name":"Latvian"},{"language":"NL","name":"Dutch"},{"language":"PL","name":"Polish"},{"language":"PT","name":"Portuguese"},{"language":"RO","name":"Romanian"},{"language":"RU","name":"Russian"},{"language":"SK","name":"Slovak"},{"language":"SL","name":"Slovenian"},{"language":"SV","name":"Swedish"},{"language":"ZH","name":"Chinese"}]'
|
38
|
-
recorded_at: Mon,
|
42
|
+
encoding: ASCII-8BIT
|
43
|
+
string: '[{"language":"BG","name":"Bulgarian"},{"language":"CS","name":"Czech"},{"language":"DA","name":"Danish"},{"language":"DE","name":"German"},{"language":"EL","name":"Greek"},{"language":"EN","name":"English"},{"language":"ES","name":"Spanish"},{"language":"ET","name":"Estonian"},{"language":"FI","name":"Finnish"},{"language":"FR","name":"French"},{"language":"HU","name":"Hungarian"},{"language":"ID","name":"Indonesian"},{"language":"IT","name":"Italian"},{"language":"JA","name":"Japanese"},{"language":"KO","name":"Korean"},{"language":"LT","name":"Lithuanian"},{"language":"LV","name":"Latvian"},{"language":"NB","name":"Norwegian"},{"language":"NL","name":"Dutch"},{"language":"PL","name":"Polish"},{"language":"PT","name":"Portuguese"},{"language":"RO","name":"Romanian"},{"language":"RU","name":"Russian"},{"language":"SK","name":"Slovak"},{"language":"SL","name":"Slovenian"},{"language":"SV","name":"Swedish"},{"language":"TR","name":"Turkish"},{"language":"UK","name":"Ukrainian"},{"language":"ZH","name":"Chinese"}]'
|
44
|
+
recorded_at: Mon, 08 Jul 2024 09:58:27 GMT
|
39
45
|
- request:
|
40
46
|
method: get
|
41
|
-
uri: https://api
|
47
|
+
uri: https://api.deepl.com/v2/languages
|
42
48
|
body:
|
43
|
-
encoding:
|
44
|
-
string:
|
49
|
+
encoding: UTF-8
|
50
|
+
string: "{}"
|
45
51
|
headers:
|
46
52
|
Authorization:
|
47
53
|
- DeepL-Auth-Key VALID_TOKEN
|
54
|
+
User-Agent:
|
55
|
+
- deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
|
56
|
+
Content-Type:
|
57
|
+
- application/json
|
48
58
|
Accept-Encoding:
|
49
59
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
50
60
|
Accept:
|
51
61
|
- "*/*"
|
52
|
-
User-Agent:
|
53
|
-
- Ruby
|
54
62
|
response:
|
55
63
|
status:
|
56
64
|
code: 200
|
57
65
|
message: OK
|
58
66
|
headers:
|
59
|
-
Server:
|
60
|
-
- nginx
|
61
67
|
Date:
|
62
|
-
- Mon,
|
68
|
+
- Mon, 08 Jul 2024 11:27:22 GMT
|
63
69
|
Content-Type:
|
64
70
|
- application/json
|
65
|
-
|
66
|
-
-
|
67
|
-
|
68
|
-
-
|
71
|
+
Transfer-Encoding:
|
72
|
+
- chunked
|
73
|
+
Vary:
|
74
|
+
- Accept-Encoding
|
69
75
|
Access-Control-Allow-Origin:
|
70
76
|
- "*"
|
77
|
+
X-Cache-Status:
|
78
|
+
- MISS
|
79
|
+
Strict-Transport-Security:
|
80
|
+
- max-age=63072000; includeSubDomains; preload
|
81
|
+
Server-Timing:
|
82
|
+
- l7_lb_tls;dur=101, l7_lb_idle;dur=1, l7_lb_receive;dur=0, l7_lb_total;dur=124
|
83
|
+
Access-Control-Expose-Headers:
|
84
|
+
- Server-Timing, X-Trace-ID
|
85
|
+
X-Trace-Id:
|
86
|
+
- a6ee4f394fe142e398267aa0ba99e1db
|
87
|
+
body:
|
88
|
+
encoding: ASCII-8BIT
|
89
|
+
string: '[{"language":"BG","name":"Bulgarian"},{"language":"CS","name":"Czech"},{"language":"DA","name":"Danish"},{"language":"DE","name":"German"},{"language":"EL","name":"Greek"},{"language":"EN","name":"English"},{"language":"ES","name":"Spanish"},{"language":"ET","name":"Estonian"},{"language":"FI","name":"Finnish"},{"language":"FR","name":"French"},{"language":"HU","name":"Hungarian"},{"language":"ID","name":"Indonesian"},{"language":"IT","name":"Italian"},{"language":"JA","name":"Japanese"},{"language":"KO","name":"Korean"},{"language":"LT","name":"Lithuanian"},{"language":"LV","name":"Latvian"},{"language":"NB","name":"Norwegian"},{"language":"NL","name":"Dutch"},{"language":"PL","name":"Polish"},{"language":"PT","name":"Portuguese"},{"language":"RO","name":"Romanian"},{"language":"RU","name":"Russian"},{"language":"SK","name":"Slovak"},{"language":"SL","name":"Slovenian"},{"language":"SV","name":"Swedish"},{"language":"TR","name":"Turkish"},{"language":"UK","name":"Ukrainian"},{"language":"ZH","name":"Chinese"}]'
|
90
|
+
recorded_at: Mon, 08 Jul 2024 11:27:22 GMT
|
91
|
+
- request:
|
92
|
+
method: get
|
93
|
+
uri: https://api.deepl.com/v2/languages
|
71
94
|
body:
|
72
95
|
encoding: UTF-8
|
96
|
+
string: '{"type":"target"}'
|
97
|
+
headers:
|
98
|
+
Authorization:
|
99
|
+
- DeepL-Auth-Key VALID_TOKEN
|
100
|
+
User-Agent:
|
101
|
+
- deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
|
102
|
+
Content-Type:
|
103
|
+
- application/json
|
104
|
+
Accept-Encoding:
|
105
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
106
|
+
Accept:
|
107
|
+
- "*/*"
|
108
|
+
response:
|
109
|
+
status:
|
110
|
+
code: 200
|
111
|
+
message: OK
|
112
|
+
headers:
|
113
|
+
Date:
|
114
|
+
- Mon, 08 Jul 2024 11:27:22 GMT
|
115
|
+
Content-Type:
|
116
|
+
- application/json
|
117
|
+
Transfer-Encoding:
|
118
|
+
- chunked
|
119
|
+
Vary:
|
120
|
+
- Accept-Encoding
|
121
|
+
Access-Control-Allow-Origin:
|
122
|
+
- "*"
|
123
|
+
X-Cache-Status:
|
124
|
+
- MISS
|
125
|
+
Strict-Transport-Security:
|
126
|
+
- max-age=63072000; includeSubDomains; preload
|
127
|
+
Server-Timing:
|
128
|
+
- l7_lb_tls;dur=185, l7_lb_idle;dur=2, l7_lb_receive;dur=0, l7_lb_total;dur=213
|
129
|
+
Access-Control-Expose-Headers:
|
130
|
+
- Server-Timing, X-Trace-ID
|
131
|
+
X-Trace-Id:
|
132
|
+
- d6a4a3b54c1b453d8ecd106a16d69b53
|
133
|
+
body:
|
134
|
+
encoding: ASCII-8BIT
|
73
135
|
string: '[{"language":"BG","name":"Bulgarian","supports_formality":false},{"language":"CS","name":"Czech","supports_formality":false},{"language":"DA","name":"Danish","supports_formality":false},{"language":"DE","name":"German","supports_formality":true},{"language":"EL","name":"Greek","supports_formality":false},{"language":"EN-GB","name":"English
|
74
136
|
(British)","supports_formality":false},{"language":"EN-US","name":"English
|
75
|
-
(American)","supports_formality":false},{"language":"ES","name":"Spanish","supports_formality":true},{"language":"ET","name":"Estonian","supports_formality":false},{"language":"FI","name":"Finnish","supports_formality":false},{"language":"FR","name":"French","supports_formality":true},{"language":"HU","name":"Hungarian","supports_formality":false},{"language":"IT","name":"Italian","supports_formality":true},{"language":"JA","name":"Japanese","supports_formality":false},{"language":"LT","name":"Lithuanian","supports_formality":false},{"language":"LV","name":"Latvian","supports_formality":false},{"language":"NL","name":"Dutch","supports_formality":true},{"language":"PL","name":"Polish","supports_formality":true},{"language":"PT-BR","name":"Portuguese
|
137
|
+
(American)","supports_formality":false},{"language":"ES","name":"Spanish","supports_formality":true},{"language":"ET","name":"Estonian","supports_formality":false},{"language":"FI","name":"Finnish","supports_formality":false},{"language":"FR","name":"French","supports_formality":true},{"language":"HU","name":"Hungarian","supports_formality":false},{"language":"ID","name":"Indonesian","supports_formality":false},{"language":"IT","name":"Italian","supports_formality":true},{"language":"JA","name":"Japanese","supports_formality":true},{"language":"KO","name":"Korean","supports_formality":false},{"language":"LT","name":"Lithuanian","supports_formality":false},{"language":"LV","name":"Latvian","supports_formality":false},{"language":"NB","name":"Norwegian","supports_formality":false},{"language":"NL","name":"Dutch","supports_formality":true},{"language":"PL","name":"Polish","supports_formality":true},{"language":"PT-BR","name":"Portuguese
|
76
138
|
(Brazilian)","supports_formality":true},{"language":"PT-PT","name":"Portuguese
|
77
|
-
(European)","supports_formality":true},{"language":"RO","name":"Romanian","supports_formality":false},{"language":"RU","name":"Russian","supports_formality":true},{"language":"SK","name":"Slovak","supports_formality":false},{"language":"SL","name":"Slovenian","supports_formality":false},{"language":"SV","name":"Swedish","supports_formality":false},{"language":"
|
78
|
-
|
139
|
+
(European)","supports_formality":true},{"language":"RO","name":"Romanian","supports_formality":false},{"language":"RU","name":"Russian","supports_formality":true},{"language":"SK","name":"Slovak","supports_formality":false},{"language":"SL","name":"Slovenian","supports_formality":false},{"language":"SV","name":"Swedish","supports_formality":false},{"language":"TR","name":"Turkish","supports_formality":false},{"language":"UK","name":"Ukrainian","supports_formality":false},{"language":"ZH","name":"Chinese
|
140
|
+
(simplified)","supports_formality":false}]'
|
141
|
+
recorded_at: Mon, 08 Jul 2024 11:27:22 GMT
|
79
142
|
- request:
|
80
143
|
method: get
|
81
|
-
uri: https://api
|
144
|
+
uri: https://api.deepl.com/v2/languages
|
82
145
|
body:
|
83
|
-
encoding:
|
84
|
-
string: ''
|
146
|
+
encoding: UTF-8
|
147
|
+
string: '{"type":"invalid"}'
|
85
148
|
headers:
|
86
149
|
Authorization:
|
87
150
|
- DeepL-Auth-Key VALID_TOKEN
|
151
|
+
User-Agent:
|
152
|
+
- deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
|
153
|
+
Content-Type:
|
154
|
+
- application/json
|
88
155
|
Accept-Encoding:
|
89
156
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
90
157
|
Accept:
|
91
158
|
- "*/*"
|
92
|
-
User-Agent:
|
93
|
-
- Ruby
|
94
159
|
response:
|
95
160
|
status:
|
96
161
|
code: 400
|
97
162
|
message: Bad Request
|
98
163
|
headers:
|
99
|
-
Server:
|
100
|
-
- nginx
|
101
164
|
Date:
|
102
|
-
- Mon,
|
103
|
-
Content-
|
104
|
-
-
|
105
|
-
|
106
|
-
-
|
165
|
+
- Mon, 08 Jul 2024 11:27:22 GMT
|
166
|
+
Content-Type:
|
167
|
+
- application/json
|
168
|
+
Transfer-Encoding:
|
169
|
+
- chunked
|
107
170
|
Access-Control-Allow-Origin:
|
108
171
|
- "*"
|
172
|
+
Strict-Transport-Security:
|
173
|
+
- max-age=63072000; includeSubDomains; preload
|
174
|
+
Server-Timing:
|
175
|
+
- l7_lb_tls;dur=129, l7_lb_idle;dur=2, l7_lb_receive;dur=0, l7_lb_total;dur=148
|
176
|
+
Access-Control-Expose-Headers:
|
177
|
+
- Server-Timing, X-Trace-ID
|
178
|
+
X-Trace-Id:
|
179
|
+
- 13e4846db29d425397f8f13783631f53
|
109
180
|
body:
|
110
181
|
encoding: UTF-8
|
111
182
|
string: '{"message":"Parameter ''type'' is invalid. ''source'' and ''target''
|
112
183
|
are valid values."}'
|
113
|
-
recorded_at: Mon,
|
114
|
-
|
184
|
+
recorded_at: Mon, 08 Jul 2024 11:27:22 GMT
|
185
|
+
- request:
|
186
|
+
method: get
|
187
|
+
uri: https://api.deepl.com/v2/languages
|
188
|
+
body:
|
189
|
+
encoding: UTF-8
|
190
|
+
string: "{}"
|
191
|
+
headers:
|
192
|
+
Authorization:
|
193
|
+
- DeepL-Auth-Key VALID_TOKEN
|
194
|
+
Content-Type:
|
195
|
+
- application/json
|
196
|
+
Accept-Encoding:
|
197
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
198
|
+
Accept:
|
199
|
+
- "*/*"
|
200
|
+
response:
|
201
|
+
status:
|
202
|
+
code: 200
|
203
|
+
message: OK
|
204
|
+
headers:
|
205
|
+
Date:
|
206
|
+
- Tue, 09 Jul 2024 09:34:12 GMT
|
207
|
+
Content-Type:
|
208
|
+
- application/json
|
209
|
+
Transfer-Encoding:
|
210
|
+
- chunked
|
211
|
+
Vary:
|
212
|
+
- Accept-Encoding
|
213
|
+
Access-Control-Allow-Origin:
|
214
|
+
- "*"
|
215
|
+
X-Cache-Status:
|
216
|
+
- MISS
|
217
|
+
Strict-Transport-Security:
|
218
|
+
- max-age=63072000; includeSubDomains; preload
|
219
|
+
Server-Timing:
|
220
|
+
- l7_lb_tls;dur=101, l7_lb_idle;dur=1, l7_lb_receive;dur=0, l7_lb_total;dur=121
|
221
|
+
Access-Control-Expose-Headers:
|
222
|
+
- Server-Timing, X-Trace-ID
|
223
|
+
X-Trace-Id:
|
224
|
+
- 43c2bc53a69c40dfb2e30f58fca8c3ef
|
225
|
+
body:
|
226
|
+
encoding: ASCII-8BIT
|
227
|
+
string: '[{"language":"BG","name":"Bulgarian"},{"language":"CS","name":"Czech"},{"language":"DA","name":"Danish"},{"language":"DE","name":"German"},{"language":"EL","name":"Greek"},{"language":"EN","name":"English"},{"language":"ES","name":"Spanish"},{"language":"ET","name":"Estonian"},{"language":"FI","name":"Finnish"},{"language":"FR","name":"French"},{"language":"HU","name":"Hungarian"},{"language":"ID","name":"Indonesian"},{"language":"IT","name":"Italian"},{"language":"JA","name":"Japanese"},{"language":"KO","name":"Korean"},{"language":"LT","name":"Lithuanian"},{"language":"LV","name":"Latvian"},{"language":"NB","name":"Norwegian"},{"language":"NL","name":"Dutch"},{"language":"PL","name":"Polish"},{"language":"PT","name":"Portuguese"},{"language":"RO","name":"Romanian"},{"language":"RU","name":"Russian"},{"language":"SK","name":"Slovak"},{"language":"SL","name":"Slovenian"},{"language":"SV","name":"Swedish"},{"language":"TR","name":"Turkish"},{"language":"UK","name":"Ukrainian"},{"language":"ZH","name":"Chinese"}]'
|
228
|
+
recorded_at: Tue, 09 Jul 2024 09:34:12 GMT
|
229
|
+
recorded_with: VCR 6.2.0
|