crowdin-api 1.12.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +23 -1
- data/lib/crowdin-api/api_resources/applications.rb +5 -5
- data/lib/crowdin-api/api_resources/dictionaries.rb +7 -0
- data/lib/crowdin-api/api_resources/distributions.rb +22 -0
- data/lib/crowdin-api/api_resources/glossaries.rb +85 -0
- data/lib/crowdin-api/api_resources/string_corrections.rb +86 -0
- data/lib/crowdin-api/api_resources/tasks.rb +76 -0
- data/lib/crowdin-api/api_resources/translations.rb +14 -0
- data/lib/crowdin-api/client/client.rb +3 -8
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api/core/graphql_extensions.rb +22 -0
- data/lib/crowdin-api.rb +2 -1
- data/spec/api_resources/string_corrections_spec.rb +83 -0
- data/spec/api_resources/tasks_spec.rb +45 -0
- data/spec/api_resources/translations_spec.rb +10 -0
- data/spec/unit/client_spec.rb +47 -0
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98a60b3487c1824a37ef3519089f1e48e7de773f35734a54a981365707bbd80a
|
|
4
|
+
data.tar.gz: 0e5642b1b3446d55602f34ec4820b82e5d686e4002df0158371031141480bde1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a6ee9691d7ce60578c6438bf58874262edaa4dc8100723a2c9ad56b70828c97367a332401a47b9f098408d48dec4324714d83e5a1f73f3a2d683c829f3dc792f
|
|
7
|
+
data.tar.gz: cc3e2fbdc50836e014496c9990be79492817c878a8758b35044e5cecedf670eeed33390fb42ab1d32e5d52b9873344ee88a3fc11942e4a7513a1e3adf66269d5
|
data/Gemfile.lock
CHANGED
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.
|
|
38
|
+
gem 'crowdin-api', '~> 1.14.0'
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
And then execute:
|
|
@@ -134,6 +134,28 @@ file_revisions = crowdin.list_file_revisions(your_file_id, { limit: 10 }, your_p
|
|
|
134
134
|
# Note: more examples you can find in spec folder
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
+
### GraphQL API
|
|
138
|
+
|
|
139
|
+
The client can send GraphQL requests to Crowdin's default API host or to an Enterprise organization endpoint.
|
|
140
|
+
|
|
141
|
+
```ruby
|
|
142
|
+
query = <<~GRAPHQL
|
|
143
|
+
query Viewer {
|
|
144
|
+
viewer {
|
|
145
|
+
id
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
GRAPHQL
|
|
149
|
+
|
|
150
|
+
response = crowdin.graphql({ query: query })
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
You can also provide a custom endpoint URL for testing.
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
crowdin.graphql({ query: query }, url: 'http://localhost:3000/api/graphql')
|
|
157
|
+
```
|
|
158
|
+
|
|
137
159
|
### Fetch all records
|
|
138
160
|
|
|
139
161
|
There is a possibility to fetch all records from paginatable methods using `fetch_all` method.
|
|
@@ -7,7 +7,7 @@ module Crowdin
|
|
|
7
7
|
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.get API Documentation}
|
|
8
8
|
def get_application_data(application_identifier = nil, path = nil)
|
|
9
9
|
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
|
10
|
-
|
|
10
|
+
path || raise_parameter_is_required_error(:path)
|
|
11
11
|
|
|
12
12
|
request = Web::Request.new(
|
|
13
13
|
connection,
|
|
@@ -21,7 +21,7 @@ module Crowdin
|
|
|
21
21
|
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.put API Documentation}
|
|
22
22
|
def update_or_restore_application_data(query = {}, application_identifier = nil, path = nil)
|
|
23
23
|
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
|
24
|
-
|
|
24
|
+
path || raise_parameter_is_required_error(:path)
|
|
25
25
|
|
|
26
26
|
request = Web::Request.new(
|
|
27
27
|
connection,
|
|
@@ -36,7 +36,7 @@ module Crowdin
|
|
|
36
36
|
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.put API Documentation}
|
|
37
37
|
def add_application_data(query = {}, application_identifier = nil, path = nil)
|
|
38
38
|
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
|
39
|
-
|
|
39
|
+
path || raise_parameter_is_required_error(:path)
|
|
40
40
|
|
|
41
41
|
request = Web::Request.new(
|
|
42
42
|
connection,
|
|
@@ -51,7 +51,7 @@ module Crowdin
|
|
|
51
51
|
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.delete API Documentation}
|
|
52
52
|
def delete_application_data(query = {}, application_identifier = nil, path = nil)
|
|
53
53
|
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
|
54
|
-
|
|
54
|
+
path || raise_parameter_is_required_error(:path)
|
|
55
55
|
|
|
56
56
|
request = Web::Request.new(
|
|
57
57
|
connection,
|
|
@@ -66,7 +66,7 @@ module Crowdin
|
|
|
66
66
|
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.patch API Documentation}
|
|
67
67
|
def edit_application_data(query = {}, application_identifier = nil, path = nil)
|
|
68
68
|
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
|
69
|
-
|
|
69
|
+
path || raise_parameter_is_required_error(:path)
|
|
70
70
|
|
|
71
71
|
request = Web::Request.new(
|
|
72
72
|
connection,
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module Crowdin
|
|
4
4
|
module ApiResources
|
|
5
5
|
module Dictionaries
|
|
6
|
+
# @param query [Hash] Request Body
|
|
7
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Dictionaries/operation/api.projects.dictionaries.getMany API Documentation}
|
|
8
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Dictionaries/operation/api.projects.dictionaries.getMany Enterprise API Documentation}
|
|
6
9
|
def list_dictionaries(query = {}, project_id = config.project_id)
|
|
7
10
|
project_id || raise_project_id_is_required_error
|
|
8
11
|
|
|
@@ -15,6 +18,10 @@ module Crowdin
|
|
|
15
18
|
Web::SendRequest.new(request).perform
|
|
16
19
|
end
|
|
17
20
|
|
|
21
|
+
# @param language_id [String] Language Identifier
|
|
22
|
+
# @param query [Hash] Request Body
|
|
23
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Dictionaries/operation/api.projects.dictionaries.patch API Documentation}
|
|
24
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Dictionaries/operation/api.projects.dictionaries.patch Enterprise API Documentation}
|
|
18
25
|
def edit_dictionary(language_id = nil, query = {}, project_id = config.project_id)
|
|
19
26
|
language_id || raise_parameter_is_required_error(:language_id)
|
|
20
27
|
project_id || raise_project_id_is_required_error
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module Crowdin
|
|
4
4
|
module ApiResources
|
|
5
5
|
module Distributions
|
|
6
|
+
# @param query [Hash] Request Body
|
|
7
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Distributions/operation/api.projects.distributions.getMany API Documentation}
|
|
8
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Distributions/operation/api.projects.distributions.getMany Enterprise API Documentation}
|
|
6
9
|
def list_distributions(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://support.crowdin.com/developer/api/v2/#tag/Distributions/operation/api.projects.distributions.post API Documentation}
|
|
23
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Distributions/operation/api.projects.distributions.post Enterprise API Documentation}
|
|
18
24
|
def add_distribution(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 hash [String] Hash
|
|
37
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Distributions/operation/api.projects.distributions.get API Documentation}
|
|
38
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Distributions/operation/api.projects.distributions.get Enterprise API Documentation}
|
|
30
39
|
def get_distribution(hash = nil, project_id = config.project_id)
|
|
31
40
|
hash || raise_parameter_is_required_error(:hash)
|
|
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 hash [String] Hash
|
|
52
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Distributions/operation/api.projects.distributions.delete API Documentation}
|
|
53
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Distributions/operation/api.projects.distributions.delete Enterprise API Documentation}
|
|
42
54
|
def delete_distribution(hash = nil, project_id = config.project_id)
|
|
43
55
|
hash || raise_parameter_is_required_error(:hash)
|
|
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 hash [String] Hash
|
|
67
|
+
# @param query [Hash] Request Body
|
|
68
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Distributions/operation/api.projects.distributions.patch API Documentation}
|
|
69
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Distributions/operation/api.projects.distributions.patch Enterprise API Documentation}
|
|
54
70
|
def edit_distribution(hash = nil, query = {}, project_id = config.project_id)
|
|
55
71
|
hash || raise_parameter_is_required_error(:hash)
|
|
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 hash [String] Hash
|
|
84
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Distributions/operation/api.projects.distributions.release.get API Documentation}
|
|
85
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Distributions/operation/api.projects.distributions.release.get Enterprise API Documentation}
|
|
67
86
|
def get_distribution_release(hash = nil, project_id = config.project_id)
|
|
68
87
|
hash || raise_parameter_is_required_error(:hash)
|
|
69
88
|
project_id || raise_project_id_is_required_error
|
|
@@ -76,6 +95,9 @@ module Crowdin
|
|
|
76
95
|
Web::SendRequest.new(request).perform
|
|
77
96
|
end
|
|
78
97
|
|
|
98
|
+
# @param hash [String] Hash
|
|
99
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Distributions/operation/api.projects.distributions.release.post API Documentation}
|
|
100
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Distributions/operation/api.projects.distributions.release.post Enterprise API Documentation}
|
|
79
101
|
def release_distribution(hash = nil, project_id = config.project_id)
|
|
80
102
|
hash || raise_parameter_is_required_error(:hash)
|
|
81
103
|
project_id || raise_project_id_is_required_error
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module Crowdin
|
|
4
4
|
module ApiResources
|
|
5
5
|
module Glossaries
|
|
6
|
+
# @param query [Hash] Request Body
|
|
7
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.getMany API Documentation}
|
|
8
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.getMany Enterprise API Documentation}
|
|
6
9
|
def list_glossaries(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 query [Hash] Request Body
|
|
20
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.post API Documentation}
|
|
21
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.post Enterprise API Documentation}
|
|
16
22
|
def add_glossary(query = {})
|
|
17
23
|
request = Web::Request.new(
|
|
18
24
|
connection,
|
|
@@ -23,6 +29,10 @@ module Crowdin
|
|
|
23
29
|
Web::SendRequest.new(request).perform
|
|
24
30
|
end
|
|
25
31
|
|
|
32
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
33
|
+
# @param query [Hash] Request Body
|
|
34
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.get API Documentation}
|
|
35
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.get Enterprise API Documentation}
|
|
26
36
|
def get_glossary(glossary_id = nil, query = {})
|
|
27
37
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
28
38
|
|
|
@@ -35,6 +45,9 @@ module Crowdin
|
|
|
35
45
|
Web::SendRequest.new(request).perform
|
|
36
46
|
end
|
|
37
47
|
|
|
48
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
49
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.delete API Documentation}
|
|
50
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.delete Enterprise API Documentation}
|
|
38
51
|
def delete_glossary(glossary_id = nil)
|
|
39
52
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
40
53
|
|
|
@@ -46,6 +59,10 @@ module Crowdin
|
|
|
46
59
|
Web::SendRequest.new(request).perform
|
|
47
60
|
end
|
|
48
61
|
|
|
62
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
63
|
+
# @param query [Hash] Request Body
|
|
64
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.patch API Documentation}
|
|
65
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.patch Enterprise API Documentation}
|
|
49
66
|
def edit_glossary(glossary_id = nil, query = {})
|
|
50
67
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
51
68
|
|
|
@@ -58,6 +75,11 @@ module Crowdin
|
|
|
58
75
|
Web::SendRequest.new(request).perform
|
|
59
76
|
end
|
|
60
77
|
|
|
78
|
+
# @param query [Hash] Request Body
|
|
79
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
80
|
+
# @param destination [String] File destination
|
|
81
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.exports.post API Documentation}
|
|
82
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.exports.post Enterprise API Documentation}
|
|
61
83
|
def export_glossary(query = {}, glossary_id = nil, destination = nil)
|
|
62
84
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
63
85
|
|
|
@@ -70,6 +92,10 @@ module Crowdin
|
|
|
70
92
|
Web::SendRequest.new(request, destination).perform
|
|
71
93
|
end
|
|
72
94
|
|
|
95
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
96
|
+
# @param export_id [String] Export Identifier, consists of 36 characters
|
|
97
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.exports.get API Documentation}
|
|
98
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.exports.get Enterprise API Documentation}
|
|
73
99
|
def check_glossary_export_status(glossary_id = nil, export_id = nil)
|
|
74
100
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
75
101
|
export_id || raise_parameter_is_required_error(:export_id)
|
|
@@ -82,6 +108,11 @@ module Crowdin
|
|
|
82
108
|
Web::SendRequest.new(request).perform
|
|
83
109
|
end
|
|
84
110
|
|
|
111
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
112
|
+
# @param export_id [String] Export Identifier, consists of 36 characters
|
|
113
|
+
# @param destination [String] File destination
|
|
114
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.exports.download.download API Documentation}
|
|
115
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.exports.download.download Enterprise API Documentation}
|
|
85
116
|
def download_glossary(glossary_id = nil, export_id = nil, destination = nil)
|
|
86
117
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
87
118
|
export_id || raise_parameter_is_required_error(:export_id)
|
|
@@ -94,6 +125,10 @@ module Crowdin
|
|
|
94
125
|
Web::SendRequest.new(request, destination).perform
|
|
95
126
|
end
|
|
96
127
|
|
|
128
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
129
|
+
# @param query [Hash] Request Body
|
|
130
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.imports.post API Documentation}
|
|
131
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.imports.post Enterprise API Documentation}
|
|
97
132
|
def import_glossary(glossary_id = nil, query = {})
|
|
98
133
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
99
134
|
|
|
@@ -106,6 +141,10 @@ module Crowdin
|
|
|
106
141
|
Web::SendRequest.new(request).perform
|
|
107
142
|
end
|
|
108
143
|
|
|
144
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
145
|
+
# @param import_id [String] Import Identifier, consists of 36 characters
|
|
146
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.imports.get API Documentation}
|
|
147
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.imports.get Enterprise API Documentation}
|
|
109
148
|
def check_glossary_import_status(glossary_id = nil, import_id = nil)
|
|
110
149
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
111
150
|
import_id || raise_parameter_is_required_error(:import_id)
|
|
@@ -118,6 +157,10 @@ module Crowdin
|
|
|
118
157
|
Web::SendRequest.new(request).perform
|
|
119
158
|
end
|
|
120
159
|
|
|
160
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
161
|
+
# @param query [Hash] Request Body
|
|
162
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.terms.getMany API Documentation}
|
|
163
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.terms.getMany Enterprise API Documentation}
|
|
121
164
|
def list_terms(glossary_id = nil, query = {})
|
|
122
165
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
123
166
|
|
|
@@ -130,6 +173,10 @@ module Crowdin
|
|
|
130
173
|
Web::SendRequest.new(request).perform
|
|
131
174
|
end
|
|
132
175
|
|
|
176
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
177
|
+
# @param query [Hash] Request Body
|
|
178
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.terms.post API Documentation}
|
|
179
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.terms.post Enterprise API Documentation}
|
|
133
180
|
def add_term(glossary_id = nil, query = {})
|
|
134
181
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
135
182
|
|
|
@@ -142,6 +189,10 @@ module Crowdin
|
|
|
142
189
|
Web::SendRequest.new(request).perform
|
|
143
190
|
end
|
|
144
191
|
|
|
192
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
193
|
+
# @param query [Hash] Request Body
|
|
194
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.terms.deleteMany API Documentation}
|
|
195
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.terms.deleteMany Enterprise API Documentation}
|
|
145
196
|
def clear_glossary(glossary_id = nil, query = {})
|
|
146
197
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
147
198
|
|
|
@@ -158,6 +209,10 @@ module Crowdin
|
|
|
158
209
|
e.message
|
|
159
210
|
end
|
|
160
211
|
|
|
212
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
213
|
+
# @param term_id [Integer] Term Identifier
|
|
214
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.terms.get API Documentation}
|
|
215
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.terms.get Enterprise API Documentation}
|
|
161
216
|
def get_term(glossary_id = nil, term_id = nil)
|
|
162
217
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
163
218
|
term_id || raise_parameter_is_required_error(:term_id)
|
|
@@ -170,6 +225,10 @@ module Crowdin
|
|
|
170
225
|
Web::SendRequest.new(request).perform
|
|
171
226
|
end
|
|
172
227
|
|
|
228
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
229
|
+
# @param term_id [Integer] Term Identifier
|
|
230
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.terms.delete API Documentation}
|
|
231
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.terms.delete Enterprise API Documentation}
|
|
173
232
|
def delete_term(glossary_id = nil, term_id = nil)
|
|
174
233
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
175
234
|
term_id || raise_parameter_is_required_error(:term_id)
|
|
@@ -182,6 +241,11 @@ module Crowdin
|
|
|
182
241
|
Web::SendRequest.new(request).perform
|
|
183
242
|
end
|
|
184
243
|
|
|
244
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
245
|
+
# @param term_id [Integer] Term Identifier
|
|
246
|
+
# @param query [Hash] Request Body
|
|
247
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.terms.patch API Documentation}
|
|
248
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.terms.patch Enterprise API Documentation}
|
|
185
249
|
def edit_term(glossary_id = nil, term_id = nil, query = {})
|
|
186
250
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
187
251
|
term_id || raise_parameter_is_required_error(:term_id)
|
|
@@ -195,6 +259,10 @@ module Crowdin
|
|
|
195
259
|
Web::SendRequest.new(request).perform
|
|
196
260
|
end
|
|
197
261
|
|
|
262
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
263
|
+
# @param query [Hash] Request Body
|
|
264
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.concepts.getMany API Documentation}
|
|
265
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.concepts.getMany Enterprise API Documentation}
|
|
198
266
|
def list_concepts(glossary_id = nil, query = {})
|
|
199
267
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
200
268
|
|
|
@@ -207,6 +275,10 @@ module Crowdin
|
|
|
207
275
|
Web::SendRequest.new(request).perform
|
|
208
276
|
end
|
|
209
277
|
|
|
278
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
279
|
+
# @param concept_id [Integer] Concept Identifier
|
|
280
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.concepts.get API Documentation}
|
|
281
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.concepts.get Enterprise API Documentation}
|
|
210
282
|
def get_concept(glossary_id = nil, concept_id = nil)
|
|
211
283
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
212
284
|
concept_id || raise_parameter_is_required_error(:concept_id)
|
|
@@ -219,6 +291,11 @@ module Crowdin
|
|
|
219
291
|
Web::SendRequest.new(request).perform
|
|
220
292
|
end
|
|
221
293
|
|
|
294
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
295
|
+
# @param concept_id [Integer] Concept Identifier
|
|
296
|
+
# @param query [Hash] Request Body
|
|
297
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.concepts.put API Documentation}
|
|
298
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.concepts.put Enterprise API Documentation}
|
|
222
299
|
def update_concept(glossary_id = nil, concept_id = nil, query = {})
|
|
223
300
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
224
301
|
concept_id || raise_parameter_is_required_error(:concept_id)
|
|
@@ -232,6 +309,10 @@ module Crowdin
|
|
|
232
309
|
Web::SendRequest.new(request).perform
|
|
233
310
|
end
|
|
234
311
|
|
|
312
|
+
# @param glossary_id [Integer] Glossary Identifier
|
|
313
|
+
# @param concept_id [Integer] Concept Identifier
|
|
314
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.glossaries.concepts.delete API Documentation}
|
|
315
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.glossaries.concepts.delete Enterprise API Documentation}
|
|
235
316
|
def delete_concept(glossary_id = nil, concept_id = nil)
|
|
236
317
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
237
318
|
concept_id || raise_parameter_is_required_error(:concept_id)
|
|
@@ -244,6 +325,10 @@ module Crowdin
|
|
|
244
325
|
Web::SendRequest.new(request).perform
|
|
245
326
|
end
|
|
246
327
|
|
|
328
|
+
# @param project_id [Integer] Project Identifier
|
|
329
|
+
# @param query [Hash] Request Body
|
|
330
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Glossaries/operation/api.projects.glossaries.concordance.post API Documentation}
|
|
331
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Glossaries/operation/api.projects.glossaries.concordance.post Enterprise API Documentation}
|
|
247
332
|
def search_glossaries_concordance(project_id = nil, query = {})
|
|
248
333
|
project_id || raise_project_id_is_required_error
|
|
249
334
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crowdin
|
|
4
|
+
module ApiResources
|
|
5
|
+
module StringCorrections
|
|
6
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/String-Corrections/operation/api.projects.corrections.getMany Enterprise API Documentation}
|
|
7
|
+
def list_corrections(query = {}, project_id = config.project_id)
|
|
8
|
+
project_id || raise_project_id_is_required_error
|
|
9
|
+
|
|
10
|
+
request = Web::Request.new(
|
|
11
|
+
connection,
|
|
12
|
+
:get,
|
|
13
|
+
"#{config.target_api_url}/projects/#{project_id}/corrections",
|
|
14
|
+
{ params: query }
|
|
15
|
+
)
|
|
16
|
+
Web::SendRequest.new(request).perform
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/String-Corrections/operation/api.projects.corrections.post Enterprise API Documentation}
|
|
20
|
+
def add_correction(body = {}, project_id = config.project_id)
|
|
21
|
+
project_id || raise_project_id_is_required_error
|
|
22
|
+
|
|
23
|
+
request = Web::Request.new(
|
|
24
|
+
connection,
|
|
25
|
+
:post,
|
|
26
|
+
"#{config.target_api_url}/projects/#{project_id}/corrections",
|
|
27
|
+
{ params: body }
|
|
28
|
+
)
|
|
29
|
+
Web::SendRequest.new(request).perform
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/String-Corrections/operation/api.projects.corrections.get Enterprise API Documentation}
|
|
33
|
+
def get_correction(correction_id = nil, query = {}, project_id = config.project_id)
|
|
34
|
+
correction_id || raise_parameter_is_required_error(:correction_id)
|
|
35
|
+
project_id || raise_project_id_is_required_error
|
|
36
|
+
|
|
37
|
+
request = Web::Request.new(
|
|
38
|
+
connection,
|
|
39
|
+
:get,
|
|
40
|
+
"#{config.target_api_url}/projects/#{project_id}/corrections/#{correction_id}",
|
|
41
|
+
{ params: query }
|
|
42
|
+
)
|
|
43
|
+
Web::SendRequest.new(request).perform
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/String-Corrections/operation/api.projects.corrections.deleteMany Enterprise API Documentation}
|
|
47
|
+
def delete_corrections(query = {}, project_id = config.project_id)
|
|
48
|
+
project_id || raise_project_id_is_required_error
|
|
49
|
+
|
|
50
|
+
request = Web::Request.new(
|
|
51
|
+
connection,
|
|
52
|
+
:delete,
|
|
53
|
+
"#{config.target_api_url}/projects/#{project_id}/corrections",
|
|
54
|
+
{ params: query }
|
|
55
|
+
)
|
|
56
|
+
Web::SendRequest.new(request).perform
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/String-Corrections/operation/api.projects.corrections.delete Enterprise API Documentation}
|
|
60
|
+
def delete_correction(correction_id = nil, project_id = config.project_id)
|
|
61
|
+
correction_id || raise_parameter_is_required_error(:correction_id)
|
|
62
|
+
project_id || raise_project_id_is_required_error
|
|
63
|
+
|
|
64
|
+
request = Web::Request.new(
|
|
65
|
+
connection,
|
|
66
|
+
:delete,
|
|
67
|
+
"#{config.target_api_url}/projects/#{project_id}/corrections/#{correction_id}"
|
|
68
|
+
)
|
|
69
|
+
Web::SendRequest.new(request).perform
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/String-Corrections/operation/api.projects.corrections.put Enterprise API Documentation}
|
|
73
|
+
def restore_correction(correction_id = nil, project_id = config.project_id)
|
|
74
|
+
correction_id || raise_parameter_is_required_error(:correction_id)
|
|
75
|
+
project_id || raise_project_id_is_required_error
|
|
76
|
+
|
|
77
|
+
request = Web::Request.new(
|
|
78
|
+
connection,
|
|
79
|
+
:put,
|
|
80
|
+
"#{config.target_api_url}/projects/#{project_id}/corrections/#{correction_id}"
|
|
81
|
+
)
|
|
82
|
+
Web::SendRequest.new(request).perform
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -97,6 +97,82 @@ module Crowdin
|
|
|
97
97
|
)
|
|
98
98
|
Web::SendRequest.new(request).perform
|
|
99
99
|
end
|
|
100
|
+
|
|
101
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.getMany API Documentation}
|
|
102
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.getMany Enterprise API Documentation}
|
|
103
|
+
def list_task_comments(task_id = nil, query = {}, project_id = config.project_id)
|
|
104
|
+
project_id || raise_project_id_is_required_error
|
|
105
|
+
task_id || raise_parameter_is_required_error(:task_id)
|
|
106
|
+
|
|
107
|
+
request = Web::Request.new(
|
|
108
|
+
connection,
|
|
109
|
+
:get,
|
|
110
|
+
"#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments",
|
|
111
|
+
{ params: query }
|
|
112
|
+
)
|
|
113
|
+
Web::SendRequest.new(request).perform
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.get API Documentation}
|
|
117
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.get Enterprise API Documentation}
|
|
118
|
+
def get_task_comment(task_id = nil, comment_id = nil, project_id = config.project_id)
|
|
119
|
+
project_id || raise_project_id_is_required_error
|
|
120
|
+
task_id || raise_parameter_is_required_error(:task_id)
|
|
121
|
+
comment_id || raise_parameter_is_required_error(:comment_id)
|
|
122
|
+
|
|
123
|
+
request = Web::Request.new(
|
|
124
|
+
connection,
|
|
125
|
+
:get,
|
|
126
|
+
"#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments/#{comment_id}"
|
|
127
|
+
)
|
|
128
|
+
Web::SendRequest.new(request).perform
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.post API Documentation}
|
|
132
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.post Enterprise API Documentation}
|
|
133
|
+
def add_task_comment(task_id = nil, body = {}, project_id = config.project_id)
|
|
134
|
+
project_id || raise_project_id_is_required_error
|
|
135
|
+
task_id || raise_parameter_is_required_error(:task_id)
|
|
136
|
+
|
|
137
|
+
request = Web::Request.new(
|
|
138
|
+
connection,
|
|
139
|
+
:post,
|
|
140
|
+
"#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments",
|
|
141
|
+
{ params: body }
|
|
142
|
+
)
|
|
143
|
+
Web::SendRequest.new(request).perform
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.patch API Documentation}
|
|
147
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.patch Enterprise API Documentation}
|
|
148
|
+
def edit_task_comment(task_id = nil, comment_id = nil, body = {}, project_id = config.project_id)
|
|
149
|
+
project_id || raise_project_id_is_required_error
|
|
150
|
+
task_id || raise_parameter_is_required_error(:task_id)
|
|
151
|
+
comment_id || raise_parameter_is_required_error(:comment_id)
|
|
152
|
+
|
|
153
|
+
request = Web::Request.new(
|
|
154
|
+
connection,
|
|
155
|
+
:patch,
|
|
156
|
+
"#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments/#{comment_id}",
|
|
157
|
+
{ params: body }
|
|
158
|
+
)
|
|
159
|
+
Web::SendRequest.new(request).perform
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.delete API Documentation}
|
|
163
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.delete Enterprise API Documentation}
|
|
164
|
+
def delete_task_comment(task_id = nil, comment_id = nil, project_id = config.project_id)
|
|
165
|
+
project_id || raise_project_id_is_required_error
|
|
166
|
+
task_id || raise_parameter_is_required_error(:task_id)
|
|
167
|
+
comment_id || raise_parameter_is_required_error(:comment_id)
|
|
168
|
+
|
|
169
|
+
request = Web::Request.new(
|
|
170
|
+
connection,
|
|
171
|
+
:delete,
|
|
172
|
+
"#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments/#{comment_id}"
|
|
173
|
+
)
|
|
174
|
+
Web::SendRequest.new(request).perform
|
|
175
|
+
end
|
|
100
176
|
end
|
|
101
177
|
end
|
|
102
178
|
end
|
|
@@ -52,6 +52,20 @@ module Crowdin
|
|
|
52
52
|
Web::SendRequest.new(request).perform
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
# * {https://support.crowdin.com/developer/api/v2/#tag/Translations/operation/api.projects.pre-translations.report.getReport API Documentation}
|
|
56
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#tag/Translations/operation/api.projects.pre-translations.report.getReport Enterprise API Documentation}
|
|
57
|
+
def pre_translation_report(pre_translation_id = nil, project_id = config.project_id)
|
|
58
|
+
pre_translation_id || raise_parameter_is_required_error(:pre_translation_id)
|
|
59
|
+
project_id || raise_project_id_is_required_error
|
|
60
|
+
|
|
61
|
+
request = Web::Request.new(
|
|
62
|
+
connection,
|
|
63
|
+
:get,
|
|
64
|
+
"#{config.target_api_url}/projects/#{project_id}/pre-translations/#{pre_translation_id}/report"
|
|
65
|
+
)
|
|
66
|
+
Web::SendRequest.new(request).perform
|
|
67
|
+
end
|
|
68
|
+
|
|
55
69
|
def build_project_directory_translation(directory_id = nil, query = {}, project_id = config.project_id)
|
|
56
70
|
directory_id || raise_parameter_is_required_error(:directory_id)
|
|
57
71
|
project_id || raise_project_id_is_required_error
|
|
@@ -31,15 +31,10 @@ module Crowdin
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
include Web::FetchAllExtensions
|
|
34
|
+
include Web::GraphqlExtensions
|
|
34
35
|
|
|
35
|
-
#
|
|
36
|
-
attr_reader :config
|
|
37
|
-
# Instance with established connection through RestClient to the Crowdin API
|
|
38
|
-
attr_reader :connection
|
|
39
|
-
# Instance with options and headers for RestClient connection
|
|
40
|
-
attr_reader :options
|
|
41
|
-
# Logger instance
|
|
42
|
-
attr_reader :logger
|
|
36
|
+
# Client configuration, connection, request options, and logger instances
|
|
37
|
+
attr_reader :config, :connection, :options, :logger
|
|
43
38
|
|
|
44
39
|
def initialize(&block)
|
|
45
40
|
build_configuration(&block)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crowdin
|
|
4
|
+
module Web
|
|
5
|
+
module GraphqlExtensions
|
|
6
|
+
def graphql(query = nil, **request_options)
|
|
7
|
+
url = request_options.delete(:url)
|
|
8
|
+
graphql_query = query || request_options
|
|
9
|
+
|
|
10
|
+
response = ::RestClient::Request.execute(
|
|
11
|
+
{
|
|
12
|
+
method: :post,
|
|
13
|
+
url: url || "#{config.base_url}/api/graphql",
|
|
14
|
+
payload: graphql_query.to_json
|
|
15
|
+
}.merge(options)
|
|
16
|
+
) { |res, _, _| res }
|
|
17
|
+
|
|
18
|
+
response.body.empty? ? response.code : JSON.parse(response.body)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/crowdin-api.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Crowdin
|
|
|
6
6
|
StringTranslations StringComments Screenshots Glossaries TranslationMemory
|
|
7
7
|
MachineTranslationEngines Reports Tasks Users Teams Vendors Webhooks
|
|
8
8
|
Dictionaries Distributions Labels TranslationStatus Bundles Notifications
|
|
9
|
-
Applications].freeze
|
|
9
|
+
Applications StringCorrections].freeze
|
|
10
10
|
|
|
11
11
|
# Error Raisers modules
|
|
12
12
|
ERROR_RAISERS_MODULES = %i[ApiErrorsRaiser ClientErrorsRaiser].freeze
|
|
@@ -23,6 +23,7 @@ require 'crowdin-api/core/errors_raisers'
|
|
|
23
23
|
require 'crowdin-api/core/request'
|
|
24
24
|
require 'crowdin-api/core/send_request'
|
|
25
25
|
require 'crowdin-api/core/fetch_all_extensions'
|
|
26
|
+
require 'crowdin-api/core/graphql_extensions'
|
|
26
27
|
|
|
27
28
|
# API modules
|
|
28
29
|
Crowdin::API_RESOURCES_MODULES.each do |api_resource|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe Crowdin::ApiResources::StringCorrections do
|
|
4
|
+
describe 'Default endpoints' do
|
|
5
|
+
let(:correction_id) { 35 }
|
|
6
|
+
let(:string_id) { 2 }
|
|
7
|
+
|
|
8
|
+
describe '#list_corrections' do
|
|
9
|
+
it 'when request is valid', :default do
|
|
10
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/corrections")
|
|
11
|
+
.with(query: { stringId: string_id })
|
|
12
|
+
list_corrections = @crowdin.list_corrections({ stringId: string_id }, project_id)
|
|
13
|
+
expect(list_corrections).to eq(200)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'when request is valid', :default do
|
|
17
|
+
query = { stringId: string_id, limit: 50, offset: 10, orderBy: 'createdAt desc', denormalizePlaceholders: 1 }
|
|
18
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/corrections")
|
|
19
|
+
.with(query: query)
|
|
20
|
+
list_corrections = @crowdin.list_corrections(query, project_id)
|
|
21
|
+
expect(list_corrections).to eq(200)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '#add_correction' do
|
|
26
|
+
it 'when request is valid', :default do
|
|
27
|
+
body = { stringId: 35_434, text: 'This string has been corrected', pluralCategoryName: 'few' }
|
|
28
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/corrections")
|
|
29
|
+
.with(body: body)
|
|
30
|
+
add_correction = @crowdin.add_correction(body, project_id)
|
|
31
|
+
expect(add_correction).to eq(200)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'when request is valid', :default do
|
|
35
|
+
body = { stringId: 35_434, text: 'This string has been corrected' }
|
|
36
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/corrections")
|
|
37
|
+
.with(body: body)
|
|
38
|
+
add_correction = @crowdin.add_correction(body, project_id)
|
|
39
|
+
expect(add_correction).to eq(200)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe '#get_correction' do
|
|
44
|
+
it 'when request is valid', :default do
|
|
45
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/corrections/#{correction_id}")
|
|
46
|
+
get_correction = @crowdin.get_correction(correction_id, {}, project_id)
|
|
47
|
+
expect(get_correction).to eq(200)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'when request is valid', :default do
|
|
51
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/corrections/#{correction_id}")
|
|
52
|
+
.with(query: { denormalizePlaceholders: 1 })
|
|
53
|
+
get_correction = @crowdin.get_correction(correction_id, { denormalizePlaceholders: 1 }, project_id)
|
|
54
|
+
expect(get_correction).to eq(200)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe '#delete_corrections' do
|
|
59
|
+
it 'when request is valid', :default do
|
|
60
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/corrections")
|
|
61
|
+
.with(query: { stringId: string_id })
|
|
62
|
+
delete_corrections = @crowdin.delete_corrections({ stringId: string_id }, project_id)
|
|
63
|
+
expect(delete_corrections).to eq(200)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe '#delete_correction' do
|
|
68
|
+
it 'when request is valid', :default do
|
|
69
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/corrections/#{correction_id}")
|
|
70
|
+
delete_correction = @crowdin.delete_correction(correction_id, project_id)
|
|
71
|
+
expect(delete_correction).to eq(200)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe '#restore_correction' do
|
|
76
|
+
it 'when request is valid', :default do
|
|
77
|
+
stub_request(:put, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/corrections/#{correction_id}")
|
|
78
|
+
restore_correction = @crowdin.restore_correction(correction_id, project_id)
|
|
79
|
+
expect(restore_correction).to eq(200)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -76,4 +76,49 @@ describe Crowdin::ApiResources::Tasks do
|
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
|
+
|
|
80
|
+
describe 'Task Comments endpoints' do
|
|
81
|
+
let(:task_id) { 1 }
|
|
82
|
+
let(:comment_id) { 101 }
|
|
83
|
+
|
|
84
|
+
describe '#list_task_comments' do
|
|
85
|
+
it 'when request is valid', :default do
|
|
86
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments")
|
|
87
|
+
list_task_comments = @crowdin.list_task_comments(task_id, {}, project_id)
|
|
88
|
+
expect(list_task_comments).to eq(200)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe '#get_task_comment' do
|
|
93
|
+
it 'when request is valid', :default do
|
|
94
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments/#{comment_id}")
|
|
95
|
+
get_task_comment = @crowdin.get_task_comment(task_id, comment_id, project_id)
|
|
96
|
+
expect(get_task_comment).to eq(200)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe '#add_task_comment' do
|
|
101
|
+
it 'when request is valid', :default do
|
|
102
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments")
|
|
103
|
+
add_task_comment = @crowdin.add_task_comment(task_id, { text: 'New comment' }, project_id)
|
|
104
|
+
expect(add_task_comment).to eq(200)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe '#edit_task_comment' do
|
|
109
|
+
it 'when request is valid', :default do
|
|
110
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments/#{comment_id}")
|
|
111
|
+
edit_task_comment = @crowdin.edit_task_comment(task_id, comment_id, { text: 'Updated comment' }, project_id)
|
|
112
|
+
expect(edit_task_comment).to eq(200)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe '#delete_task_comment' do
|
|
117
|
+
it 'when request is valid', :default do
|
|
118
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks/#{task_id}/comments/#{comment_id}")
|
|
119
|
+
delete_task_comment = @crowdin.delete_task_comment(task_id, comment_id, project_id)
|
|
120
|
+
expect(delete_task_comment).to eq(200)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
79
124
|
end
|
|
@@ -38,6 +38,16 @@ describe Crowdin::ApiResources::Translations do
|
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
describe '#pre_translation_report' do
|
|
42
|
+
let(:pre_translation_id) { 1 }
|
|
43
|
+
|
|
44
|
+
it 'when request are valid', :default do
|
|
45
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/pre-translations/#{pre_translation_id}/report")
|
|
46
|
+
pre_translation_report = @crowdin.pre_translation_report(pre_translation_id, project_id)
|
|
47
|
+
expect(pre_translation_report).to eq(200)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
41
51
|
describe '#build_project_directory_translation' do
|
|
42
52
|
let(:directory_id) { 1 }
|
|
43
53
|
|
data/spec/unit/client_spec.rb
CHANGED
|
@@ -98,6 +98,53 @@ describe 'Crowdin Client' do
|
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
+
describe 'Crowdin Client graphql' do
|
|
102
|
+
let(:graphql_request) do
|
|
103
|
+
{
|
|
104
|
+
query: 'query Viewer { viewer { id } }',
|
|
105
|
+
operationName: 'Viewer',
|
|
106
|
+
variables: { projectId: 1, emptyValue: nil }
|
|
107
|
+
}
|
|
108
|
+
end
|
|
109
|
+
let(:graphql_response) { { 'data' => { 'viewer' => { 'id' => 1 } } } }
|
|
110
|
+
|
|
111
|
+
it 'posts to the default GraphQL endpoint', :default do
|
|
112
|
+
stub_request(:post, 'https://api.crowdin.com/api/graphql')
|
|
113
|
+
.with(body: graphql_request.to_json)
|
|
114
|
+
.to_return(body: graphql_response.to_json)
|
|
115
|
+
|
|
116
|
+
expect(@crowdin.graphql(graphql_request)).to eq(graphql_response)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it 'posts to the Enterprise GraphQL endpoint', :enterprise do
|
|
120
|
+
stub_request(:post, 'https://domain.api.crowdin.com/api/graphql')
|
|
121
|
+
.with(body: graphql_request.to_json)
|
|
122
|
+
.to_return(body: graphql_response.to_json)
|
|
123
|
+
|
|
124
|
+
expect(@crowdin.graphql(graphql_request)).to eq(graphql_response)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'supports a custom GraphQL endpoint URL', :default do
|
|
128
|
+
custom_url = 'http://localhost:3000/api/graphql'
|
|
129
|
+
|
|
130
|
+
stub_request(:post, custom_url)
|
|
131
|
+
.with(body: graphql_request.to_json)
|
|
132
|
+
.to_return(body: graphql_response.to_json)
|
|
133
|
+
|
|
134
|
+
expect(@crowdin.graphql(graphql_request, url: custom_url)).to eq(graphql_response)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'returns parsed GraphQL error responses', :default do
|
|
138
|
+
graphql_error_response = { 'errors' => [{ 'message' => 'Invalid query' }] }
|
|
139
|
+
|
|
140
|
+
stub_request(:post, 'https://api.crowdin.com/api/graphql')
|
|
141
|
+
.with(body: graphql_request.to_json)
|
|
142
|
+
.to_return(status: 400, body: graphql_error_response.to_json)
|
|
143
|
+
|
|
144
|
+
expect(@crowdin.graphql(graphql_request)).to eq(graphql_error_response)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
101
148
|
describe 'connection' do
|
|
102
149
|
subject(:connection) { crowdin_client.connection }
|
|
103
150
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: crowdin-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Crowdin
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: open-uri
|
|
@@ -221,6 +220,7 @@ files:
|
|
|
221
220
|
- lib/crowdin-api/api_resources/source_strings.rb
|
|
222
221
|
- lib/crowdin-api/api_resources/storages.rb
|
|
223
222
|
- lib/crowdin-api/api_resources/string_comments.rb
|
|
223
|
+
- lib/crowdin-api/api_resources/string_corrections.rb
|
|
224
224
|
- lib/crowdin-api/api_resources/string_translations.rb
|
|
225
225
|
- lib/crowdin-api/api_resources/tasks.rb
|
|
226
226
|
- lib/crowdin-api/api_resources/teams.rb
|
|
@@ -237,6 +237,7 @@ files:
|
|
|
237
237
|
- lib/crowdin-api/core/errors.rb
|
|
238
238
|
- lib/crowdin-api/core/errors_raisers.rb
|
|
239
239
|
- lib/crowdin-api/core/fetch_all_extensions.rb
|
|
240
|
+
- lib/crowdin-api/core/graphql_extensions.rb
|
|
240
241
|
- lib/crowdin-api/core/request.rb
|
|
241
242
|
- lib/crowdin-api/core/send_request.rb
|
|
242
243
|
- spec/api_resources/applications_spec.rb
|
|
@@ -255,6 +256,7 @@ files:
|
|
|
255
256
|
- spec/api_resources/source_strings_spec.rb
|
|
256
257
|
- spec/api_resources/storages_spec.rb
|
|
257
258
|
- spec/api_resources/string_comments_spec.rb
|
|
259
|
+
- spec/api_resources/string_corrections_spec.rb
|
|
258
260
|
- spec/api_resources/string_translations_spec.rb
|
|
259
261
|
- spec/api_resources/tasks_spec.rb
|
|
260
262
|
- spec/api_resources/teams_spec.rb
|
|
@@ -271,7 +273,6 @@ homepage: https://github.com/crowdin/crowdin-api-client-ruby
|
|
|
271
273
|
licenses:
|
|
272
274
|
- MIT
|
|
273
275
|
metadata: {}
|
|
274
|
-
post_install_message:
|
|
275
276
|
rdoc_options: []
|
|
276
277
|
require_paths:
|
|
277
278
|
- lib
|
|
@@ -286,8 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
286
287
|
- !ruby/object:Gem::Version
|
|
287
288
|
version: '0'
|
|
288
289
|
requirements: []
|
|
289
|
-
rubygems_version: 3.
|
|
290
|
-
signing_key:
|
|
290
|
+
rubygems_version: 3.6.9
|
|
291
291
|
specification_version: 4
|
|
292
292
|
summary: Ruby Client for the Crowdin API
|
|
293
293
|
test_files: []
|