crowdin-api 1.13.0 → 1.15.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/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +1 -0
- data/AGENTS.md +63 -0
- data/CLAUDE.md +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +23 -1
- data/lib/crowdin-api/api_resources/advisor.rb +86 -0
- data/lib/crowdin-api/api_resources/ai.rb +974 -0
- data/lib/crowdin-api/api_resources/applications.rb +252 -15
- data/lib/crowdin-api/api_resources/bundles.rb +45 -29
- data/lib/crowdin-api/api_resources/clients.rb +23 -0
- data/lib/crowdin-api/api_resources/custom_spellcheckers.rb +36 -0
- data/lib/crowdin-api/api_resources/dictionaries.rb +5 -5
- data/lib/crowdin-api/api_resources/distributions.rb +15 -15
- data/lib/crowdin-api/api_resources/external_qa_checks.rb +36 -0
- data/lib/crowdin-api/api_resources/fields.rb +78 -0
- data/lib/crowdin-api/api_resources/glossaries.rb +62 -50
- data/lib/crowdin-api/api_resources/integrations.rb +201 -0
- data/lib/crowdin-api/api_resources/labels.rb +32 -0
- data/lib/crowdin-api/api_resources/languages.rb +16 -0
- data/lib/crowdin-api/api_resources/machine_translation_engines.rb +17 -0
- data/lib/crowdin-api/api_resources/notifications.rb +15 -6
- data/lib/crowdin-api/api_resources/organization.rb +33 -0
- data/lib/crowdin-api/api_resources/organization_webhooks.rb +71 -0
- data/lib/crowdin-api/api_resources/placeholders.rb +182 -0
- data/lib/crowdin-api/api_resources/projects.rb +137 -41
- data/lib/crowdin-api/api_resources/reports.rb +310 -26
- data/lib/crowdin-api/api_resources/screenshots.rb +48 -0
- data/lib/crowdin-api/api_resources/security_logs.rb +63 -0
- data/lib/crowdin-api/api_resources/source_files.rb +370 -65
- data/lib/crowdin-api/api_resources/source_strings.rb +62 -0
- data/lib/crowdin-api/api_resources/storages.rb +11 -11
- data/lib/crowdin-api/api_resources/string_comments.rb +46 -0
- data/lib/crowdin-api/api_resources/string_corrections.rb +21 -6
- data/lib/crowdin-api/api_resources/string_translations.rb +96 -0
- data/lib/crowdin-api/api_resources/style_guides.rb +71 -0
- data/lib/crowdin-api/api_resources/tasks.rb +140 -10
- data/lib/crowdin-api/api_resources/teams.rb +99 -0
- data/lib/crowdin-api/api_resources/translation_memory.rb +138 -0
- data/lib/crowdin-api/api_resources/translation_status.rb +65 -0
- data/lib/crowdin-api/api_resources/translations.rb +122 -2
- data/lib/crowdin-api/api_resources/users.rb +136 -6
- data/lib/crowdin-api/api_resources/vendors.rb +2 -0
- data/lib/crowdin-api/api_resources/webhooks.rb +16 -0
- data/lib/crowdin-api/api_resources/workflows.rb +24 -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/core/request.rb +1 -1
- data/lib/crowdin-api.rb +4 -1
- data/spec/api_resources/advisor_spec.rb +45 -0
- data/spec/api_resources/ai_spec.rb +863 -0
- data/spec/api_resources/applications_spec.rb +138 -0
- data/spec/api_resources/bundles_spec.rb +8 -0
- data/spec/api_resources/clients_spec.rb +13 -0
- data/spec/api_resources/custom_spellcheckers_spec.rb +21 -0
- data/spec/api_resources/external_qa_checks_spec.rb +21 -0
- data/spec/api_resources/fields_spec.rb +45 -0
- data/spec/api_resources/glossaries_spec.rb +18 -0
- data/spec/api_resources/integrations_spec.rb +117 -0
- data/spec/api_resources/organization_spec.rb +21 -0
- data/spec/api_resources/organization_webhooks_spec.rb +45 -0
- data/spec/api_resources/placeholders_spec.rb +103 -0
- data/spec/api_resources/projects_spec.rb +58 -0
- data/spec/api_resources/reports_spec.rb +221 -0
- data/spec/api_resources/security_logs_spec.rb +39 -0
- data/spec/api_resources/source_files_spec.rb +182 -0
- data/spec/api_resources/source_strings_spec.rb +26 -0
- data/spec/api_resources/string_comments_spec.rb +18 -0
- data/spec/api_resources/string_corrections_spec.rb +25 -19
- data/spec/api_resources/string_translations_spec.rb +26 -0
- data/spec/api_resources/style_guides_spec.rb +45 -0
- data/spec/api_resources/tasks_spec.rb +60 -0
- data/spec/api_resources/teams_spec.rb +42 -0
- data/spec/api_resources/translation_memory_spec.rb +58 -0
- data/spec/api_resources/translation_status_spec.rb +26 -0
- data/spec/api_resources/translations_spec.rb +42 -0
- data/spec/api_resources/users_spec.rb +84 -0
- data/spec/api_resources/workflows_spec.rb +10 -0
- data/spec/unit/client_spec.rb +47 -0
- metadata +28 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4bdb93529784382ee4d113d179869366097e30470da8e50e460d423df663f281
|
|
4
|
+
data.tar.gz: 0db2ee94c5d6ae47f6fb97421218297fdfccaffaf3c4c2f65dcc60332b7d9516
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47e744480df7814f0af17667a3353d1dc5d09857e94eb21d8aa2970ff5c7850882cd624a2f2f3ce5ed43573a4c3c812a8df8e143ec8a670f5a1bdca1165a8def
|
|
7
|
+
data.tar.gz: 794511fb64551fe49b67215d8213b793b8aa09f46eb5dbf8b6b31604f02d932f00986e0ad1e791e3d2dc2ee97398d594deed18b8408f378fdb8c9939786d4b36
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
data/AGENTS.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Ruby client for the Crowdin API v2 and Crowdin Enterprise API v2 (gem: `crowdin-api`, namespace `Crowdin`).
|
|
4
|
+
|
|
5
|
+
The gemspec requires Ruby >= 2.4 while CI tests 3.0–3.3 — stay conservative with syntax (no pattern matching, no endless methods).
|
|
6
|
+
|
|
7
|
+
## Layout
|
|
8
|
+
|
|
9
|
+
- `lib/crowdin-api.rb` — entry point; the `API_RESOURCES_MODULES` array plus requires
|
|
10
|
+
- `lib/crowdin-api/client/client.rb` — `Crowdin::Client`; mixes every resource module in
|
|
11
|
+
- `lib/crowdin-api/api_resources/<name>.rb` — one module per API resource, plain instance methods
|
|
12
|
+
- `lib/crowdin-api/core/` — request/response plumbing, errors, `fetch_all`, GraphQL
|
|
13
|
+
- `spec/api_resources/<name>_spec.rb` — 1:1 with resources; WebMock, no fixtures directory
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
- Install: `bundle install`
|
|
18
|
+
- Test (all): `bundle exec rspec` (or `bundle exec rake`)
|
|
19
|
+
- Test (one file): `bundle exec rspec spec/api_resources/<name>_spec.rb`
|
|
20
|
+
- Lint (CI runs this before the specs): `bundle exec rubocop`
|
|
21
|
+
- Lint autofix: `bundle exec rubocop -a`
|
|
22
|
+
|
|
23
|
+
## Adding or changing an endpoint
|
|
24
|
+
|
|
25
|
+
Fetch the endpoint spec first (see Crowdin API reference below). Then:
|
|
26
|
+
|
|
27
|
+
1. Implement the method in `lib/crowdin-api/api_resources/<snake_case>.rb` (`# frozen_string_literal: true`, then `module Crowdin` > `module ApiResources` > `module <CamelCase>`):
|
|
28
|
+
- Argument order: required path ids, then the `query`/`body` hash, then optional `destination` (file downloads), then `project_id = config.project_id` last. RuboCop caps optional parameters at 4 and this pattern already uses them all.
|
|
29
|
+
- Guards: `project_id || raise_project_id_is_required_error`; Enterprise-only methods start with `enterprise_mode? || raise_only_for_enterprise_mode_error` and sit under a `# -- For Enterprise mode only --` comment.
|
|
30
|
+
- Body: build `Web::Request.new(connection, :get, "#{config.target_api_url}/projects/#{project_id}/...", { params: query })` and return `Web::SendRequest.new(request).perform` (pass `destination` as the second argument to `SendRequest` for downloads).
|
|
31
|
+
- Name list endpoints `list_*` — `fetch_all` refuses anything else (and hard-codes extra args for `list_terms` and `list_file_revisions` in `client.rb`).
|
|
32
|
+
- Doc comment: two `{https://support.crowdin.com/developer/... API Documentation}` links (base and enterprise) plus YARD `@param` lines.
|
|
33
|
+
2. For a new resource, append the CamelCase symbol to `Crowdin::API_RESOURCES_MODULES` in `lib/crowdin-api.rb`. The file name must be the exact snake_case of that symbol: the require loop swallows `LoadError` silently and a mismatch surfaces later as an unrelated `NameError` from `const_get`. `client.rb` needs no edit — the include loop picks the module up.
|
|
34
|
+
3. Spec in `spec/api_resources/<snake_case>_spec.rb`: tag examples `:default` or `:enterprise` — `spec_helper.rb` prebuilds `@crowdin` and sets the WebMock host (`https://api.crowdin.com` vs `https://domain.api.crowdin.com`) from the tag. House idiom: `stub_request(...)` with no `.to_return`, then `expect(result).to eq(200)` — `perform` returns the HTTP status for an empty body, a parsed Hash otherwise, and an error String on failure (HTTP errors are returned, not raised).
|
|
35
|
+
|
|
36
|
+
A complete new resource touches exactly 3 files: the resource module, `lib/crowdin-api.rb`, and the spec.
|
|
37
|
+
|
|
38
|
+
## Crowdin API reference
|
|
39
|
+
|
|
40
|
+
Before implementing or changing any endpoint, fetch its spec from the llms.txt indexes (pick by environment, then project type):
|
|
41
|
+
|
|
42
|
+
- https://support.crowdin.com/_llms-txt/api/crowdin/file-based.txt — Crowdin API, file-based projects (start here)
|
|
43
|
+
- https://support.crowdin.com/_llms-txt/api/crowdin/string-based.txt — Crowdin API, string-based projects
|
|
44
|
+
- https://support.crowdin.com/_llms-txt/api/enterprise/file-based.txt — Crowdin Enterprise API, file-based projects
|
|
45
|
+
- https://support.crowdin.com/_llms-txt/api/enterprise/string-based.txt — Crowdin Enterprise API, string-based projects
|
|
46
|
+
|
|
47
|
+
Each index links one spec file per route (e.g. `.../api.projects.strings.get.txt`) with the exact request and response shapes.
|
|
48
|
+
|
|
49
|
+
## Conventions
|
|
50
|
+
|
|
51
|
+
- Conventional Commits for commit messages and PR titles; CI lints PR titles.
|
|
52
|
+
- PRs target `main`. CI runs RuboCop before the specs, so a lint failure blocks the test result.
|
|
53
|
+
- Keep the public API backward compatible.
|
|
54
|
+
- Never bump the version by hand — the Release workflow rewrites `lib/crowdin-api/client/version.rb`, the README install line, and `Gemfile.lock` together.
|
|
55
|
+
|
|
56
|
+
## PR checklist
|
|
57
|
+
|
|
58
|
+
A change is ready when:
|
|
59
|
+
|
|
60
|
+
1. `bundle exec rubocop` is clean,
|
|
61
|
+
2. `bundle exec rspec` passes,
|
|
62
|
+
3. every new or changed endpoint method has a spec (tagged `:default`, plus `:enterprise` where the API differs), and
|
|
63
|
+
4. every new or changed public method carries the two API documentation links.
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
AGENTS.md
|
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.15.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.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crowdin
|
|
4
|
+
module ApiResources
|
|
5
|
+
module Advisor
|
|
6
|
+
# @param body [Hash] Request Body
|
|
7
|
+
# * {https://support.crowdin.com/developer/api/v2/#operation/api.projects.advisors.checks.post API Documentation}
|
|
8
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.projects.advisors.checks.post Enterprise API Documentation}
|
|
9
|
+
def create_advisor_check(body = {}, project_id = config.project_id)
|
|
10
|
+
project_id || raise_project_id_is_required_error
|
|
11
|
+
|
|
12
|
+
request = Web::Request.new(
|
|
13
|
+
connection,
|
|
14
|
+
:post,
|
|
15
|
+
"#{config.target_api_url}/projects/#{project_id}/advisors/checks",
|
|
16
|
+
{ params: body }
|
|
17
|
+
)
|
|
18
|
+
Web::SendRequest.new(request).perform
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @param check_id [String] Advisor Check Identifier, consists of 36 characters
|
|
22
|
+
# * {https://support.crowdin.com/developer/api/v2/#operation/api.projects.advisors.checks.get API Documentation}
|
|
23
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.projects.advisors.checks.get Enterprise API Documentation}
|
|
24
|
+
def get_advisor_check_status(check_id, project_id = config.project_id)
|
|
25
|
+
project_id || raise_project_id_is_required_error
|
|
26
|
+
|
|
27
|
+
request = Web::Request.new(
|
|
28
|
+
connection,
|
|
29
|
+
:get,
|
|
30
|
+
"#{config.target_api_url}/projects/#{project_id}/advisors/checks/#{check_id}"
|
|
31
|
+
)
|
|
32
|
+
Web::SendRequest.new(request).perform
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @param query [Hash] Request Query Parameters
|
|
36
|
+
# * {https://support.crowdin.com/developer/api/v2/#operation/api.projects.advisors.insights.getMany API Documentation}
|
|
37
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.projects.advisors.insights.getMany Enterprise API Documentation}
|
|
38
|
+
def list_advisor_insights(query = {}, project_id = config.project_id)
|
|
39
|
+
project_id || raise_project_id_is_required_error
|
|
40
|
+
|
|
41
|
+
request = Web::Request.new(
|
|
42
|
+
connection,
|
|
43
|
+
:get,
|
|
44
|
+
"#{config.target_api_url}/projects/#{project_id}/advisors/insights",
|
|
45
|
+
{ params: query }
|
|
46
|
+
)
|
|
47
|
+
Web::SendRequest.new(request).perform
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @param insight_id [Integer] Insight Identifier
|
|
51
|
+
# @param body [Array] Request Body
|
|
52
|
+
# * {https://support.crowdin.com/developer/api/v2/#operation/api.projects.advisors.insights.patch API Documentation}
|
|
53
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.projects.advisors.insights.patch Enterprise API Documentation}
|
|
54
|
+
def edit_advisor_insight(insight_id, body = [], project_id = config.project_id)
|
|
55
|
+
project_id || raise_project_id_is_required_error
|
|
56
|
+
|
|
57
|
+
request = Web::Request.new(
|
|
58
|
+
connection,
|
|
59
|
+
:patch,
|
|
60
|
+
"#{config.target_api_url}/projects/#{project_id}/advisors/insights/#{insight_id}",
|
|
61
|
+
{ params: body }
|
|
62
|
+
)
|
|
63
|
+
Web::SendRequest.new(request).perform
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# @param application_identifier [String] applicationIdentifier
|
|
67
|
+
# @param module_key [String] moduleKey
|
|
68
|
+
# @param body [Hash] Request Body
|
|
69
|
+
# * {https://support.crowdin.com/developer/api/v2/#operation/api.projects.applications.modules.advisors.insights.put API Documentation}
|
|
70
|
+
# * {https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.projects.applications.modules.advisors.insights.put Enterprise API Documentation}
|
|
71
|
+
def create_or_update_application_advisor_insight(application_identifier, module_key, body = {},
|
|
72
|
+
project_id = config.project_id)
|
|
73
|
+
project_id || raise_project_id_is_required_error
|
|
74
|
+
|
|
75
|
+
endpoint = "projects/#{project_id}/applications/#{application_identifier}/modules/#{module_key}/advisors/insights"
|
|
76
|
+
request = Web::Request.new(
|
|
77
|
+
connection,
|
|
78
|
+
:put,
|
|
79
|
+
"#{config.target_api_url}/#{endpoint}",
|
|
80
|
+
{ params: body }
|
|
81
|
+
)
|
|
82
|
+
Web::SendRequest.new(request).perform
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|