crowdin-api 1.10.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: d44d26d0f12ba278e3199deda37ad21b26e1d977f36bb050e0b42bc98ded84bc
4
- data.tar.gz: e86837279bc7aa8a6cfdd7a87c0e09c7764c63a0b6ac072bb1ba72c820ab5970
3
+ metadata.gz: 9cd5b2539130f20d40ab8eae20e4291675e8b58c27883fd7ce59323492ad4daa
4
+ data.tar.gz: 699e9cc4411451da663e4bb59abb4a641c8dad98c9bb82dac475e11882facc59
5
5
  SHA512:
6
- metadata.gz: 6798c53e8405fbc05faa84d21aaac11a780e8d945b2ebde85872b18b706c320d83ec797ba762cca02f96b568fdc460361f469cdb00440bb8aa6db7a3768cbeb4
7
- data.tar.gz: 8c211132ea5389f49cb800d78a7cc5405663ee0cd1c12dda5a0bb687f7feb18fd34c29937f5de289c17d3f2cf5a72e86c2197c2b06c69c7fc1c7c0f1fc65279a
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.10.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
 
@@ -39,7 +39,7 @@ GEM
39
39
  public_suffix (5.0.4)
40
40
  racc (1.7.3)
41
41
  rainbow (3.1.1)
42
- rake (13.1.0)
42
+ rake (13.2.1)
43
43
  regexp_parser (2.8.3)
44
44
  rest-client (2.1.0)
