crowdin-api 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22ed7c31fb89ca5299a07d1fe3c828f7686e36d74ad710dc5e1b115598f90fe7
4
- data.tar.gz: fd8069c348ff758595bbc18a3f8684f6d220b1a53d00fac2fc0af0751b213087
3
+ metadata.gz: 9cd5b2539130f20d40ab8eae20e4291675e8b58c27883fd7ce59323492ad4daa
4
+ data.tar.gz: 699e9cc4411451da663e4bb59abb4a641c8dad98c9bb82dac475e11882facc59
5
5
  SHA512:
6
- metadata.gz: 6014441ccc9d7c0a1e6a11e20611ee686cff396da2d596c12a1293d701f0395d5ff4adc730098301b4563f3167e5d7af54d15579e401578f822dadeb65066101
7
- data.tar.gz: afa63e70a5616430e750429bb5b99e4d30e89ae92bbec440eb3fa2e5b7fbeb1319ff4c4947812ae8878597cd7850725f58018c094aa6d0ea2a02230b0ed8e799
6
+ metadata.gz: e80a6940f20de8d1e70d4edbec95d468137ae5b9b4979ed005e920c6e5fe2e9d794ed5dfe43120766c0e3d9a2e9e7aaa2d8c1abfbfd1c566c19b688d3a494224
7
+ data.tar.gz: 62102d71575df111fbeed6f28fba6b7a91d66fc2835174df83ca51138df0fc3b242937363f55f07d8d1b046fb405179bd6c953e3732cdc39f05c4dbfb057e19f
@@ -24,6 +24,6 @@ jobs:
24
24
  permissions:
25
25
  contents: write
26
26
  steps:
27
- - uses: peter-evans/repository-dispatch@v2
27
+ - uses: peter-evans/repository-dispatch@v3
28
28
  with:
29
29
  event-type: publish
data/.rubocop.yml CHANGED
@@ -6,3 +6,7 @@ AllCops:
6
6
 
7
7
  Gemspec/DevelopmentDependencies:
8
8
  Enabled: false
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - 'spec/**/*'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crowdin-api (1.11.0)
4
+ crowdin-api (1.12.0)
5
5
  open-uri (>= 0.1.0, < 0.2.0)
6
6
  rest-client (>= 2.0.0, < 2.2.0)
7
7
 
data/README.md CHANGED
@@ -35,7 +35,7 @@ Crowdin API is a full-featured RESTful API that helps you to integrate localizat
35
35
  Add this line to your application's Gemfile:
36
36
 
37
37
  ```gemfile
38
- gem 'crowdin-api', '~> 1.11.0'
38
+ gem 'crowdin-api', '~> 1.12.0'
39
39
  ```
40
40
 
41
41
  And then execute:
@@ -73,6 +73,89 @@ module Crowdin
73
73
  Web::SendRequest.new(request).perform
74
74
  end
75
75
 
