phrase 2.15.0 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile +1 -0
  4. data/README.md +13 -3
  5. data/docs/FigmaAttachment.md +23 -0
  6. data/docs/FigmaAttachmentCreateParameters.md +19 -0
  7. data/docs/FigmaAttachmentUpdateParameters.md +19 -0
  8. data/docs/FigmaAttachmentsApi.md +341 -0
  9. data/docs/KeysFigmaAttachmentsApi.md +142 -0
  10. data/docs/LocalesApi.md +8 -8
  11. data/docs/TranslationsApi.md +2 -2
  12. data/docs/UploadCreateParameters.md +3 -1
  13. data/docs/UploadsApi.md +3 -1
  14. data/lib/phrase/api/figma_attachments_api.rb +393 -0
  15. data/lib/phrase/api/keys_figma_attachments_api.rb +168 -0
  16. data/lib/phrase/api/locales_api.rb +8 -8
  17. data/lib/phrase/api/translations_api.rb +2 -2
  18. data/lib/phrase/api/uploads_api.rb +3 -0
  19. data/lib/phrase/models/figma_attachment.rb +221 -0
  20. data/lib/phrase/models/figma_attachment_create_parameters.rb +205 -0
  21. data/lib/phrase/models/figma_attachment_update_parameters.rb +205 -0
  22. data/lib/phrase/models/upload_create_parameters.rb +16 -4
  23. data/lib/phrase/version.rb +1 -1
  24. data/lib/phrase.rb +5 -0
  25. data/spec/api/figma_attachments_api_spec.rb +100 -0
  26. data/spec/api/keys_figma_attachments_api_spec.rb +55 -0
  27. data/spec/api/locales_api_spec.rb +112 -8
  28. data/spec/api/translations_api_spec.rb +1 -1
  29. data/spec/api/uploads_api_spec.rb +16 -1
  30. data/spec/models/figma_attachment_create_parameters_spec.rb +35 -0
  31. data/spec/models/figma_attachment_spec.rb +47 -0
  32. data/spec/models/figma_attachment_update_parameters_spec.rb +35 -0
  33. data/spec/models/upload_create_parameters_spec.rb +6 -0
  34. data/spec/spec_helper.rb +1 -0
  35. metadata +239 -219
@@ -39,7 +39,7 @@ describe 'LocalesApi' do
39
39
  # Create a locale
40
40
  # Create a new locale.
41
41
  # @param project_id Project ID
42
- # @param locale_create_parameters
42
+ # @param locale_create_parameters
43
43
  # @param [Hash] opts the optional parameters
44
44
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
45
45
  # @return [LocaleDetails]
@@ -53,7 +53,7 @@ describe 'LocalesApi' do
53
53
  # Delete a locale
54
54
  # Delete an existing locale.
55
55
  # @param project_id Project ID
56
- # @param id ID
56
+ # @param id Locale ID or locale name
57
57
  # @param [Hash] opts the optional parameters
58
58
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
59
59
  # @option opts [String] :branch specify the branch to use
@@ -68,7 +68,7 @@ describe 'LocalesApi' do
68
68
  # Download a locale
69
69
  # Download a locale in a specific file format.
70
70
  # @param project_id Project ID
71
- # @param id ID
71
+ # @param id Locale ID or locale name
72
72
  # @param [Hash] opts the optional parameters
73
73
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
74
74
  # @option opts [String] :if_modified_since Last modified condition, see <a href=\"#overview--conditional-get-requests--http-caching\">Conditional GET requests / HTTP Caching</a> (optional)
@@ -91,8 +91,28 @@ describe 'LocalesApi' do
91
91
  # @option opts [String] :source_locale_id Provides the source language of a corresponding job as the source language of the generated locale file. This parameter will be ignored unless used in combination with a <code>tag</code> parameter indicating a specific job.
92
92
  # @return [File]
93
93
  describe 'locale_download test' do
94
+ let(:project_id) { 'project_id_example' }
95
+ let(:id) { 'id_example' }
96
+ let(:opts) { {
97
+ branch: 'branch_example',
98
+ format_options: {foo: 'bar'},
99
+ } }
100
+
101
+ before do
102
+ stub_request(:any, /.*phrase.com/)
103
+ .to_return(status: 200, body: "foo", headers: {
104
+ 'Content-Type' => 'application/octet-stream',
105
+ 'Content-Disposition' => 'attachment; filename="test.txt"',
106
+ })
107
+ end
108
+
94
109
  it 'should work' do
