crowdin-api 1.4.0 → 1.5.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: 283ff1afb3a211be3a2c06c0417decc9b6ff3fcca1e8c61c78523708c428d286
4
- data.tar.gz: e6f02c86c39702e00eacc0908c6dec0a93783a7a4038e2eddbc634ca2d4887d3
3
+ metadata.gz: 92b7e78f934fe0170055ff679da134b9b4444caba51677c19ba8903a1eaf55ec
4
+ data.tar.gz: 22ebff0813e0d4d1c0217a3c9163e738f3b58fa6124d09f5cfff4cf3ddb3330c
5
5
  SHA512:
6
- metadata.gz: ca47c68a8c81d3de24a5ae913155ece611ae9400fdbea47933355d6043036c269d15ab067df037afcdc4aae1fa982991f49bee4603fb5f6816a783dd6d7c30b1
7
- data.tar.gz: dcf04302fb3c882a81f630476b4e7dce4cf1e98320da04615d3d393fb4bdfadb9bc67aec732bee227321cd3af7cbc095363f0f0c22a903a5f954acb6101a243a
6
+ metadata.gz: e0705ea1264b498c2a8080445ab79ccc353347e65f928acd68008ea96a1a8a97c0c947b332d88fb9171ba1d02001e231498cc34102d2c8dd6967d1b858204f7a
7
+ data.tar.gz: 81c748f6b6cf1090bb218d486548634c37c2a10594d937745abdd07e2cea097a8e9dd64617a85e85c06cc35b97b7ac4a5f4ffa3bc7846970efa860ef99fe3522
@@ -0,0 +1,31 @@
1
+ name: Docs
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+
8
+ jobs:
9
+ docs:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - name: Set up Ruby 2.6
14
+ uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
15
+ with:
16
+ ruby-version: 2.6
17
+ - run: bundle install
18
+
19
+ - name: Cleanup the Readme
20
+ run: |
21
+ sed -i /\<div/d README.md
22
+ sed -i /\<\\/div/d README.md
23
+
24
+ - name: Generate Docs
25
+ run: yardoc lib/crowdin-api/api_resources/*.rb
26
+
27
+ - name: Deploy 🚀
28
+ uses: JamesIves/github-pages-deploy-action@v4.4.1
29
+ with:
30
+ branch: gh-pages
31
+ folder: doc
data/.rubocop_todo.yml CHANGED
@@ -104,7 +104,7 @@ Metrics/MethodLength:
104
104
  # Offense count: 8
105
105
  # Configuration parameters: CountComments, CountAsOne.
106
106
  Metrics/ModuleLength:
107
- Max: 196
107
+ Max: 256
108
108
 
109
109
  # Offense count: 2
110
110
  # Configuration parameters: Max, CountKeywordArgs.
data/Gemfile CHANGED
@@ -2,4 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ # For Documentation
6
+ gem 'yard', '~> 0.9.28'
7
+
5
8
  gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [<p align='center'><img src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' data-canonical-src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' width='200' height='200' align='center'/></p>](https://crowdin.com)
1
+ [<p align='center'><img src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' data-canonical-src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' width='150' height='150' align='center'/></p>](https://crowdin.com)
2
2
 
3
3
  # Crowdin Ruby client
4
4
 
@@ -6,11 +6,11 @@ The Crowdin Ruby client is a lightweight interface to the Crowdin API v2. It pro
6
6
 
7
7
  Crowdin API is a full-featured RESTful API that helps you to integrate localization into your development process. The endpoints that we use allow you to easily make calls to retrieve information and to execute actions needed.
8
8
 
9
- For more about Crowdin API v2 see the documentation:
10
- - [Crowdin](https://support.crowdin.com/api/v2/)
11
- - [Crowdin Enterprise](https://support.crowdin.com/enterprise/api/)
9
+ <div align="center">
12
10
 
13
- ## Status
11
+ [**`API Client Docs`**](http://crowdin.github.io/crowdin-api-client-ruby/) &nbsp;|&nbsp;
12
+ [**`Crowdin API`**](https://developer.crowdin.com/api/v2/) &nbsp;|&nbsp;
13
+ [**`Crowdin Enterprise API`**](https://developer.crowdin.com/enterprise/api/v2/)
14
14
 
15
15
  [![Gem](https://img.shields.io/gem/v/crowdin-api?logo=ruby&cacheSeconds=1800)](https://rubygems.org/gems/crowdin-api)
16
16
  [![Gem](https://img.shields.io/gem/dt/crowdin-api?cacheSeconds=1800)](https://rubygems.org/gems/crowdin-api)
@@ -21,6 +21,8 @@ For more about Crowdin API v2 see the documentation:
21
21
  [![GitHub issues](https://img.shields.io/github/issues/crowdin/crowdin-api-client-ruby?cacheSeconds=1800)](https://github.com/crowdin/crowdin-api-client-ruby/issues)
22
22
  [![GitHub](https://img.shields.io/github/license/crowdin/crowdin-api-client-ruby?cacheSeconds=1800)](https://github.com/crowdin/crowdin-api-client-ruby/blob/main/LICENSE)
23
23
 
24
+ </div>
25
+
24
26
  ## Table of Contents
25
27
  * [Requirements](#requirements)
26
28
  * [Installation](#installation)
@@ -41,7 +43,7 @@ For more about Crowdin API v2 see the documentation:
41
43
  Add this line to your application's Gemfile:
42
44
 
43
45
  ```gemfile
44
- gem 'crowdin-api', '~> 1.4.0'
46
+ gem 'crowdin-api', '~> 1.5.0'
45
47
  ```
46
48
 
47
49
  And then execute:
@@ -3,6 +3,9 @@
3
3
  module Crowdin
4
4
  module ApiResources
5
5
  module Bundles
6
+ # @param query [Hash] Request Body
7
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.getMany API Documentation}
8
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.getMany Enterprise API Documentation}
6
9
  def list_bundles(query = {}, project_id = config.project_id)
7
10
  project_id || raise_project_id_is_required_error
8
11
 
@@ -15,8 +18,14 @@ module Crowdin
15
18
  Web::SendRequest.new(request).perform
16
19
  end
17
20
 
21
+ # @param query [Hash] Request Body
22
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.post API Documentation}
23
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.post Enterprise API Documentation}
18
24
  def add_bundle(query = {}, project_id = config.project_id)
19
25
  project_id || raise_project_id_is_required_error
26
+ %i[name format sourcePatterns exportPattern].each do |param|
27
+ query[param] || raise_parameter_is_required_error(param)
28
+ end
20
29
 
21
30
  request = Web::Request.new(
22
31
  connection,
@@ -27,6 +36,9 @@ module Crowdin
27
36
  Web::SendRequest.new(request).perform
28
37
  end
29
38
 
39
+ # @param bundle_id [Integer] Bundle ID
40
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.get API Documentation}
41
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.get Enterprise API Documentation}
30
42
  def get_bundle(bundle_id, project_id = config.project_id)
31
43
  bundle_id || raise_parameter_is_required_error(:bundle_id)
32
44
  project_id || raise_project_id_is_required_error
@@ -39,6 +51,9 @@ module Crowdin
39
51
  Web::SendRequest.new(request).perform
40
52
  end
41
53
 
54
+ # @param bundle_id [Integer] Bundle ID
55
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.delete API Documentation}
56
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.delete Enterprise API Documentation}
42
57
  def delete_bundle(bundle_id, project_id = config.project_id)
43
58
  bundle_id || raise_parameter_is_required_error(:bundle_id)
44
59
  project_id || raise_project_id_is_required_error
@@ -51,6 +66,10 @@ module Crowdin
51
66
  Web::SendRequest.new(request).perform
52
67
  end
53
68
 
69
+ # @param bundle_id [Integer] Bundle ID
70
+ # @param query [Hash] Request Body
71
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.patch API Documentation}
72
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.patch Enterprise API Documentation}
54
73
  def edit_bundle(bundle_id, query = {}, project_id = config.project_id)
55
74
  bundle_id || raise_parameter_is_required_error(:bundle_id)
56
75
  project_id || raise_project_id_is_required_error
@@ -64,6 +83,10 @@ module Crowdin
64
83
  Web::SendRequest.new(request).perform
65
84
  end
66
85
 
86
+ # @param bundle_id [Integer] Bundle ID
87
+ # @param query [Hash] Request Body
88
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.files.getMany API Documentation}
89
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.files.getMany Enterprise API Documentation}
67
90
  def bundle_list_files(bundle_id, query = {}, project_id = config.project_id)
68
91
  bundle_id || raise_parameter_is_required_error(:bundle_id)
69
92
  project_id || raise_project_id_is_required_error
@@ -194,6 +194,55 @@ module Crowdin
194
194
  )
195
195
  Web::SendRequest.new(request).perform
196
196
  end
197
+
198
+ def list_concepts(glossary_id = nil, query = {})
199
+ glossary_id || raise_parameter_is_required_error(:glossary_id)
200
+
201
+ request = Web::Request.new(
202
+ connection,
203
+ :get,
204
+ "#{config.target_api_url}/glossaries/#{glossary_id}/concepts",
205
+ { params: query }
206
+ )
207
+ Web::SendRequest.new(request).perform
208
+ end
209
+
210
+ def get_concept(glossary_id = nil, concept_id = nil)
211
+ glossary_id || raise_parameter_is_required_error(:glossary_id)
212
+ concept_id || raise_parameter_is_required_error(:concept_id)
213
+
214
+ request = Web::Request.new(
215
+ connection,
216
+ :get,
217
+ "#{config.target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}"
218
+ )
219
+ Web::SendRequest.new(request).perform
220
+ end
221
+
222
+ def update_concept(glossary_id = nil, concept_id = nil, query = {})
223
+ glossary_id || raise_parameter_is_required_error(:glossary_id)
224
+ concept_id || raise_parameter_is_required_error(:concept_id)
225
+
226
+ request = Web::Request.new(
227
+ connection,
228
+ :put,
229
+ "#{config.target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}",
230
+ { params: query }
231
+ )
232
+ Web::SendRequest.new(request).perform
233
+ end
234
+
235
+ def delete_concept(glossary_id = nil, concept_id = nil)
236
+ glossary_id || raise_parameter_is_required_error(:glossary_id)
237
+ concept_id || raise_parameter_is_required_error(:concept_id)
238
+
239
+ request = Web::Request.new(
240
+ connection,
241
+ :delete,
242
+ "#{config.target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}"
243
+ )
244
+ Web::SendRequest.new(request).perform
245
+ end
197
246
  end
198
247
  end
199
248
  end
@@ -3,6 +3,9 @@
3
3
  module Crowdin
4
4
  module ApiResources
5
5
  module Projects
6
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.getMany API Documentation}
7
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.getMany Enterprise API Documentation}
8
+ # @param query [Hash] Request Body
6
9
  def list_projects(query = {})
7
10
  request = Web::Request.new(
8
11
  connection,
@@ -13,6 +16,9 @@ module Crowdin
13
16
  Web::SendRequest.new(request).perform
14
17
  end
15
18
 
19
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.post API Documentation}
20
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.post Enterprise API Documentation}
21
+ # @param query [Hash] Request Body
16
22
  def add_project(query = {})
17
23
  request = Web::Request.new(
18
24
  connection,
@@ -23,6 +29,9 @@ module Crowdin
23
29
  Web::SendRequest.new(request).perform
24
30
  end
25
31
 
32
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.get API Documentation}
33
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.get Enterprise API Documentation}
34
+ # @param project_id [Integer] Project ID
26
35
  def get_project(project_id = nil)
27
36
  project_id || raise_parameter_is_required_error(:project_id)
28
37
 
@@ -34,6 +43,9 @@ module Crowdin
34
43
  Web::SendRequest.new(request).perform
35
44
  end
36
45
 
46
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.delete API Documentation}
47
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.delete Enterprise API Documentation}
48
+ # @param project_id [Integer] Project ID
37
49
  def delete_project(project_id = nil)
38
50
  project_id || raise_parameter_is_required_error(:project_id)
39
51
 
@@ -45,6 +57,10 @@ module Crowdin
45
57
  Web::SendRequest.new(request).perform
46
58
  end
47
59
 
60
+ # @param project_id [Integer] Project ID
61
+ # @param query [Hash] Request Body
62
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.patch API Documentation}
63
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.patch Enterprise API Documentation}
48
64
  def edit_project(project_id = nil, query = {})
49
65
  project_id || raise_parameter_is_required_error(:project_id)
50
66
 
@@ -59,6 +75,8 @@ module Crowdin
59
75
 
60
76
  # -- For Enterprise mode only --
61
77
 
78
+ # @param query [Hash] Request Body
79
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.groups.getMany Enterprise API Documentation}
62
80
  def list_groups(query = {})
63
81
  enterprise_mode? || raise_only_for_enterprise_mode_error
64
82
 
@@ -71,6 +89,8 @@ module Crowdin
71
89
  Web::SendRequest.new(request).perform
72
90
  end
73
91
 
92
+ # @param query [Hash] Request Body
93
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.groups.post Enterprise API Documentation}
74
94
  def add_group(query = {})
75
95
  enterprise_mode? || raise_only_for_enterprise_mode_error
76
96
 
@@ -83,6 +103,8 @@ module Crowdin
83
103
  Web::SendRequest.new(request).perform
84
104
  end
85
105
 
106
+ # @param group_id [Integer] Group ID
107
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.groups.get Enterprise API Documentation}
86
108
  def get_group(group_id = nil)
87
109
  enterprise_mode? || raise_only_for_enterprise_mode_error
88
110
  group_id || raise_parameter_is_required_error(:group_id)
@@ -95,6 +117,8 @@ module Crowdin
95
117
  Web::SendRequest.new(request).perform
96
118
  end
97
119
 
120
+ # @param group_id [Integer] Group ID
121
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.groups.delete Enterprise API Documentation}
98
122
  def delete_group(group_id = nil)
99
123
  enterprise_mode? || raise_only_for_enterprise_mode_error
100
124
  group_id || raise_parameter_is_required_error(:group_id)
@@ -107,6 +131,9 @@ module Crowdin
107
131
  Web::SendRequest.new(request).perform
108
132
  end
109
133
 
134
+ # @param group_id [Integer] Group ID
135
+ # @param query [Hash] Request Body
136
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.groups.patch Enterprise API Documentation}
110
137
  def edit_group(group_id = nil, query = {})
111
138
  enterprise_mode? || raise_only_for_enterprise_mode_error
112
139
  group_id || raise_parameter_is_required_error(:group_id)
@@ -115,6 +115,70 @@ module Crowdin
115
115
  )
116
116
  Web::SendRequest.new(request, destination).perform
117
117
  end
118
+
119
+ def list_report_settings_templates(query = {}, project_id = config.project_id)
120
+ project_id || raise_project_id_is_required_error
121
+
122
+ request = Web::Request.new(
123
+ connection,
124
+ :get,
125
+ "#{config.target_api_url}/projects/#{project_id}/reports/settings-templates",
126
+ { params: query }
127
+ )
128
+ Web::SendRequest.new(request).perform
129
+ end
130
+
131
+ def add_report_settings_template(query = {}, project_id = config.project_id)
132
+ project_id || raise_project_id_is_required_error
133
+ %i[name currency unit mode config].each do |param|
134
+ query[param] || raise_parameter_is_required_error(param)
135
+ end
136
+
137
+ request = Web::Request.new(
138
+ connection,
139
+ :post,
140
+ "#{config.target_api_url}/projects/#{project_id}/reports/settings-templates",
141
+ { params: query }
142
+ )
143
+ Web::SendRequest.new(request).perform
144
+ end
145
+
146
+ def get_report_settings_template(template_id = nil, project_id = config.project_id)
147
+ project_id || raise_project_id_is_required_error
148
+ template_id || raise_parameter_is_required_error(:template_id)
149
+
150
+ request = Web::Request.new(
151
+ connection,
152
+ :get,
153
+ "#{config.target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}"
154
+ )
155
+ Web::SendRequest.new(request).perform
156
+ end
157
+
158
+ def edit_report_settings_template(query = {}, template_id = nil, project_id = config.project_id)
159
+ project_id || raise_project_id_is_required_error
160
+ template_id || raise_parameter_is_required_error(:template_id)
161
+
162
+ request = Web::Request.new(
163
+ connection,
164
+ :patch,
165
+ "#{config.target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}",
166
+ { params: query }
167
+ )
168
+ Web::SendRequest.new(request).perform
169
+ end
170
+
171
+ def delete_report_settings_template(template_id = nil, project_id = config.project_id)
172
+ project_id || raise_project_id_is_required_error
173
+ template_id || raise_parameter_is_required_error(:template_id)
174
+
175
+ request = Web::Request.new(
176
+ connection,
177
+ :delete,
178
+ "#{config.target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}"
179
+ )
180
+ Web::SendRequest.new(request).perform
181
+ end
118
182
  end
119
183
  end
120
184
  end
@@ -3,6 +3,9 @@
3
3
  module Crowdin
4
4
  module ApiResources
5
5
  module SourceFiles
6
+ # @param query [Hash] Request Body
7
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.getMany API Documentation}
8
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.getMany Enterprise API Documentation}
6
9
  def list_branches(query = {}, project_id = config.project_id)
7
10
  project_id || raise_project_id_is_required_error
8
11
 
@@ -15,6 +18,9 @@ module Crowdin
15
18
  Web::SendRequest.new(request).perform
16
19
  end
17
20
 
21
+ # @param query [Hash] Request Body
22
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.post API Documentation}
23
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.post Enterprise API Documentation}
18
24
  def add_branch(query = {}, project_id = config.project_id)
19
25
  project_id || raise_project_id_is_required_error
20
26
 
@@ -27,6 +33,9 @@ module Crowdin
27
33
  Web::SendRequest.new(request).perform
28
34
  end
29
35
 
36
+ # @param branch_id [Integer] Branch ID
37
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.get API Documentation}
38
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.get Enterprise API Documentation}
30
39
  def get_branch(branch_id = nil, project_id = config.project_id)
31
40
  branch_id || raise_parameter_is_required_error(:branch_id)
32
41
  project_id || raise_project_id_is_required_error
@@ -39,6 +48,9 @@ module Crowdin
39
48
  Web::SendRequest.new(request).perform
40
49
  end
41
50
 
51
+ # @param branch_id [Hash] Branch ID
52
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.delete API Documentation}
53
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.delete Enterprise API Documentation}
42
54
  def delete_branch(branch_id = nil, project_id = config.project_id)
43
55
  branch_id || raise_parameter_is_required_error(:branch_id)
44
56
  project_id || raise_project_id_is_required_error
@@ -51,6 +63,10 @@ module Crowdin
51
63
  Web::SendRequest.new(request).perform
52
64
  end
53
65
 
66
+ # @param query [Hash] Request Body
67
+ # @param branch_id [Integer] Branch ID
68
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.patch API Documentation}
69
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.patch Enterprise API Documentation}
54
70
  def edit_branch(branch_id = nil, query = {}, project_id = config.project_id)
55
71
  branch_id || raise_parameter_is_required_error(:branch_id)
56
72
  project_id || raise_project_id_is_required_error
@@ -64,6 +80,9 @@ module Crowdin
64
80
  Web::SendRequest.new(request).perform
65
81
  end
66
82
 
83
+ # @param query [Hash] Request Body
84
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.getMany API Documentation}
85
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.getMany Enterprise API Documentation}
67
86
  def list_directories(query = {}, project_id = config.project_id)
68
87
  project_id || raise_project_id_is_required_error
69
88
 
@@ -76,6 +95,9 @@ module Crowdin
76
95
  Web::SendRequest.new(request).perform
77
96
  end
78
97
 
98
+ # @param query [Hash] Request Body
99
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.post API Documentation}
100
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.post Enterprise API Documentation}
79
101
  def add_directory(query = {}, project_id = config.project_id)
80
102
  project_id || raise_project_id_is_required_error
81
103
 
@@ -88,6 +110,9 @@ module Crowdin
88
110
  Web::SendRequest.new(request).perform
89
111
  end
90
112
 
113
+ # @param directory_id [Integer] Directory ID
114
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.get API Documentation}
115
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.get Enterprise API Documentation}
91
116
  def get_directory(directory_id = nil, project_id = config.project_id)
92
117
  directory_id || raise_parameter_is_required_error(:directory_id)
93
118
  project_id || raise_project_id_is_required_error
@@ -100,6 +125,9 @@ module Crowdin
100
125
  Web::SendRequest.new(request).perform
101
126
  end
102
127
 
128
+ # @param directory_id [Integer] Directory ID
129
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.delete API Documentation}
130
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.delete Enterprise API Documentation}
103
131
  def delete_directory(directory_id = nil, project_id = config.project_id)
104
132
  directory_id || raise_parameter_is_required_error(:directory_id)
105
133
  project_id || raise_project_id_is_required_error
@@ -112,6 +140,10 @@ module Crowdin
112
140
  Web::SendRequest.new(request).perform
113
141
  end
114
142
 
143
+ # @param query [Hash] Request Body
144
+ # @param directory_id [Integer] Directory ID
145
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.patch API Documentation}
146
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.patch Enterprise API Documentation}
115
147
  def edit_directory(directory_id = nil, query = {}, project_id = config.project_id)
116
148
  directory_id || raise_parameter_is_required_error(:directory_id)
117
149
  project_id || raise_project_id_is_required_error
@@ -125,6 +157,9 @@ module Crowdin
125
157
  Web::SendRequest.new(request).perform
126
158
  end
127
159
 
160
+ # @param query [Hash] Request Body
161
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.getMany API Documentation}
162
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.getMany Enterprise API Documentation}
128
163
  def list_files(query = {}, project_id = config.project_id)
129
164
  project_id || raise_project_id_is_required_error
130
165
 
@@ -137,6 +172,9 @@ module Crowdin
137
172
  Web::SendRequest.new(request).perform
138
173
  end
139
174
 
175
+ # @param query [Hash] Request Body
176
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.post API Documentation}
177
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.post Enterprise API Documentation}
140
178
  def add_file(query = {}, project_id = config.project_id)
141
179
  project_id || raise_project_id_is_required_error
142
180
 
@@ -149,6 +187,9 @@ module Crowdin
149
187
  Web::SendRequest.new(request).perform
150
188
  end
151
189
 
190
+ # @param file_id [Integer] File ID
191
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.get API Documentation}
192
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.get Enterprise API Documentation}
152
193
  def get_file(file_id = nil, project_id = config.project_id)
153
194
  file_id || raise_parameter_is_required_error(:file_id)
154
195
  project_id || raise_project_id_is_required_error
@@ -161,6 +202,10 @@ module Crowdin
161
202
  Web::SendRequest.new(request).perform
162
203
  end
163
204
 
205
+ # @param query [Hash] Request Body
206
+ # @param file_id [Integer] File ID
207
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.put API Documentation}
208
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.put Enterprise API Documentation}
164
209
  def update_or_restore_file(file_id = nil, query = {}, project_id = config.project_id)
165
210
  file_id || raise_parameter_is_required_error(:file_id)
166
211
  project_id || raise_project_id_is_required_error
@@ -174,6 +219,9 @@ module Crowdin
174
219
  Web::SendRequest.new(request).perform
175
220
  end
176
221
 
222
+ # @param file_id [Integer] File ID
223
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.delete API Documentation}
224
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.delete Enterprise API Documentation}
177
225
  def delete_file(file_id = nil, project_id = config.project_id)
178
226
  file_id || raise_parameter_is_required_error(:file_id)
179
227
  project_id || raise_project_id_is_required_error
@@ -186,6 +234,10 @@ module Crowdin
186
234
  Web::SendRequest.new(request).perform
187
235
  end
188
236
 
237
+ # @param query [Hash] Request Body
238
+ # @param file_id [Integer] File ID
239
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.patch API Documentation}
240
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.patch Enterprise API Documentation}
189
241
  def edit_file(file_id = nil, query = {}, project_id = config.project_id)
190
242
  file_id || raise_parameter_is_required_error(:file_id)
191
243
  project_id || raise_project_id_is_required_error
@@ -199,6 +251,10 @@ module Crowdin
199
251
  Web::SendRequest.new(request).perform
200
252
  end
201
253
 
254
+ # @param file_id [Integer] File ID
255
+ # @param destination [String] Destination of File
256
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.download.get API Documentation}
257
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.download.get Enterprise API Documentation}
202
258
  def download_file(file_id = nil, destination = nil, project_id = config.project_id)
203
259
  file_id || raise_parameter_is_required_error(:file_id)
204
260
  project_id || raise_project_id_is_required_error
@@ -211,6 +267,10 @@ module Crowdin
211
267
  Web::SendRequest.new(request, destination).perform
212
268
  end
213
269
 
270
+ # @param query [Hash] Request Body
271
+ # @param file_id [Integer] File ID
272
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.revisions.getMany API Documentation}
273
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.revisions.getMany Enterprise API Documentation}
214
274
  def list_file_revisions(file_id = nil, query = {}, project_id = config.project_id)
215
275
  file_id || raise_parameter_is_required_error(:file_id)
216
276
  project_id || raise_project_id_is_required_error
@@ -224,6 +284,10 @@ module Crowdin
224
284
  Web::SendRequest.new(request).perform
225
285
  end
226
286
 
287
+ # @param revision_id [Integer] Revision ID
288
+ # @param file_id [Integer] File ID
289
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.revisions.get API Documentation}
290
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.revisions.get Enterprise API Documentation}
227
291
  def get_file_revision(file_id = nil, revision_id = nil, project_id = config.project_id)
228
292
  file_id || raise_parameter_is_required_error(:file_id)
229
293
  revision_id || raise_parameter_is_required_error(:revision_id)
@@ -3,6 +3,9 @@
3
3
  module Crowdin
4
4
  module ApiResources
5
5
  module Storages
6
+ # @param query [Hash] Request Body
7
+ # * {https://developer.crowdin.com/api/v2/#operation/api.storages.getMany API Documentation}
8
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.storages.getMany Enterprise API Documentation}
6
9
  def list_storages(query = {})
7
10
  request = Web::Request.new(
8
11
  connection,
@@ -13,6 +16,9 @@ module Crowdin
13
16
  Web::SendRequest.new(request).perform
14
17
  end
15
18
 
19
+ # @param file [string] File path
20
+ # * {https://developer.crowdin.com/api/v2/#operation/api.storages.post API Documentation}
21
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.storages.post Enterprise API Documentation}
16
22
  def add_storage(file = nil)
17
23
  file || raise_parameter_is_required_error(:file)
18
24
 
@@ -28,6 +34,9 @@ module Crowdin
28
34
  Web::SendRequest.new(request).perform
29
35
  end
30
36
 
37
+ # @param storage_id [Integer] Storage ID
38
+ # * {https://developer.crowdin.com/api/v2/#operation/api.storages.get API Documentation}
39
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.storages.get Enterprise API Documentation}
31
40
  def get_storage(storage_id = nil)
32
41
  storage_id || raise_parameter_is_required_error(:storage_id)
33
42
 
@@ -39,6 +48,9 @@ module Crowdin
39
48
  Web::SendRequest.new(request).perform
40
49
  end
41
50
 
51
+ # @param storage_id [Integer] Storage ID
52
+ # * {https://developer.crowdin.com/api/v2/#operation/api.storages.delete API Documentation}
53
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.storages.delete Enterprise API Documentation}
42
54
  def delete_storage(storage_id = nil)
43
55
  storage_id || raise_parameter_is_required_error(:storage_id)
44
56
 
@@ -103,7 +103,7 @@ module Crowdin
103
103
  # otherwise system will retry so many times, as indicated at tries_count
104
104
  #
105
105
  def fetch_all(api_resource, opts = {}, retry_opts = {})
106
- unless Web::FetchAllExtensions::API_RESOURCES_FOR_FETCH_ALL.include?(api_resource)
106
+ unless api_resource.to_s.start_with?('list_')
107
107
  raise(Errors::FetchAllProcessingError, "#{api_resource} method aren't supported for FetchAll")
108
108
  end
109
109
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Crowdin
4
4
  class Client
5
- VERSION = '1.4.0'
5
+ VERSION = '1.5.0'
6
6
  end
7
7
  end
@@ -4,11 +4,6 @@ module Crowdin
4
4
  module Web
5
5
  module FetchAllExtensions
6
6
  MAX_ITEMS_COUNT_PER_REQUEST = 500.freeze
7
- API_RESOURCES_FOR_FETCH_ALL = %i[list_vendors list_dictionaries list_directories list_distributions
8
- list_workflow_templates list_languages list_labels list_mts list_files
9
- list_projects list_groups list_branches list_strings list_storages
10
- list_string_comments list_tasks list_user_tasks list_webhooks
11
- list_terms list_file_revisions list_bundles].freeze
12
7
  end
13
8
  end
14
9
  end
@@ -13,7 +13,7 @@ describe Crowdin::ApiResources::Bundles do
13
13
  describe '#add_bundle' do
14
14
  it 'when request are valid', :default do
15
15
  stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles")
16
- add_bundle = @crowdin.add_bundle({}, project_id)
16
+ add_bundle = @crowdin.add_bundle({ name: '', format: '', sourcePatterns: [], exportPattern: '' }, project_id)
17
17
  expect(add_bundle).to eq(200)
18
18
  end
19
19
  end
@@ -163,5 +163,48 @@ describe Crowdin::ApiResources::Glossaries do
163
163
  expect(edit_term).to eq(200)
164
164
  end
165
165
  end
166
+
167
+ describe '#list_concepts' do
168
+ let(:glossary_id) { 1 }
169
+
170
+ it 'when request are valid', :default do
171
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts")
172
+ concepts = @crowdin.list_concepts(glossary_id)
173
+ expect(concepts).to eq(200)
174
+ end
175
+ end
176
+
177
+ describe '#get_concept' do
178
+ let(:glossary_id) { 1 }
179
+ let(:concept_id) { 1 }
180
+
181
+ it 'when request are valid', :default do
182
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
183
+ concept = @crowdin.get_concept(glossary_id, concept_id)
184
+ expect(concept).to eq(200)
185
+ end
186
+ end
187
+
188
+ describe '#update_concept' do
189
+ let(:glossary_id) { 1 }
190
+ let(:concept_id) { 1 }
191
+
192
+ it 'when request are valid', :default do
193
+ stub_request(:put, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
194
+ concept = @crowdin.update_concept(glossary_id, concept_id)
195
+ expect(concept).to eq(200)
196
+ end
197
+ end
198
+
199
+ describe '#update_concept' do
200
+ let(:glossary_id) { 1 }
201
+ let(:concept_id) { 1 }
202
+
203
+ it 'when request are valid', :default do
204
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
205
+ concept = @crowdin.delete_concept(glossary_id, concept_id)
206
+ expect(concept).to eq(200)
207
+ end
208
+ end
166
209
  end
167
210
  end
@@ -92,4 +92,54 @@ describe Crowdin::ApiResources::Reports do
92
92
  end
93
93
  end
94
94
  end
95
+
96
+ describe 'Setting Templates endpoints' do
97
+ describe 'List Report Settings templates' do
98
+ it 'when request are valid', :default do
99
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates")
100
+ settings_templates = @crowdin.list_report_settings_templates({}, project_id)
101
+ expect(settings_templates).to eq(200)
102
+ end
103
+ end
104
+
105
+ describe 'Add Report Settings template' do
106
+ it 'when request are valid', :default do
107
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates")
108
+ settings_templates = @crowdin.add_report_settings_template(
109
+ { name: '', currency: '', unit: '', mode: '', config: '' }, project_id
110
+ )
111
+ expect(settings_templates).to eq(200)
112
+ end
113
+ end
114
+
115
+ describe 'Get Report Settings template' do
116
+ let(:template_id) { 1 }
117
+
118
+ it 'when request are valid', :default do
119
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}")
120
+ settings_templates = @crowdin.get_report_settings_template(template_id, project_id)
121
+ expect(settings_templates).to eq(200)
122
+ end
123
+ end
124
+
125
+ describe 'Get Report Settings template' do
126
+ let(:template_id) { 1 }
127
+
128
+ it 'when request are valid', :default do
129
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}")
130
+ settings_templates = @crowdin.edit_report_settings_template({}, template_id, project_id)
131
+ expect(settings_templates).to eq(200)
132
+ end
133
+ end
134
+
135
+ describe 'Get Report Settings template' do
136
+ let(:template_id) { 1 }
137
+
138
+ it 'when request are valid', :default do
139
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}")
140
+ settings_templates = @crowdin.delete_report_settings_template(template_id, project_id)
141
+ expect(settings_templates).to eq(200)
142
+ end
143
+ end
144
+ end
95
145
  end
@@ -82,4 +82,10 @@ describe 'Crowdin Client' do
82
82
  expect(@crowdin.config.base_url).to eq("https://#{full_organization_domain}")
83
83
  end
84
84
  end
85
+
86
+ describe 'Crowdin Client fetch_all' do
87
+ it 'should raise error if fetch_all is called for unsupported methods' do
88
+ expect { @crowdin.fetch_all(:add_bundle).to raise_error(Crowdin::Errors::FetchAllProcessingError) }
89
+ end
90
+ end
85
91
  end
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.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crowdin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-15 00:00:00.000000000 Z
11
+ date: 2022-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open-uri
@@ -170,6 +170,7 @@ extensions: []
170
170
  extra_rdoc_files: []
171
171
  files:
172
172
  - ".github/workflows/build-and-publish.yml"
173
+ - ".github/workflows/docs.yml"
173
174
  - ".github/workflows/test-and-lint.yml"
174
175
  - ".gitignore"
175
176
  - ".rspec"