76
+ # @param project_id [Integer] Project ID
77
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.strings-exporter-settings.getMany API Documentation}
78
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.strings-exporter-settings.getMany Enterprise API Documentation}
79
+ def list_project_strings_exporter_settings(project_id = nil)
80
+ project_id || raise_parameter_is_required_error(:project_id)
81
+
82
+ request = Web::Request.new(
83
+ connection,
84
+ :get,
85
+ "#{config.target_api_url}/projects/#{project_id}/strings-exporter-settings"
86
+ )
87
+ Web::SendRequest.new(request).perform
88
+ end
89
+
90
+ # @param project_id [Integer] Project ID
91
+ # @param query [Hash] Request Body
92
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.strings-exporter-settings.post API Documentation}
93
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.strings-exporter-settings.post Enterprise API Documentation}
94
+ def add_project_strings_exporter_settings(project_id = nil, query = {})
95
+ project_id || raise_parameter_is_required_error(:project_id)
96
+
97
+ request = Web::Request.new(
98
+ connection,
99
+ :post,
100
+ "#{config.target_api_url}/projects/#{project_id}/strings-exporter-settings",
101
+ { params: query }
102
+ )
103
+ Web::SendRequest.new(request).perform
104
+ end
105
+
106
+ # @param project_id [Integer] Project ID
107
+ # @param system_strings_exporter_settings_id [Integer] Request Body
108
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.strings-exporter-settings.get API Documentation}
109
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.strings-exporter-settings.get Enterprise API Documentation}
110
+ def get_project_strings_exporter_settings(project_id = nil, system_strings_exporter_settings_id = nil)
111
+ project_id || raise_parameter_is_required_error(:project_id)
112
+ system_strings_exporter_settings_id || raise_parameter_is_required_error(:system_strings_exporter_settings_id)
113
+
114
+ path = "projects/#{project_id}/strings-exporter-settings/#{system_strings_exporter_settings_id}"
115
+ request = Web::Request.new(
116
+ connection,
117
+ :get,
118
+ "#{config.target_api_url}/#{path}"
119
+ )
120
+ Web::SendRequest.new(request).perform
121
+ end
122
+
123
+ # @param project_id [Integer] Project ID
124
+ # @param system_strings_exporter_settings_id [Integer] Request Body
125
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.strings-exporter-settings.delete API Documentation}
126
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.strings-exporter-settings.delete Enterprise API Documentation}
127
+ def delete_project_strings_exporter_settings(project_id = nil, system_strings_exporter_settings_id = nil)
128
+ project_id || raise_parameter_is_required_error(:project_id)
129
+ system_strings_exporter_settings_id || raise_parameter_is_required_error(:system_strings_exporter_settings_id)
130
+
131
+ path = "projects/#{project_id}/strings-exporter-settings/#{system_strings_exporter_settings_id}"
132
+ request = Web::Request.new(
133
+ connection,
134
+ :delete,
135
+ "#{config.target_api_url}/#{path}"
136
+ )
137
+ Web::SendRequest.new(request).perform
138
+ end
139
+
140
+ # @param project_id [Integer] Project ID
141
+ # @param system_strings_exporter_settings_id [Integer] Request Body
142
+ # @param query [Hash] Request Body
143
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.strings-exporter-settings.patch API Documentation}
144
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.strings-exporter-settings.patch Enterprise API Documentation}
145
+ def edit_project_strings_exporter_settings(project_id = nil, system_strings_exporter_settings_id = nil, query = {})
146
+ project_id || raise_parameter_is_required_error(:project_id)
147
+ system_strings_exporter_settings_id || raise_parameter_is_required_error(:system_strings_exporter_settings_id)
148
+
149
+ path = "projects/#{project_id}/strings-exporter-settings/#{system_strings_exporter_settings_id}"
150
+ request = Web::Request.new(
151
+ connection,
152
+ :patch,
153
+ "#{config.target_api_url}/#{path}",
154
+ params: query
155
+ )
156
+ Web::SendRequest.new(request).perform
157
+ end
158
+
76
159
  # -- For Enterprise mode only --
77
160
 
78
161
  # @param query [Hash] Request Body
@@ -267,6 +267,22 @@ module Crowdin
267
267
  Web::SendRequest.new(request, destination).perform
268
268
  end
269
269
 
270
+ # @param file_id [Integer] File ID
271
+ # @param destination [String] Destination of File
272
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.preview.get API Documentation}
273
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.preview.get Enterprise API Documentation}
274
+ def download_file_preview(file_id = nil, destination = nil, project_id = config.project_id)
275
+ file_id || raise_parameter_is_required_error(:file_id)
276
+ project_id || raise_project_id_is_required_error
277
+
278
+ request = Web::Request.new(
279
+ connection,
280
+ :get,
281
+ "#{config.target_api_url}/projects/#{project_id}/files/#{file_id}/preview"
282
+ )
283
+ Web::SendRequest.new(request, destination).perform
284
+ end
285
+
270
286
  # @param query [Hash] Request Body
271
287
  # @param file_id [Integer] File ID
272
288
  # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.revisions.getMany API Documentation}
@@ -51,6 +51,18 @@ module Crowdin
51
51
  Web::SendRequest.new(request).perform
52
52
  end
53
53
 
54
+ def remove_string_approvals(query = {}, project_id = config.project_id)
55
+ project_id || raise_project_id_is_required_error
56
+
57
+ request = Web::Request.new(
58
+ connection,
59
+ :delete,
60
+ "#{config.target_api_url}/projects/#{project_id}/approvals",
61
+ { params: query }
62
+ )
63
+ Web::SendRequest.new(request).perform
64
+ end
65
+
54
66
  def list_language_translations(language_id = nil, query = {}, project_id = config.project_id)
55
67
  language_id || raise_parameter_is_required_error(:language_id)
56
68
  project_id || raise_project_id_is_required_error
@@ -91,17 +103,13 @@ module Crowdin
91
103
  def delete_string_translations(query = {}, project_id = config.project_id)
92
104
  project_id || raise_project_id_is_required_error
93
105
 