95
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
110
+ locale = @api_instance.locale_download(project_id, id, opts)
111
+ expect(a_request(:get, "https://api.phrase.com/v2/projects/project_id_example/locales/id_example/download").with(query: {branch: "branch_example", format_options: {foo: "bar"}})).
112
+ to have_been_made
113
+
114
+ expect(locale).to be_instance_of(Phrase::Response)
115
+ expect(File.read(locale.data)).to eq("foo")
96
116
  end
97
117
  end
98
118
 
@@ -100,7 +120,7 @@ describe 'LocalesApi' do
100
120
  # Get a single locale
101
121
  # Get details on a single locale for a given project.
102
122
  # @param project_id Project ID
103
- # @param id ID
123
+ # @param id Locale ID or locale name
104
124
  # @param [Hash] opts the optional parameters
105
125
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
106
126
  # @option opts [String] :branch specify the branch to use
@@ -115,8 +135,8 @@ describe 'LocalesApi' do
115
135
  # Update a locale
116
136
  # Update an existing locale.
117
137
  # @param project_id Project ID
118
- # @param id ID
119
- # @param locale_update_parameters
138
+ # @param id Locale ID or locale name
139
+ # @param locale_update_parameters
120
140
  # @param [Hash] opts the optional parameters
121
141
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
122
142
  # @return [LocaleDetails]
@@ -138,8 +158,92 @@ describe 'LocalesApi' do
138
158
  # @option opts [String] :branch specify the branch to use
139
159
  # @return [Array<Locale>]
140
160
  describe 'locales_list test' do
161
+ let(:project_id) { 'project_id_example' }
162
+ let(:opts) { {
163
+ branch: 'branch_example',
164
+ } }
165
+ let(:response_body) {
166
+ <<-EOF
167
+ [
168
+ {
169
+ "id": "ae0ce77b64dbf7e8315b5da8ecbb42c0",
170
+ "name": "de-DE",
171
+ "code": "de-DE",
172
+ "default": false,
173
+ "main": false,
174
+ "rtl": false,
175
+ "plural_forms": [
176
+ "zero",
177
+ "one",
178
+ "other"
179
+ ],
180
+ "created_at": "2022-10-27T11:03:39Z",
181
+ "updated_at": "2023-10-05T09:49:28Z",
182
+ "source_locale": null,
183
+ "fallback_locale": null
184
+ },
185
+ {
186
+ "id": "95060c3b178252e0c5d1936493e93108",
187
+ "name": "en-US",
188
+ "code": "en-US",
189
+ "default": true,
190
+ "main": false,
191
+ "rtl": false,
192
+ "plural_forms": [
193
+ "zero",
194
+ "one",
195
+ "other"
196
+ ],
197
+ "created_at": "2022-10-27T11:03:39Z",
198
+ "updated_at": "2023-10-05T09:50:20Z",
199
+ "source_locale": null,
200
+ "fallback_locale": null
201
+ },
202
+ {
203
+ "id": "97b4b258d9000f256a97276561294b5b",
204
+ "name": "sh",
205
+ "code": "sr-Latn-RS",
206
+ "default": false,
207
+ "main": false,
208
+ "rtl": false,
209
+ "plural_forms": [
210
+ "zero",
211
+ "one",
212
+ "few",
213
+ "other"
214
+ ],
215
+ "created_at": "2022-10-27T11:03:39Z",
216
+ "updated_at": "2023-05-10T08:22:18Z",
217
+ "source_locale": null,
218
+ "fallback_locale": null
219
+ }
220
+ ]
221
+ EOF
222
+ }
223
+
224
+ before do
225
+ stub_request(:any, /.*phrase.com/)
226
+ .to_return(status: 200, body: response_body, headers: {
227
+ 'Content-Type' => 'application/json'
228
+ })
229
+ end
230
+
141
231
  it 'should work' do