45
45
  http-accept (>= 1.7.0, < 2.0)
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.10.0'
38
+ gem 'crowdin-api', '~> 1.12.0'
39
39
  ```
40
40
 
41
41
  And then execute:
@@ -84,7 +84,37 @@ module Crowdin
84
84
  response = ::RestClient::Request.execute(
85
85
  {
86
86
  method: :delete,
87
- url: config.base_url + config.target_api_url + "/projects/#{project_id}/labels/#{label_id}",
87
+ url: config.base_url + config.target_api_url + "/projects/#{project_id}/labels/#{label_id}/strings",
88
+ payload: query.to_json
89
+ }.merge(@options)
90
+ )
91
+
92
+ response.body.empty? ? response.code : JSON.parse(response.body)
93
+ rescue StandardError => e
94
+ e.message
95
+ end
96
+
97
+ def assign_label_to_screenshots(label_id = nil, query = {}, project_id = config.project_id)
98
+ label_id || raise_parameter_is_required_error(:label_id)
99
+ project_id || raise_project_id_is_required_error
100
+
101
+ request = Web::Request.new(
102
+ connection,
103
+ :post,
104
+ "#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}/screenshots",
105
+ { params: query }
106
+ )
107
+ Web::SendRequest.new(request).perform
108
+ end
109
+
110
+ def unassign_label_from_screenshots(label_id = nil, query = {}, project_id = config.project_id)
111
+ label_id || raise_parameter_is_required_error(:label_id)
112
+ project_id || raise_project_id_is_required_error
113
+
114
+ response = ::RestClient::Request.execute(
115
+ {
116
+ method: :delete,
117
+ url: config.base_url + config.target_api_url + "/projects/#{project_id}/labels/#{label_id}/screenshots",
88
118
  payload: query.to_json
89
119
  }.merge(@options)
90
120
  )
@@ -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}
@@ -64,6 +64,18 @@ module Crowdin
64
64
  )
65
65
  Web::SendRequest.new(request).perform
66
66
  end
67
+
68
+ def string_batch_operations(query = {}, project_id = config.project_id)
69
+ project_id || raise_project_id_is_required_error
70
+
71
+ request = Web::Request.new(
72
+ connection,
73
+ :patch,
74
+ "#{config.target_api_url}/projects/#{project_id}/strings",
75
+ { params: query }
76
+ )
77
+ Web::SendRequest.new(request).perform
78
+ end
67
79
  end
68
80
  end
69
81
  end
@@ -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.10.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)
@@ -3,7 +3,7 @@
3
3
  describe Crowdin::ApiResources::Labels do
4
4
  describe 'Default endpoints' do
5
5
  describe '#list_labels' do
6
- it 'when request are valid', :default do
6
+ it 'returns 200 when request is valid', :default do
7
7
  stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels")
8
8
  list_labels = @crowdin.list_labels({}, project_id)
9
9
  expect(list_labels).to eq(200)
@@ -11,7 +11,7 @@ describe Crowdin::ApiResources::Labels do
11
11
  end
12
12
 
13
13
  describe '#add_label' do
14
- it 'when request are valid', :default do
14
+ it 'returns 200 when request is valid', :default do
15
15
  stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels")
16
16
  add_label = @crowdin.add_label({}, project_id)
17
17
  expect(add_label).to eq(200)
@@ -21,7 +21,7 @@ describe Crowdin::ApiResources::Labels do
21
21
  describe '#get_label' do
22
22
  let(:label_id) { 1 }
23
23
 
24
- it 'when request are valid', :default do
24
+ it 'returns 200 when request is valid', :default do
25
25
  stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}")
26
26
  get_label = @crowdin.get_label(label_id, project_id)
27
27
  expect(get_label).to eq(200)
@@ -31,7 +31,7 @@ describe Crowdin::ApiResources::Labels do
31
31
  describe '#delete_label' do
32
32
  let(:label_id) { 1 }
33
33
 
34
- it 'when request are valid', :default do
34
+ it 'returns 200 when request is valid', :default do
35
35
  stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}")
36
36
  delete_label = @crowdin.delete_label(label_id, project_id)
37
37
  expect(delete_label).to eq(200)
@@ -41,7 +41,7 @@ describe Crowdin::ApiResources::Labels do
41
41
  describe '#edit_label' do
42
42
  let(:label_id) { 1 }
43
43
 
44
- it 'when request are valid', :default do
44
+ it 'returns 200 when request is valid', :default do
45
45
  stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}")
46
46
  edit_label = @crowdin.edit_label(label_id, {}, project_id)
47
47
  expect(edit_label).to eq(200)
@@ -51,7 +51,7 @@ describe Crowdin::ApiResources::Labels do
51
51
  describe '#assign_label_to_strings' do
52
52
  let(:label_id) { 1 }
53
53
 
54
- it 'when request are valid', :default do
54
+ it 'returns 200 when request is valid', :default do
55
55
  stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}/strings")
56
56
  assign_label_to_strings = @crowdin.assign_label_to_strings(label_id, {}, project_id)
57
57
  expect(assign_label_to_strings).to eq(200)
@@ -61,11 +61,43 @@ describe Crowdin::ApiResources::Labels do
61
61
  describe '#unassign_label_from_strings' do
62
62
  let(:label_id) { 1 }
63
63
 
64
- it 'when request are valid', :default do
65
- stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}")
64
+ it 'returns 200 when request is valid', :default do
65
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}/strings")
66
66
  unassign_label_from_strings = @crowdin.unassign_label_from_strings(label_id, {}, project_id)
67
67
  expect(unassign_label_from_strings).to eq(200)
68
68
  end
69
+
70
+ it 'returns error message when request was processed with an error' do
71
+ allow(RestClient::Request).to receive(:execute).and_raise('Error')
72
+ unassign_label_from_strings = @crowdin.unassign_label_from_strings(label_id, {}, project_id)
73
+ expect(unassign_label_from_strings).to eq('Error')
74
+ end
75
+ end
76
+
77
+ describe '#assign_label_to_screenshots' do
78
+ let(:label_id) { 1 }
79
+
80
+ it 'returns 200 when request is valid', :default do
81
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}/screenshots")
82
+ assign_label_to_screenshots = @crowdin.assign_label_to_screenshots(label_id, {}, project_id)
83
+ expect(assign_label_to_screenshots).to eq(200)
84
+ end
85
+ end
86
+
87
+ describe '#unassign_label_from_screenshots' do
88
+ let(:label_id) { 1 }
89
+
90
+ it 'returns 200 when request is valid', :default do
91
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}/screenshots")
92
+ unassign_label_from_screenshots = @crowdin.unassign_label_from_screenshots(label_id, {}, project_id)
93
+ expect(unassign_label_from_screenshots).to eq(200)
94
+ end
95
+
96
+ it 'returns error message when request was processed with an error' do
97
+ allow(RestClient::Request).to receive(:execute).and_raise('Error')
98
+ unassign_label_from_screenshots = @crowdin.unassign_label_from_screenshots(label_id, {}, project_id)
99
+ expect(unassign_label_from_screenshots).to eq('Error')
100
+ end
69
101
  end
70
102
  end
71
103
  end
@@ -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
 
@@ -3,7 +3,7 @@
3
3
  describe Crowdin::ApiResources::SourceStrings do
4
4
  describe 'Default endpoints' do
5
5
  describe '#list_strings' do
6
- it 'when request are valid', :default do
6
+ it 'returns 200 when request is valid', :default do
7
7
  stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings")
8
8
  list_strings = @crowdin.list_strings({}, project_id)
9
9
  expect(list_strings).to eq(200)
@@ -11,7 +11,7 @@ describe Crowdin::ApiResources::SourceStrings do
11
11
  end
12
12
 
13
13
  describe '#add_string' do
14
- it 'when request are valid', :default do
14
+ it 'returns 200 when request is valid', :default do
15
15
  stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings")
16
16
  add_string = @crowdin.add_string({}, project_id)
17
17
  expect(add_string).to eq(200)
@@ -21,7 +21,7 @@ describe Crowdin::ApiResources::SourceStrings do
21
21
  describe '#get_string' do
22
22
  let(:string_id) { 1 }
23
23
 
24
- it 'when request are valid', :default do
24
+ it 'returns 200 when request is valid', :default do
25
25
  stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}")
26
26
  get_string = @crowdin.get_string(string_id, {}, project_id)
27
27
  expect(get_string).to eq(200)
@@ -31,7 +31,7 @@ describe Crowdin::ApiResources::SourceStrings do
31
31
  describe '#delete_string' do
32
32
  let(:string_id) { 1 }
33
33
 
34
- it 'when request are valid', :default do
34
+ it 'returns 200 when request is valid', :default do
35
35
  stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}")
36
36
  delete_string = @crowdin.delete_string(string_id, project_id)
37
37
  expect(delete_string).to eq(200)
@@ -41,11 +41,19 @@ describe Crowdin::ApiResources::SourceStrings do
41
41
  describe '#edit_string' do
42
42
  let(:string_id) { 1 }
43
43
 
44
- it 'when request are valid', :default do
44
+ it 'returns 200 when request is valid', :default do
45
45
  stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}")
46
46
  edit_string = @crowdin.edit_string(string_id, {}, project_id)
47
47
  expect(edit_string).to eq(200)
48
48
  end
49
49
  end
50
+
51
+ describe '#string_batch_operations' do
52
+ it 'returns 200 when request is valid', :default do
53
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings")
54
+ string_batch_operations = @crowdin.string_batch_operations({}, project_id)
55
+ expect(string_batch_operations).to eq(200)
56
+ end
57
+ end
50
58
  end
51
59
  end
@@ -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.10.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-04-17 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.3
289
+ rubygems_version: 3.5.16
290
290
  signing_key:
291
291
  specification_version: 4
292
292
  summary: Ruby Client for the Crowdin API