94
- response = ::RestClient::Request.execute(
95
- {
96
- method: :delete,
97
- url: config.base_url + config.target_api_url + "/projects/#{project_id}/translations",
98
- payload: query.to_json
99
- }.merge(@options)
106
+ request = Web::Request.new(
107
+ connection,
108
+ :delete,
109
+ "#{config.target_api_url}/projects/#{project_id}/translations",
110
+ { params: query }
100
111
  )
101
-
102
- response.body.empty? ? response.code : JSON.parse(response.body)
103
- rescue StandardError => e
104
- e.message
112
+ Web::SendRequest.new(request).perform
105
113
  end
106
114
 
107
115
  def get_translation(translation_id = nil, query = {}, project_id = config.project_id)
@@ -27,6 +27,31 @@ module Crowdin
27
27
  Web::SendRequest.new(request).perform
28
28
  end
29
29
 
30
+ def list_pre_translations(query = {}, project_id = config.project_id)
31
+ project_id || raise_project_id_is_required_error
32
+
33
+ request = Web::Request.new(
34
+ connection,
35
+ :get,
36
+ "#{config.target_api_url}/projects/#{project_id}/pre-translations",
37
+ { params: query }
38
+ )
39
+ Web::SendRequest.new(request).perform
40
+ end
41
+
42
+ def edit_pre_translations(pre_translation_id = nil, query = {}, project_id = config.project_id)
43
+ pre_translation_id || raise_parameter_is_required_error(:pre_translation_id)
44
+ project_id || raise_project_id_is_required_error
45
+
46
+ request = Web::Request.new(
47
+ connection,
48
+ :patch,
49
+ "#{config.target_api_url}/projects/#{project_id}/pre-translations/#{pre_translation_id}",
50
+ { params: query }
51
+ )
52
+ Web::SendRequest.new(request).perform
53
+ end
54
+
30
55
  def build_project_directory_translation(directory_id = nil, query = {}, project_id = config.project_id)
31
56
  directory_id || raise_parameter_is_required_error(:directory_id)
32
57
  project_id || raise_project_id_is_required_error
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Crowdin
4
4
  class Client
5
- VERSION = '1.11.0'
5
+ VERSION = '1.12.0'
6
6
  end
7
7
  end
@@ -26,7 +26,7 @@ module Crowdin
26
26
  end
27
27
 
28
28
  def delete
29
- connection.delete
29
+ connection.delete(prepare_payload(payload[:params]))
30
30
  end
31
31
 
32
32
  def process_with_body
@@ -60,7 +60,7 @@ module Crowdin
60
60
  def prepare_payload(params)
61
61
  return params if params.is_a?(File)
62
62
 
63
- get? ? { params: fetch_cleared_params(params) } : fetch_cleared_params(params).to_json
63
+ get? || delete? ? { params: fetch_cleared_params(params) } : fetch_cleared_params(params).to_json
64
64
  end
65
65
 
66
66
  def fetch_cleared_params(params)
@@ -94,6 +94,117 @@ describe Crowdin::ApiResources::Projects do
94
94
  expect { @crowdin.edit_project }.to raise_error(ArgumentError)
95
95
  end
96
96
  end
97
+
98
+ describe '#list_project_strings_exporter_settings' do
99
+ let(:project_id) { 1 }
100
+
101
+ it 'when request are valid', :default do
102
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings-exporter-settings")
103
+ list_project_strings_exporter_settings = @crowdin.list_project_strings_exporter_settings(project_id)
104
+ expect(list_project_strings_exporter_settings).to eq(200)
105
+ end
106
+
107
+ it 'when the request is invalid', :default do
108
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings-exporter-settings")
109
+ expect { @crowdin.list_project_strings_exporter_settings }.to raise_error(ArgumentError)
110
+ end
111
+ end
112
+
113
+ describe '#add_project_strings_exporter_settings' do
114
+ let(:project_id) { 1 }
115
+ let(:body) do
116
+ {
117
+ format: 'json',
118
+ settings: {
119
+ convertPlaceholders: true,
120
+ convertLineBreaks: true
121
+ }
122
+ }
123
+ end
124
+
125
+ it 'when request are valid', :default do
126
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings-exporter-settings")
127
+ .with(body: body.to_json)
128
+ add_project_strings_exporter_settings = @crowdin.add_project_strings_exporter_settings(project_id, body)
129
+ expect(add_project_strings_exporter_settings).to eq(200)
130
+ end
131
+
132
+ it 'when the request is invalid', :default do
133
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings-exporter-settings")
134
+ expect { @crowdin.add_project_strings_exporter_settings }.to raise_error(ArgumentError)
135
+ end
136
+ end
137
+
138
+ describe '#get_project_strings_exporter_settings' do
139
+ let(:project_id) { 1 }
140
+ let(:system_strings_exporter_settings_id) { 1 }
141
+ let(:path) { "projects/#{project_id}/strings-exporter-settings/#{system_strings_exporter_settings_id}" }
142
+
143
+ it 'when request are valid', :default do
144
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/#{path}")
145
+ get_project_strings_exporter_settings = @crowdin.get_project_strings_exporter_settings(
146
+ project_id,
147
+ system_strings_exporter_settings_id
148
+ )
149
+ expect(get_project_strings_exporter_settings).to eq(200)
150
+ end
151
+
152
+ it 'when the request is invalid', :default do
153
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/#{path}")
154
+ expect { @crowdin.get_project_strings_exporter_settings }.to raise_error(ArgumentError)
155
+ end
156
+ end
157
+
158
+ describe '#delete_project_strings_exporter_settings' do
159
+ let(:project_id) { 1 }
160
+ let(:system_strings_exporter_settings_id) { 1 }
161
+ let(:path) { "projects/#{project_id}/strings-exporter-settings/#{system_strings_exporter_settings_id}" }
162
+
163
+ it 'when request are valid', :default do
164
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/#{path}")
165
+ delete_project_strings_exporter_settings = @crowdin.delete_project_strings_exporter_settings(
166
+ project_id,
167
+ system_strings_exporter_settings_id
168
+ )
169
+ expect(delete_project_strings_exporter_settings).to eq(200)
170
+ end
171
+
172
+ it 'when the request is invalid', :default do
173
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/#{path}")
174
+ expect { @crowdin.delete_project_strings_exporter_settings }.to raise_error(ArgumentError)
175
+ end
176
+ end
177
+
178
+ describe '#edit_project_strings_exporter_settings' do
179
+ let(:project_id) { 1 }
180
+ let(:system_strings_exporter_settings_id) { 1 }
181
+ let(:body) do
182
+ {
183
+ format: 'json',
184
+ settings: {
185
+ convertPlaceholders: true,
186
+ convertLineBreaks: true
187
+ }
188
+ }
189
+ end
190
+ let(:path) { "projects/#{project_id}/strings-exporter-settings/#{system_strings_exporter_settings_id}" }
191
+
192
+ it 'when request are valid', :default do
193
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/#{path}")
194
+ .with(body: body.to_json)
195
+ edit_project_strings_exporter_settings = @crowdin.edit_project_strings_exporter_settings(
196
+ project_id,
197
+ system_strings_exporter_settings_id,
198
+ body
199
+ )
200
+ expect(edit_project_strings_exporter_settings).to eq(200)
201
+ end
202
+
203
+ it 'when the request is invalid', :default do
204
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/#{path}")
205
+ expect { @crowdin.edit_project_strings_exporter_settings }.to raise_error(ArgumentError)
206
+ end
207
+ end
97
208
  end
98
209
 
99
210
  describe 'Enterprise endpoints' do
@@ -160,6 +160,16 @@ describe Crowdin::ApiResources::SourceFiles do
160
160
  end
161
161
  end
162
162
 
163
+ describe '#download_file_preview' do
164
+ let(:file_id) { 1 }
165
+
166
+ it 'when request are valid', :default do
167
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}/preview")
168
+ download_file_preview = @crowdin.download_file_preview(file_id, nil, project_id)
169
+ expect(download_file_preview).to eq(200)
170
+ end
171
+ end
172
+
163
173
  describe '#list_file_revisions' do