142
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
232
+ locales = @api_instance.locales_list(project_id, opts)
233
+ expect(a_request(:get, "https://api.phrase.com/v2/projects/project_id_example/locales").with(query: {branch: "branch_example"})).
234
+ to have_been_made
235
+
236
+ expect(locales).to be_instance_of(Phrase::Response)
237
+ expect(locales.data).to be_instance_of(Array)
238
+ expect(locales.data.length).to eq(3)
239
+ expect(locales.data[0]).to be_instance_of(Phrase::Locale)
240
+ expect(locales.data[0].id).to eq("ae0ce77b64dbf7e8315b5da8ecbb42c0")
241
+ expect(locales.data[0].name).to eq("de-DE")
242
+ expect(locales.data[0].code).to eq("de-DE")
243
+ expect(locales.data[0].default).to eq(false)
244
+ expect(locales.data[0].plural_forms).to eq(["zero", "one", "other"])
245
+ expect(locales.data[0].created_at).to eq(DateTime.parse("2022-10-27T11:03:39Z"))
246
+ expect(locales.data[0].updated_at).to eq(DateTime.parse("2023-10-05T09:49:28Z"))
143
247
  end
144
248
  end
145
249
 
@@ -220,7 +220,7 @@ describe 'TranslationsApi' do
220
220
  # @option opts [String] :branch specify the branch to use
221
221
  # @option opts [String] :sort Sort criteria. Can be one of: key_name, created_at, updated_at.
222
222
  # @option opts [String] :order Order direction. Can be one of: asc, desc.
223
- # @option opts [String] :q Specify a query to find translations by content (including wildcards).&lt;br&gt;&lt;br&gt; &lt;i&gt;Note: Search is limited to 10000 results and may not include recently updated data (depending on the project size).&lt;/i&gt;&lt;br&gt; The following qualifiers are supported in the query:&lt;br&gt; &lt;ul&gt; &lt;li&gt;&lt;code&gt;id:translation_id,...&lt;/code&gt; for queries on a comma-separated list of ids&lt;/li&gt; &lt;li&gt;&lt;code&gt;tags:XYZ&lt;/code&gt; for tags on the translation&lt;/li&gt; &lt;li&gt;&lt;code&gt;unverified:{true|false}&lt;/code&gt; for verification status&lt;/li&gt; &lt;li&gt;&lt;code&gt;excluded:{true|false}&lt;/code&gt; for exclusion status&lt;/li&gt; &lt;li&gt;&lt;code&gt;updated_at:{&gt;&#x3D;|&lt;&#x3D;}2013-02-21T00:00:00Z&lt;/code&gt; for date range queries&lt;/li&gt; &lt;/ul&gt; Find more examples &lt;a href&#x3D;\&quot;#overview--usage-examples\&quot;&gt;here&lt;/a&gt;.
223
+ # @option opts [String] :q Specify a query to find translations by content (including wildcards).&lt;br&gt;&lt;br&gt; &lt;i&gt;Note: Search is limited to 10000 results and may not include recently updated data (depending on the project size).&lt;/i&gt;&lt;br&gt; The following qualifiers are supported in the query:&lt;br&gt; &lt;ul&gt; &lt;li&gt;&lt;code&gt;id:translation_id,...&lt;/code&gt; for queries on a comma-separated list of ids&lt;/li&gt; &lt;li&gt;&lt;code&gt;tags:XYZ&lt;/code&gt; for tags on the translation&lt;/li&gt; &lt;li&gt;&lt;code&gt;unverified:{true|false}&lt;/code&gt; for verification status&lt;/li&gt; &lt;li&gt;&lt;code&gt;excluded:{true|false}&lt;/code&gt; for exclusion status&lt;/li&gt; &lt;li&gt;&lt;code&gt;updated_at:{&gt;&#x3D;|&lt;&#x3D;}2013-02-21T00:00:00Z&lt;/code&gt; for date range queries&lt;/li&gt; &lt;li&gt;&lt;code&gt;reviewed_after:2013-02-21T00:00:00Z&lt;/code&gt; for fetching translations that were reviewed after the given timestamp&lt;/li&gt; &lt;/ul&gt; Find more examples &lt;a href&#x3D;\&quot;#overview--usage-examples\&quot;&gt;here&lt;/a&gt;.
224
224
  # @return [Array<Translation>]
225
225
  describe 'translations_list test' do
226
226
  it 'should work' do
@@ -41,10 +41,25 @@ describe 'UploadsApi' do
41
41
  # @option opts [Object] :format_options Additional options available for specific formats. See our format guide for complete list.
42
42
  # @option opts [Boolean] :autotranslate If set, translations for the uploaded language will be fetched automatically.
43
43
  # @option opts [Boolean] :mark_reviewed Indicated whether the imported translations should be marked as reviewed. This setting is available if the review workflow is enabled for the project.
