deepl-rb 2.2.1 → 2.5.3

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 (66) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +1 -13
  3. data/.rubocop.yml +8 -4
  4. data/Gemfile +6 -0
  5. data/README.md +133 -25
  6. data/Rakefile +2 -0
  7. data/VERSION +1 -1
  8. data/deepl-rb.gemspec +38 -10
  9. data/lib/deepl/api.rb +2 -0
  10. data/lib/deepl/configuration.rb +4 -2
  11. data/lib/deepl/exceptions/authorization_failed.rb +2 -0
  12. data/lib/deepl/exceptions/bad_request.rb +4 -0
  13. data/lib/deepl/exceptions/error.rb +2 -0
  14. data/lib/deepl/exceptions/limit_exceeded.rb +2 -0
  15. data/lib/deepl/exceptions/not_found.rb +13 -0
  16. data/lib/deepl/exceptions/not_supported.rb +11 -0
  17. data/lib/deepl/exceptions/quota_exceeded.rb +2 -0
  18. data/lib/deepl/exceptions/request_entity_too_large.rb +12 -0
  19. data/lib/deepl/exceptions/request_error.rb +4 -1
  20. data/lib/deepl/glossary_api.rb +35 -0
  21. data/lib/deepl/requests/base.rb +23 -11
  22. data/lib/deepl/requests/glossary/create.rb +45 -0
  23. data/lib/deepl/requests/glossary/destroy.rb +30 -0
  24. data/lib/deepl/requests/glossary/entries.rb +30 -0
  25. data/lib/deepl/requests/glossary/find.rb +31 -0
  26. data/lib/deepl/requests/glossary/language_pairs.rb +31 -0
  27. data/lib/deepl/requests/glossary/list.rb +30 -0
  28. data/lib/deepl/requests/languages.rb +30 -0
  29. data/lib/deepl/requests/translate.rb +8 -2
  30. data/lib/deepl/requests/usage.rb +2 -0
  31. data/lib/deepl/resources/base.rb +2 -0
  32. data/lib/deepl/resources/glossary.rb +25 -0
  33. data/lib/deepl/resources/language.rb +27 -0
  34. data/lib/deepl/resources/language_pair.rb +20 -0
  35. data/lib/deepl/resources/text.rb +2 -0
  36. data/lib/deepl/resources/usage.rb +2 -0
  37. data/lib/deepl/utils/exception_builder.rb +29 -0
  38. data/lib/deepl.rb +28 -0
  39. data/spec/api/api_spec.rb +2 -0
  40. data/spec/api/configuration_spec.rb +4 -2
  41. data/spec/api/deepl_spec.rb +213 -0
  42. data/spec/fixtures/vcr_cassettes/deepl_glossaries.yml +374 -0
  43. data/spec/fixtures/vcr_cassettes/deepl_languages.yml +43 -0
  44. data/spec/fixtures/vcr_cassettes/deepl_translate.yml +215 -5
  45. data/spec/fixtures/vcr_cassettes/deepl_usage.yml +12 -7
  46. data/spec/fixtures/vcr_cassettes/glossaries.yml +480 -0
  47. data/spec/fixtures/vcr_cassettes/languages.yml +114 -0
  48. data/spec/fixtures/vcr_cassettes/translate_texts.yml +199 -33
  49. data/spec/fixtures/vcr_cassettes/usage.yml +12 -7
  50. data/spec/requests/glossary/create_spec.rb +55 -0
  51. data/spec/requests/glossary/destroy_spec.rb +50 -0
  52. data/spec/requests/glossary/entries_spec.rb +48 -0
  53. data/spec/requests/glossary/find_spec.rb +54 -0
  54. data/spec/requests/glossary/language_pairs_spec.rb +30 -0
  55. data/spec/requests/glossary/list_spec.rb +44 -0
  56. data/spec/requests/languages_spec.rb +58 -0
  57. data/spec/requests/translate_spec.rb +139 -4
  58. data/spec/requests/usage_spec.rb +2 -0
  59. data/spec/resources/glossary_spec.rb +35 -0
  60. data/spec/resources/language_pair_spec.rb +20 -0
  61. data/spec/resources/language_spec.rb +42 -0
  62. data/spec/resources/text_spec.rb +4 -2
  63. data/spec/resources/usage_spec.rb +5 -3
  64. data/spec/spec_helper.rb +6 -4
  65. metadata +49 -8
  66. data/Gemfile.lock +0 -113
@@ -2,11 +2,13 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: https://api.deepl.com/v2/translate?auth_key=VALID_TOKEN&param=fake
5
+ uri: https://api-free.deepl.com/v2/translate?param=fake
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: text=Sample&source_lang=EN&target_lang=ES
9
9
  headers:
10
+ Authorization:
11
+ - DeepL-Auth-Key VALID_TOKEN
10
12
  Accept-Encoding:
11
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
14
  Accept:
@@ -23,7 +25,7 @@ http_interactions:
23
25
  Server:
24
26
  - nginx
25
27
  Date:
26
- - Tue, 08 May 2018 16:31:34 GMT
28
+ - Mon, 17 May 2021 14:42:56 GMT
27
29
  Content-Type:
28
30
  - application/json
29
31
  Content-Length:
@@ -35,6 +37,214 @@ http_interactions:
35
37
  body:
36
38
  encoding: UTF-8
37
39
  string: '{"translations":[{"detected_source_language":"EN","text":"Muestra"}]}'
38
- http_version:
39
- recorded_at: Tue, 08 May 2018 16:31:33 GMT
40
- recorded_with: VCR 4.0.0
40
+ recorded_at: Mon, 17 May 2021 14:42:56 GMT
41
+ - request:
42
+ method: post
43
+ uri: https://api-free.deepl.com/v2/glossaries
44
+ body:
45
+ encoding: US-ASCII
46
+ string: name=fixture&source_lang=EN&target_lang=ES&entries=World%09Tierra%0A&entries_format=tsv
47
+ headers:
48
+ Authorization:
49
+ - DeepL-Auth-Key VALID_TOKEN
50
+ Accept-Encoding:
51
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
52
+ Accept:
53
+ - "*/*"
54
+ User-Agent:
55
+ - Ruby
56
+ Content-Type:
57
+ - application/x-www-form-urlencoded
58
+ response:
59
+ status:
60
+ code: 201
61
+ message: Created
62
+ headers:
63
+ Server:
64
+ - nginx
65
+ Date:
66
+ - Mon, 24 Jan 2022 23:22:45 GMT
67
+ Content-Type:
68
+ - application/json; charset=utf-8
69
+ Transfer-Encoding:
70
+ - chunked
71
+ Connection:
72
+ - keep-alive
73
+ body:
74
+ encoding: UTF-8
75
+ string: '{"glossary_id":"c8ec9224-f13c-4af5-94eb-25e2d6112d34","name":"fixture","ready":true,"source_lang":"en","target_lang":"es","creation_time":"2022-01-24T23:22:45.4428+00:00","entry_count":1}'
76
+ recorded_at: Mon, 24 Jan 2022 23:22:45 GMT
77
+ - request:
78
+ method: post
79
+ uri: https://api-free.deepl.com/v2/translate?glossary_id=c8ec9224-f13c-4af5-94eb-25e2d6112d34
80
+ body:
81
+ encoding: US-ASCII
82
+ string: text=Hello+World&source_lang=EN&target_lang=ES
83
+ headers:
84
+ Authorization:
85
+ - DeepL-Auth-Key VALID_TOKEN
86
+ Accept-Encoding:
87
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
88
+ Accept:
89
+ - "*/*"
90
+ User-Agent:
91
+ - Ruby
92
+ Content-Type:
93
+ - application/x-www-form-urlencoded
94
+ response:
95
+ status:
96
+ code: 200
97
+ message: OK
98
+ headers:
99
+ Server:
100
+ - nginx
101
+ Date:
102
+ - Mon, 24 Jan 2022 23:22:47 GMT
103
+ Content-Type:
104
+ - application/json
105
+ Content-Length:
106
+ - '73'
107
+ Connection:
108
+ - keep-alive
109
+ Access-Control-Allow-Origin:
110
+ - "*"
111
+ body:
112
+ encoding: UTF-8
113
+ string: '{"translations":[{"detected_source_language":"EN","text":"Hola Tierra"}]}'
114
+ recorded_at: Mon, 24 Jan 2022 23:22:47 GMT
115
+ - request:
116
+ method: delete
117
+ uri: https://api-free.deepl.com/v2/glossaries/c8ec9224-f13c-4af5-94eb-25e2d6112d34
118
+ body:
119
+ encoding: US-ASCII
120
+ string: ''
121
+ headers:
122
+ Authorization:
123
+ - DeepL-Auth-Key VALID_TOKEN
124
+ Accept-Encoding:
125
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
126
+ Accept:
127
+ - "*/*"
128
+ User-Agent:
129
+ - Ruby
130
+ response:
131
+ status:
132
+ code: 204
133
+ message: No Content
134
+ headers:
135
+ Server:
136
+ - nginx
137
+ Date:
138
+ - Mon, 24 Jan 2022 23:22:48 GMT
139
+ Connection:
140
+ - keep-alive
141
+ body:
142
+ encoding: UTF-8
143
+ string: ''
144
+ recorded_at: Mon, 24 Jan 2022 23:22:48 GMT
145
+ - request:
146
+ method: post
147
+ uri: https://api-free.deepl.com/v2/glossaries
148
+ body:
149
+ encoding: US-ASCII
150
+ string: name=fixture&source_lang=EN&target_lang=ES&entries=car%09auto%0A&entries_format=tsv
151
+ headers:
152
+ Authorization:
153
+ - DeepL-Auth-Key VALID_TOKEN
154
+ Accept-Encoding:
155
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
156
+ Accept:
157
+ - "*/*"
158
+ User-Agent:
159
+ - Ruby
160
+ Content-Type:
161
+ - application/x-www-form-urlencoded
162
+ response:
163
+ status:
164
+ code: 201
165
+ message: Created
166
+ headers:
167
+ Server:
168
+ - nginx
169
+ Date:
170
+ - Tue, 25 Jan 2022 00:52:04 GMT
171
+ Content-Type:
172
+ - application/json; charset=utf-8
173
+ Transfer-Encoding:
174
+ - chunked
175
+ Connection:
176
+ - keep-alive
177
+ body:
178
+ encoding: UTF-8
179
+ string: '{"glossary_id":"0d425d16-dbdf-4d26-aca1-12d41e9ea484","name":"fixture","ready":true,"source_lang":"en","target_lang":"es","creation_time":"2022-01-25T00:52:04.21883+00:00","entry_count":1}'
180
+ recorded_at: Tue, 25 Jan 2022 00:52:04 GMT
181
+ - request:
182
+ method: post
183
+ uri: https://api-free.deepl.com/v2/translate?glossary_id=0d425d16-dbdf-4d26-aca1-12d41e9ea484
184
+ body:
185
+ encoding: US-ASCII
186
+ string: text=I+wish+we+had+a+car.&source_lang=EN&target_lang=ES
187
+ headers:
188
+ Authorization:
189
+ - DeepL-Auth-Key VALID_TOKEN
190
+ Accept-Encoding:
191
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
192
+ Accept:
193
+ - "*/*"
194
+ User-Agent:
195
+ - Ruby
196
+ Content-Type:
197
+ - application/x-www-form-urlencoded
198
+ response:
199
+ status:
200
+ code: 200
201
+ message: OK
202
+ headers:
203
+ Server:
204
+ - nginx
205
+ Date:
206
+ - Tue, 25 Jan 2022 00:52:04 GMT
207
+ Content-Type:
208
+ - application/json
209
+ Content-Length:
210
+ - '89'
211
+ Connection:
212
+ - keep-alive
213
+ Access-Control-Allow-Origin:
214
+ - "*"
215
+ body:
216
+ encoding: ASCII-8BIT
217
+ string: !binary |-
218
+ eyJ0cmFuc2xhdGlvbnMiOlt7ImRldGVjdGVkX3NvdXJjZV9sYW5ndWFnZSI6IkVOIiwidGV4dCI6Ik9qYWzDoSB0dXZpw6lyYW1vcyB1biBhdXRvLiJ9XX0=
219
+ recorded_at: Tue, 25 Jan 2022 00:52:04 GMT
220
+ - request:
221
+ method: delete
222
+ uri: https://api-free.deepl.com/v2/glossaries/0d425d16-dbdf-4d26-aca1-12d41e9ea484
223
+ body:
224
+ encoding: US-ASCII
225
+ string: ''
226
+ headers:
227
+ Authorization:
228
+ - DeepL-Auth-Key VALID_TOKEN
229
+ Accept-Encoding:
230
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
231
+ Accept:
232
+ - "*/*"
233
+ User-Agent:
234
+ - Ruby
235
+ response:
236
+ status:
237
+ code: 204
238
+ message: No Content
239
+ headers:
240
+ Server:
241
+ - nginx
242
+ Date:
243
+ - Tue, 25 Jan 2022 00:52:05 GMT
244
+ Connection:
245
+ - keep-alive
246
+ body:
247
+ encoding: UTF-8
248
+ string: ''
249
+ recorded_at: Tue, 25 Jan 2022 00:52:05 GMT
250
+ recorded_with: VCR 6.0.0
@@ -2,11 +2,13 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.deepl.com/v2/usage?auth_key=VALID_TOKEN
5
+ uri: https://api-free.deepl.com/v2/usage
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
+ Authorization:
11
+ - DeepL-Auth-Key VALID_TOKEN
10
12
  Accept-Encoding:
11
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
14
  Accept:
@@ -21,14 +23,17 @@ http_interactions:
21
23
  Server:
22
24
  - nginx
23
25
  Date:
24
- - Tue, 08 May 2018 16:31:35 GMT
26
+ - Mon, 17 May 2021 14:18:28 GMT
27
+ Content-Type:
28
+ - application/json
25
29
  Content-Length:
26
- - '52'
30
+ - '48'
27
31
  Connection:
28
32
  - keep-alive
33
+ Access-Control-Allow-Origin:
34
+ - "*"
29
35
  body:
30
36
  encoding: UTF-8
31
- string: '{"character_count":802127,"character_limit":1000000}'
32
- http_version:
33
- recorded_at: Tue, 08 May 2018 16:31:33 GMT
34
- recorded_with: VCR 4.0.0
37
+ string: '{"character_count":303,"character_limit":500000}'
38
+ recorded_at: Mon, 17 May 2021 14:18:28 GMT
39
+ recorded_with: VCR 6.0.0