164
174
  let(:file_id) { 1 }
165
175
 
@@ -38,6 +38,14 @@ describe Crowdin::ApiResources::StringTranslations do
38
38
  end
39
39
  end
40
40
 
41
+ describe '#remove_string_approvals' do
42
+ it 'when request are valid', :default do
43
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/approvals")
44
+ remove_string_approvals = @crowdin.remove_string_approvals({}, project_id)
45
+ expect(remove_string_approvals).to eq(200)
46
+ end
47
+ end
48
+
41
49
  describe '#list_language_translations' do
42
50
  let(:language_id) { 1 }
43
51
 
@@ -20,6 +20,24 @@ describe Crowdin::ApiResources::Translations do
20
20
  end
21
21
  end
22
22
 
23
+ describe '#list_pre_translations' do
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/pre-translations")
26
+ list_pre_translations = @crowdin.list_pre_translations({}, project_id)
27
+ expect(list_pre_translations).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#edit_pre_translations' do
32
+ let(:pre_translation_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/pre-translations/#{pre_translation_id}")
36
+ edit_pre_translations = @crowdin.edit_pre_translations(pre_translation_id, {}, project_id)
37
+ expect(edit_pre_translations).to eq(200)
38
+ end
39
+ end
40
+
23
41
  describe '#build_project_directory_translation' do
24
42
  let(:directory_id) { 1 }
25
43
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowdin-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crowdin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-10 00:00:00.000000000 Z
11
+ date: 2024-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open-uri
@@ -286,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
286
  - !ruby/object:Gem::Version
287
287
  version: '0'
288
288
  requirements: []
289
- rubygems_version: 3.5.9
289
+ rubygems_version: 3.5.16
290
290
  signing_key:
291
291
  specification_version: 4
292
292
  summary: Ruby Client for the Crowdin API