44
+ # @option opts [Boolean] :tag_only_affected_keys Indicates whether only keys affected (created or updated) by the upload should be tagged. The default is &#x60;false&#x60;
44
45
  # @return [Upload]
45
46
  describe 'upload_create test' do
47
+ let(:response_body) { { data: {} }.to_json }
48
+ before do
49
+ stub_request(:any, /.*phrase.com/)
50
+ .to_return(status: 200, body: response_body, headers: {
51
+ 'Content-Type' => 'application/json'
52
+ })
53
+ end
54
+
46
55
  it 'should work' do
47
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
+ @api_instance.upload_create('project_id', file: File.new('Gemfile'))
57
+
58
+ expect(a_request(:post, 'https://api.phrase.com/v2/projects/project_id/uploads')
59
+ .with { |req|
60
+ expect(req.headers['Content-Type']).to eq('multipart/form-data')
61
+ # expect(req.body).to include('Gemfile')
62
+ }).to have_been_made
48
63
  end
49
64
  end
50
65
 
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+ require 'date'
4
+
5
+ # Unit tests for Phrase::FigmaAttachmentCreateParameters
6
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
7
+ # Please update as you see appropriate
8
+ describe 'FigmaAttachmentCreateParameters' do
9
+ before do
10
+ # run before each test
11
+ @instance = Phrase::FigmaAttachmentCreateParameters.new
12
+ end
13
+
14
+ after do
15
+ # run after each test
16
+ end
17
+
18
+ describe 'test an instance of FigmaAttachmentCreateParameters' do
19
+ it 'should create an instance of FigmaAttachmentCreateParameters' do
20
+ expect(@instance).to be_instance_of(Phrase::FigmaAttachmentCreateParameters)
21
+ end
22
+ end
23
+ describe 'test attribute "branch"' do
24
+ it 'should work' do
25
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
26
+ end
27
+ end
28
+
29
+ describe 'test attribute "url"' do
30
+ it 'should work' do
31
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+ require 'date'
4
+
5
+ # Unit tests for Phrase::FigmaAttachment
6
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
7
+ # Please update as you see appropriate
8
+ describe 'FigmaAttachment' do
9
+ before do
10
+ # run before each test
11
+ @instance = Phrase::FigmaAttachment.new
12
+ end
13
+
14
+ after do
15
+ # run after each test
16
+ end
17
+
18
+ describe 'test an instance of FigmaAttachment' do
19
+ it 'should create an instance of FigmaAttachment' do
20
+ expect(@instance).to be_instance_of(Phrase::FigmaAttachment)
21
+ end
22
+ end
23
+ describe 'test attribute "id"' do
24
+ it 'should work' do
25
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
26
+ end
27
+ end
28
+
29
+ describe 'test attribute "url"' do
30
+ it 'should work' do
31
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
32
+ end
33
+ end
34
+
35
+ describe 'test attribute "created_at"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ describe 'test attribute "updated_at"' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+ require 'date'
4
+
5
+ # Unit tests for Phrase::FigmaAttachmentUpdateParameters
6
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
7
+ # Please update as you see appropriate
8
+ describe 'FigmaAttachmentUpdateParameters' do
9
+ before do
10
+ # run before each test
11
+ @instance = Phrase::FigmaAttachmentUpdateParameters.new
12
+ end
13
+
14
+ after do
15
+ # run after each test
16
+ end
17
+
18
+ describe 'test an instance of FigmaAttachmentUpdateParameters' do
19
+ it 'should create an instance of FigmaAttachmentUpdateParameters' do
20
+ expect(@instance).to be_instance_of(Phrase::FigmaAttachmentUpdateParameters)
21
+ end
22
+ end
23
+ describe 'test attribute "branch"' do
24
+ it 'should work' do
25
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
26
+ end
27
+ end
28
+
29
+ describe 'test attribute "url"' do
30
+ it 'should work' do
31
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
32
+ end
33
+ end
34
+
35
+ end
@@ -110,4 +110,10 @@ describe 'UploadCreateParameters' do
110
110
  end
111
111
  end
112
112
 
113
+ describe 'test attribute "tag_only_affected_keys"' do
114
+ it 'should work' do
115
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
116
+ end
117
+ end
118
+
113
119
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # load the gem
2
2
  require 'phrase'
3
+ require 'webmock/rspec'
3
4
 
4
5
  # The following was generated by the `rspec --init` command. Conventionally, all
5
6
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.