crowdin-api 1.6.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/build-and-publish.yml +7 -6
- data/.github/workflows/dependency-analysis.yml +15 -0
- data/.github/workflows/docs.yml +9 -8
- data/.github/workflows/lint-pr-title.yml +1 -1
- data/.github/workflows/release.yml +29 -0
- data/.github/workflows/test-and-lint.yml +3 -2
- data/.gitignore +0 -1
- data/.release-it.json +36 -0
- data/CONTRIBUTING.md +2 -0
- data/Gemfile.lock +112 -0
- data/README.md +8 -4
- data/crowdin-api.gemspec +3 -2
- data/lib/crowdin-api/api_resources/applications.rb +81 -0
- data/lib/crowdin-api/api_resources/notifications.rb +53 -0
- data/lib/crowdin-api/api_resources/storages.rb +1 -1
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api/core/send_request.rb +2 -3
- data/lib/crowdin-api.rb +2 -1
- data/spec/api_resources/applications_spec.rb +47 -0
- data/spec/api_resources/notifications_spec.rb +64 -0
- data/spec/api_resources/storages_spec.rb +19 -3
- data/spec/spec_helper.rb +2 -2
- metadata +42 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e48386263c0d9c28eb7d659a8a35ee2b634991556f6d90794fe02edad4f76bb9
|
4
|
+
data.tar.gz: dcdcfd4f4a1f9d0415d7eb8ec6e0db54adbf2e77db9da9dad40b3568aee3938e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2702291c599443bbc8b8454bbe0755eaeaf08de6433fdf6f516014332fd262e6daa26f3944888ff42d4cf03647f840371f78cfbd5a7ada30264d30cfbb5ad214
|
7
|
+
data.tar.gz: 160bada2b69cc096bca583296d8ee2d5bc390a72d0d62e633bd4f4ae7bde56ef169bf324f5b19d1d3d16ee18b906231d999198abb8cce2d6b3e99f51e3a524e5
|
@@ -1,9 +1,10 @@
|
|
1
1
|
name: Build and Publish
|
2
2
|
|
3
3
|
on:
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
repository_dispatch:
|
7
|
+
types: [publish]
|
7
8
|
|
8
9
|
jobs:
|
9
10
|
build-and-publish:
|
@@ -12,12 +13,12 @@ jobs:
|
|
12
13
|
packages: write
|
13
14
|
contents: read
|
14
15
|
steps:
|
15
|
-
- uses: actions/checkout@
|
16
|
+
- uses: actions/checkout@v4
|
16
17
|
|
17
|
-
- name: Set up Ruby
|
18
|
+
- name: Set up Ruby 3.0
|
18
19
|
uses: ruby/setup-ruby@v1
|
19
20
|
with:
|
20
|
-
ruby-version:
|
21
|
+
ruby-version: 3.0
|
21
22
|
|
22
23
|
- run: bundle install
|
23
24
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
name: Dependency Analysis
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
schedule:
|
8
|
+
- cron: '0 0 * * MON'
|
9
|
+
workflow_dispatch:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
dependency-analysis:
|
13
|
+
uses: crowdin/.github/.github/workflows/dependency-analysis.yml@main
|
14
|
+
secrets:
|
15
|
+
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
|
data/.github/workflows/docs.yml
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
name: Docs
|
2
2
|
|
3
3
|
on:
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
repository_dispatch:
|
7
|
+
types: [publish]
|
7
8
|
|
8
9
|
jobs:
|
9
10
|
docs:
|
10
11
|
runs-on: ubuntu-latest
|
11
12
|
steps:
|
12
|
-
- uses: actions/checkout@
|
13
|
+
- uses: actions/checkout@v4
|
13
14
|
|
14
|
-
- name: Set up Ruby
|
15
|
+
- name: Set up Ruby 3.0
|
15
16
|
uses: ruby/setup-ruby@v1
|
16
17
|
with:
|
17
|
-
ruby-version:
|
18
|
+
ruby-version: 3.0
|
18
19
|
|
19
20
|
- run: bundle install
|
20
21
|
|
@@ -27,7 +28,7 @@ jobs:
|
|
27
28
|
run: yardoc lib/crowdin-api/api_resources/*.rb
|
28
29
|
|
29
30
|
- name: Deploy 🚀
|
30
|
-
uses: JamesIves/github-pages-deploy-action@v4
|
31
|
+
uses: JamesIves/github-pages-deploy-action@v4
|
31
32
|
with:
|
32
33
|
branch: gh-pages
|
33
|
-
folder: doc
|
34
|
+
folder: doc
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: Release
|
2
|
+
run-name: Release ${{ github.event.inputs.version }} version
|
3
|
+
|
4
|
+
on:
|
5
|
+
workflow_dispatch:
|
6
|
+
inputs:
|
7
|
+
version:
|
8
|
+
type: choice
|
9
|
+
description: Version
|
10
|
+
options:
|
11
|
+
- patch
|
12
|
+
- minor
|
13
|
+
- major
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
version:
|
17
|
+
permissions:
|
18
|
+
contents: write
|
19
|
+
uses: crowdin/.github/.github/workflows/bump-version.yml@main
|
20
|
+
|
21
|
+
publish:
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
needs: version
|
24
|
+
permissions:
|
25
|
+
contents: write
|
26
|
+
steps:
|
27
|
+
- uses: peter-evans/repository-dispatch@v2
|
28
|
+
with:
|
29
|
+
event-type: publish
|
@@ -12,10 +12,10 @@ jobs:
|
|
12
12
|
runs-on: ubuntu-latest
|
13
13
|
strategy:
|
14
14
|
matrix:
|
15
|
-
ruby-version: [ '
|
15
|
+
ruby-version: [ '3.0', '3.1', '3.2', '3.3' ]
|
16
16
|
steps:
|
17
17
|
- name: Checkout code
|
18
|
-
uses: actions/checkout@
|
18
|
+
uses: actions/checkout@v4
|
19
19
|
|
20
20
|
- name: Set up Ruby
|
21
21
|
uses: ruby/setup-ruby@v1
|
@@ -30,5 +30,6 @@ jobs:
|
|
30
30
|
|
31
31
|
- name: Publish code coverage report
|
32
32
|
uses: codecov/codecov-action@v3
|
33
|
+
if: matrix.ruby-version == '3.0'
|
33
34
|
with:
|
34
35
|
token: ${{ secrets.CODECOV_TOKEN }}
|
data/.gitignore
CHANGED
data/.release-it.json
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"git": {
|
3
|
+
"push": true,
|
4
|
+
"commit": true,
|
5
|
+
"commitMessage": "chore: version ${version} [skip ci]",
|
6
|
+
"requireBranch": "main",
|
7
|
+
"tag": true
|
8
|
+
},
|
9
|
+
"github": {
|
10
|
+
"release": true,
|
11
|
+
"autoGenerate": true,
|
12
|
+
"releaseName": "${version}"
|
13
|
+
},
|
14
|
+
"plugins": {
|
15
|
+
"@j-ulrich/release-it-regex-bumper": {
|
16
|
+
"in": "lib/crowdin-api/client/version.rb",
|
17
|
+
"out": [
|
18
|
+
{
|
19
|
+
"file": "README.md",
|
20
|
+
"search": "gem 'crowdin-api', '~> \\d+\\.\\d+\\.\\d+'",
|
21
|
+
"replace": "gem 'crowdin-api', '~> {{versionWithoutPrerelease}}'"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"file": "lib/crowdin-api/client/version.rb",
|
25
|
+
"search": "VERSION = '\\d+\\.\\d+\\.\\d+'",
|
26
|
+
"replace": "VERSION = '{{versionWithoutPrerelease}}'"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"file": "Gemfile.lock",
|
30
|
+
"search": "crowdin-api \\(\\d+\\.\\d+\\.\\d+\\)",
|
31
|
+
"replace": "crowdin-api ({{versionWithoutPrerelease}})"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
data/CONTRIBUTING.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
:tada: First off, thanks for taking the time to contribute! :tada:
|
4
4
|
|
5
|
+
The Crowdin API client provides methods that essentially call Crowdin's APIs. This makes it much easier for other developers to make calls to Crowdin's APIs, as the client abstracts a lot of the work required. In short, the API client provides a lightweight interface for making API requests to Crowdin.
|
6
|
+
|
5
7
|
The following is a set of guidelines for contributing to Crowdin Ruby Client. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
|
6
8
|
|
7
9
|
This project and everyone participating in it are governed by the [Code of Conduct](/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
crowdin-api (1.8.0)
|
5
|
+
open-uri (>= 0.1.0, < 0.2.0)
|
6
|
+
rest-client (>= 2.0.0, < 2.2.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.8.6)
|
12
|
+
public_suffix (>= 2.0.2, < 6.0)
|
13
|
+
ast (2.4.2)
|
14
|
+
coderay (1.1.3)
|
15
|
+
crack (0.4.5)
|
16
|
+
rexml
|
17
|
+
diff-lcs (1.5.0)
|
18
|
+
docile (1.4.0)
|
19
|
+
domain_name (0.5.20190701)
|
20
|
+
unf (>= 0.0.5, < 1.0.0)
|
21
|
+
hashdiff (1.1.0)
|
22
|
+
http-accept (1.7.0)
|
23
|
+
http-cookie (1.0.5)
|
24
|
+
domain_name (~> 0.5)
|
25
|
+
json (2.7.1)
|
26
|
+
method_source (1.0.0)
|
27
|
+
mime-types (3.5.2)
|
28
|
+
mime-types-data (~> 3.2015)
|
29
|
+
mime-types-data (3.2023.1205)
|
30
|
+
netrc (0.11.0)
|
31
|
+
open-uri (0.1.0)
|
32
|
+
parallel (1.24.0)
|
33
|
+
parser (3.2.2.4)
|
34
|
+
ast (~> 2.4.1)
|
35
|
+
racc
|
36
|
+
pry (0.14.2)
|
37
|
+
coderay (~> 1.1)
|
38
|
+
method_source (~> 1.0)
|
39
|
+
public_suffix (5.0.4)
|
40
|
+
racc (1.7.3)
|
41
|
+
rainbow (3.1.1)
|
42
|
+
rake (13.1.0)
|
43
|
+
regexp_parser (2.8.3)
|
44
|
+
rest-client (2.1.0)
|
45
|
+
http-accept (>= 1.7.0, < 2.0)
|
46
|
+
http-cookie (>= 1.0.2, < 2.0)
|
47
|
+
mime-types (>= 1.16, < 4.0)
|
48
|
+
netrc (~> 0.8)
|
49
|
+
rexml (3.2.6)
|
50
|
+
rspec (3.12.0)
|
51
|
+
rspec-core (~> 3.12.0)
|
52
|
+
rspec-expectations (~> 3.12.0)
|
53
|
+
rspec-mocks (~> 3.12.0)
|
54
|
+
rspec-core (3.12.2)
|
55
|
+
rspec-support (~> 3.12.0)
|
56
|
+
rspec-expectations (3.12.3)
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
+
rspec-support (~> 3.12.0)
|
59
|
+
rspec-mocks (3.12.6)
|
60
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
61
|
+
rspec-support (~> 3.12.0)
|
62
|
+
rspec-support (3.12.1)
|
63
|
+
rubocop (1.50.2)
|
64
|
+
json (~> 2.3)
|
65
|
+
parallel (~> 1.10)
|
66
|
+
parser (>= 3.2.0.0)
|
67
|
+
rainbow (>= 2.2.2, < 4.0)
|
68
|
+
regexp_parser (>= 1.8, < 3.0)
|
69
|
+
rexml (>= 3.2.5, < 4.0)
|
70
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
71
|
+
ruby-progressbar (~> 1.7)
|
72
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
73
|
+
rubocop-ast (1.30.0)
|
74
|
+
parser (>= 3.2.1.0)
|
75
|
+
ruby-progressbar (1.13.0)
|
76
|
+
simplecov (0.22.0)
|
77
|
+
docile (~> 1.1)
|
78
|
+
simplecov-html (~> 0.11)
|
79
|
+
simplecov_json_formatter (~> 0.1)
|
80
|
+
simplecov-cobertura (2.1.0)
|
81
|
+
rexml
|
82
|
+
simplecov (~> 0.19)
|
83
|
+
simplecov-html (0.12.3)
|
84
|
+
simplecov_json_formatter (0.1.4)
|
85
|
+
unf (0.1.4)
|
86
|
+
unf_ext
|
87
|
+
unf_ext (0.0.9.1)
|
88
|
+
unicode-display_width (2.5.0)
|
89
|
+
webmock (3.19.1)
|
90
|
+
addressable (>= 2.8.0)
|
91
|
+
crack (>= 0.3.2)
|
92
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
93
|
+
yard (0.9.34)
|
94
|
+
|
95
|
+
PLATFORMS
|
96
|
+
arm64-darwin-23
|
97
|
+
x86_64-linux
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
bundler (~> 2.2, >= 2.2.32)
|
101
|
+
crowdin-api!
|
102
|
+
pry (~> 0.14.1)
|
103
|
+
rake (~> 13.0, >= 13.0.6)
|
104
|
+
rspec (~> 3.10)
|
105
|
+
rubocop (~> 1.23)
|
106
|
+
simplecov (~> 0.22)
|
107
|
+
simplecov-cobertura (~> 2.1)
|
108
|
+
webmock (~> 3.14)
|
109
|
+
yard (~> 0.9.28)
|
110
|
+
|
111
|
+
BUNDLED WITH
|
112
|
+
2.4.22
|
data/README.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
1
|
+
<p align="center">
|
2
|
+
<picture>
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://support.crowdin.com/assets/logos/symbol/png/crowdin-symbol-cWhite.png">
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://support.crowdin.com/assets/logos/symbol/png/crowdin-symbol-cDark.png">
|
5
|
+
<img width="150" height="150" src="https://support.crowdin.com/assets/logos/symbol/png/crowdin-symbol-cDark.png">
|
6
|
+
</picture>
|
7
|
+
</p>
|
2
8
|
|
3
9
|
# Crowdin Ruby client
|
4
10
|
|
@@ -15,10 +21,8 @@ Crowdin API is a full-featured RESTful API that helps you to integrate localizat
|
|
15
21
|
[![Gem](https://img.shields.io/gem/v/crowdin-api?logo=ruby&cacheSeconds=1800)](https://rubygems.org/gems/crowdin-api)
|
16
22
|
[![Gem](https://img.shields.io/gem/dt/crowdin-api?cacheSeconds=1800)](https://rubygems.org/gems/crowdin-api)
|
17
23
|
[![Gem](https://img.shields.io/gem/dtv/crowdin-api?cacheSeconds=1800)](https://rubygems.org/gems/crowdin-api)
|
18
|
-
|
19
24
|
[![Test and Lint](https://github.com/crowdin/crowdin-api-client-ruby/actions/workflows/test-and-lint.yml/badge.svg)](https://github.com/crowdin/crowdin-api-client-ruby/actions/workflows/test-and-lint.yml)
|
20
25
|
[![codecov](https://codecov.io/gh/crowdin/crowdin-api-client-ruby/branch/main/graph/badge.svg?token=OJsyJwQbFM)](https://codecov.io/gh/crowdin/crowdin-api-client-ruby)
|
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
26
|
[![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
27
|
|
24
28
|
</div>
|
@@ -31,7 +35,7 @@ Crowdin API is a full-featured RESTful API that helps you to integrate localizat
|
|
31
35
|
Add this line to your application's Gemfile:
|
32
36
|
|
33
37
|
```gemfile
|
34
|
-
gem 'crowdin-api', '~> 1.
|
38
|
+
gem 'crowdin-api', '~> 1.8.0'
|
35
39
|
```
|
36
40
|
|
37
41
|
And then execute:
|
data/crowdin-api.gemspec
CHANGED
@@ -20,13 +20,14 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.required_ruby_version = '>= 2.4'
|
21
21
|
|
22
22
|
gem.add_runtime_dependency 'open-uri', '>= 0.1.0', '< 0.2.0'
|
23
|
-
gem.add_runtime_dependency 'rest-client', '>= 2.0.0', '< 2.
|
23
|
+
gem.add_runtime_dependency 'rest-client', '>= 2.0.0', '< 2.2.0'
|
24
24
|
|
25
25
|
gem.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.32'
|
26
|
-
gem.add_development_dependency 'codecov', '~> 0.6.0'
|
27
26
|
gem.add_development_dependency 'pry', '~> 0.14.1'
|
28
27
|
gem.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
29
28
|
gem.add_development_dependency 'rspec', '~> 3.10'
|
30
29
|
gem.add_development_dependency 'rubocop', '~> 1.23'
|
30
|
+
gem.add_development_dependency 'simplecov', '~> 0.22'
|
31
|
+
gem.add_development_dependency 'simplecov-cobertura', '~> 2.1'
|
31
32
|
gem.add_development_dependency 'webmock', '~> 3.14'
|
32
33
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Applications
|
6
|
+
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.applications.api.get API Documentation}
|
7
|
+
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.get API Documentation}
|
8
|
+
def get_application_data(application_identifier = nil, path = nil)
|
9
|
+
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
10
|
+
application_identifier || raise_parameter_is_required_error(:path)
|
11
|
+
|
12
|
+
request = Web::Request.new(
|
13
|
+
connection,
|
14
|
+
:get,
|
15
|
+
"#{config.target_api_url}/applications/#{application_identifier}/api/#{path}"
|
16
|
+
)
|
17
|
+
Web::SendRequest.new(request).perform
|
18
|
+
end
|
19
|
+
|
20
|
+
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.applications.api.put API Documentation}
|
21
|
+
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.put API Documentation}
|
22
|
+
def update_or_restore_application_data(query = {}, application_identifier = nil, path = nil)
|
23
|
+
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
24
|
+
application_identifier || raise_parameter_is_required_error(:path)
|
25
|
+
|
26
|
+
request = Web::Request.new(
|
27
|
+
connection,
|
28
|
+
:put,
|
29
|
+
"#{config.target_api_url}/applications/#{application_identifier}/api/#{path}",
|
30
|
+
{ params: query }
|
31
|
+
)
|
32
|
+
Web::SendRequest.new(request).perform
|
33
|
+
end
|
34
|
+
|
35
|
+
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.applications.api.put API Documentation}
|
36
|
+
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.put API Documentation}
|
37
|
+
def add_application_data(query = {}, application_identifier = nil, path = nil)
|
38
|
+
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
39
|
+
application_identifier || raise_parameter_is_required_error(:path)
|
40
|
+
|
41
|
+
request = Web::Request.new(
|
42
|
+
connection,
|
43
|
+
:post,
|
44
|
+
"#{config.target_api_url}/applications/#{application_identifier}/api/#{path}",
|
45
|
+
{ params: query }
|
46
|
+
)
|
47
|
+
Web::SendRequest.new(request).perform
|
48
|
+
end
|
49
|
+
|
50
|
+
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.applications.api.delete API Documentation}
|
51
|
+
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.delete API Documentation}
|
52
|
+
def delete_application_data(query = {}, application_identifier = nil, path = nil)
|
53
|
+
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
54
|
+
application_identifier || raise_parameter_is_required_error(:path)
|
55
|
+
|
56
|
+
request = Web::Request.new(
|
57
|
+
connection,
|
58
|
+
:delete,
|
59
|
+
"#{config.target_api_url}/applications/#{application_identifier}/api/#{path}",
|
60
|
+
{ params: query }
|
61
|
+
)
|
62
|
+
Web::SendRequest.new(request).perform
|
63
|
+
end
|
64
|
+
|
65
|
+
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.applications.api.patch API Documentation}
|
66
|
+
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.applications.api.patch API Documentation}
|
67
|
+
def edit_application_data(query = {}, application_identifier = nil, path = nil)
|
68
|
+
application_identifier || raise_parameter_is_required_error(:application_identifier)
|
69
|
+
application_identifier || raise_parameter_is_required_error(:path)
|
70
|
+
|
71
|
+
request = Web::Request.new(
|
72
|
+
connection,
|
73
|
+
:patch,
|
74
|
+
"#{config.target_api_url}/applications/#{application_identifier}/api/#{path}",
|
75
|
+
{ params: query }
|
76
|
+
)
|
77
|
+
Web::SendRequest.new(request).perform
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Notifications
|
6
|
+
def send_notification_to_authenticated_user(query = {})
|
7
|
+
%i[message].each do |param|
|
8
|
+
query[param] || raise_parameter_is_required_error(param)
|
9
|
+
end
|
10
|
+
|
11
|
+
request = Web::Request.new(
|
12
|
+
connection,
|
13
|
+
:post,
|
14
|
+
"#{config.target_api_url}/notify",
|
15
|
+
{ params: query }
|
16
|
+
)
|
17
|
+
Web::SendRequest.new(request).perform
|
18
|
+
end
|
19
|
+
|
20
|
+
def send_notification_to_organization_members(query = {})
|
21
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
22
|
+
|
23
|
+
%i[message].each do |param|
|
24
|
+
query[param] || raise_parameter_is_required_error(param)
|
25
|
+
end
|
26
|
+
|
27
|
+
request = Web::Request.new(
|
28
|
+
connection,
|
29
|
+
:post,
|
30
|
+
"#{config.target_api_url}/notify",
|
31
|
+
{ params: query }
|
32
|
+
)
|
33
|
+
Web::SendRequest.new(request).perform
|
34
|
+
end
|
35
|
+
|
36
|
+
def send_notifications_to_project_members(query = {}, project_id = config.project_id)
|
37
|
+
project_id || raise_project_id_is_required_error
|
38
|
+
|
39
|
+
%i[message].each do |param|
|
40
|
+
query[param] || raise_parameter_is_required_error(param)
|
41
|
+
end
|
42
|
+
|
43
|
+
request = Web::Request.new(
|
44
|
+
connection,
|
45
|
+
:post,
|
46
|
+
"#{config.target_api_url}/projects/#{project_id}/notify",
|
47
|
+
{ params: query }
|
48
|
+
)
|
49
|
+
Web::SendRequest.new(request).perform
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -22,7 +22,7 @@ module Crowdin
|
|
22
22
|
def add_storage(file = nil)
|
23
23
|
file || raise_parameter_is_required_error(:file)
|
24
24
|
|
25
|
-
file
|
25
|
+
file = File.open(file, 'r')
|
26
26
|
headers = { 'Content-Type' => 'application/octet-stream', 'Crowdin-API-FileName' => File.basename(file) }
|
27
27
|
|
28
28
|
request = Web::Request.new(
|
@@ -44,7 +44,7 @@ module Crowdin
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def fetch_response_data(doc)
|
47
|
-
if doc['data'].is_a?(Hash) && doc['data']['url']
|
47
|
+
if @file_destination && doc['data'].is_a?(Hash) && doc['data']['url']
|
48
48
|
download_file(doc['data']['url'])
|
49
49
|
else
|
50
50
|
doc
|
@@ -53,8 +53,7 @@ module Crowdin
|
|
53
53
|
|
54
54
|
def download_file(url)
|
55
55
|
download = URI.parse(url).open
|
56
|
-
destination = @file_destination
|
57
|
-
.match(/filename=("?)(.+)\1/)[2]
|
56
|
+
destination = @file_destination
|
58
57
|
|
59
58
|
IO.copy_stream(download, destination)
|
60
59
|
|
data/lib/crowdin-api.rb
CHANGED
@@ -5,7 +5,8 @@ module Crowdin
|
|
5
5
|
API_RESOURCES_MODULES = %i[Storages Languages Projects Workflows SourceFiles Translations SourceStrings
|
6
6
|
StringTranslations StringComments Screenshots Glossaries TranslationMemory
|
7
7
|
MachineTranslationEngines Reports Tasks Users Teams Vendors Webhooks
|
8
|
-
Dictionaries Distributions Labels TranslationStatus Bundles
|
8
|
+
Dictionaries Distributions Labels TranslationStatus Bundles Notifications
|
9
|
+
Applications].freeze
|
9
10
|
|
10
11
|
# Error Raisers modules
|
11
12
|
ERROR_RAISERS_MODULES = %i[ApiErrorsRaiser ClientErrorsRaiser].freeze
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Applications do
|
4
|
+
let(:application_identifier) { 'identifier' }
|
5
|
+
let(:path) { 'application_path' }
|
6
|
+
describe 'Default endpoints' do
|
7
|
+
describe '#get_application_data' do
|
8
|
+
it 'when request are valid', :default do
|
9
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
10
|
+
get_application_data = @crowdin.get_application_data(application_identifier, path)
|
11
|
+
expect(get_application_data).to eq(200)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#update_or_restore_application_data' do
|
16
|
+
it 'when request are valid', :default do
|
17
|
+
stub_request(:put, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
18
|
+
get_application_data = @crowdin.update_or_restore_application_data({}, application_identifier, path)
|
19
|
+
expect(get_application_data).to eq(200)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#add_application_data' do
|
24
|
+
it 'when request are valid', :default do
|
25
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
26
|
+
get_application_data = @crowdin.add_application_data({}, application_identifier, path)
|
27
|
+
expect(get_application_data).to eq(200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_application_data' do
|
32
|
+
it 'when request are valid', :default do
|
33
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
34
|
+
get_application_data = @crowdin.delete_application_data({}, application_identifier, path)
|
35
|
+
expect(get_application_data).to eq(200)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#edit_application_data' do
|
40
|
+
it 'when request are valid', :default do
|
41
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
42
|
+
get_application_data = @crowdin.edit_application_data({}, application_identifier, path)
|
43
|
+
expect(get_application_data).to eq(200)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Notifications do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#send_notification_to_authenticated_user' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/notify")
|
8
|
+
.with(body: { 'message' => 'New notification message' })
|
9
|
+
query = { message: 'New notification message' }
|
10
|
+
response = @crowdin.send_notification_to_authenticated_user(query)
|
11
|
+
expect(response).to eq(200)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'raises ArgumentError when request is missing required query parameter', :default do
|
15
|
+
expect do
|
16
|
+
@crowdin.send_notification_to_authenticated_user({})
|
17
|
+
end.to raise_error(ArgumentError, ':message is required')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#send_notifications_to_project_members' do
|
22
|
+
let(:project_id) { 1 }
|
23
|
+
|
24
|
+
it 'when request are valid', :default do
|
25
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/notify")
|
26
|
+
.with(body: { 'message' => 'New notification message' })
|
27
|
+
query = { message: 'New notification message' }
|
28
|
+
response = @crowdin.send_notifications_to_project_members(query, project_id)
|
29
|
+
expect(response).to eq(200)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'raises ArgumentError when request is missing required query parameter', :default do
|
33
|
+
expect do
|
34
|
+
@crowdin.send_notifications_to_project_members({}, project_id)
|
35
|
+
end.to raise_error(ArgumentError, ':message is required')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'raises ArgumentError when request is missing project_id parameter', :default do
|
39
|
+
query = { message: 'New notification message' }
|
40
|
+
expect do
|
41
|
+
@crowdin.send_notifications_to_project_members(query, nil)
|
42
|
+
end.to raise_error(ArgumentError, ':project_id is required in parameters or while Client initialization')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'Enterprise endpoints' do
|
48
|
+
describe '#send_notification_to_organization_members' do
|
49
|
+
it 'when request are valid', :enterprise do
|
50
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/notify")
|
51
|
+
.with(body: { 'message' => 'New notification message' })
|
52
|
+
query = { message: 'New notification message' }
|
53
|
+
response = @crowdin.send_notification_to_organization_members(query)
|
54
|
+
expect(response).to eq(200)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'raises ArgumentError when request is missing required query parameter', :enterprise do
|
58
|
+
expect do
|
59
|
+
@crowdin.send_notification_to_organization_members({})
|
60
|
+
end.to raise_error(ArgumentError, ':message is required')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -11,10 +11,26 @@ describe Crowdin::ApiResources::Storages do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '#add_storage' do
|
14
|
-
|
14
|
+
subject(:add_storage) { @crowdin.add_storage(file) }
|
15
|
+
|
16
|
+
let(:file) { 'README.md' }
|
17
|
+
|
18
|
+
it 'uploads the file to the storage', :default do
|
19
|
+
expected_response = 'expected_response'
|
20
|
+
|
15
21
|
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/storages")
|
16
|
-
|
17
|
-
|
22
|
+
.with(
|
23
|
+
body: File.read(file),
|
24
|
+
headers: {
|
25
|
+
'Content-Type' => 'application/octet-stream',
|
26
|
+
'Crowdin-API-FileName' => File.basename(file)
|
27
|
+
}
|
28
|
+
)
|
29
|
+
.to_return(
|
30
|
+
body: JSON.dump(expected_response)
|
31
|
+
)
|
32
|
+
|
33
|
+
is_expected.to eq(expected_response)
|
18
34
|
end
|
19
35
|
end
|
20
36
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'simplecov'
|
4
|
-
require '
|
4
|
+
require 'simplecov-cobertura'
|
5
5
|
|
6
6
|
SimpleCov.start
|
7
|
-
SimpleCov.formatter = SimpleCov::Formatter::
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
8
8
|
|
9
9
|
require 'webmock/rspec'
|
10
10
|
require 'crowdin-api'
|
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
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open-uri
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 2.0.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 2.
|
42
|
+
version: 2.2.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 2.0.0
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 2.
|
52
|
+
version: 2.2.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,20 +70,6 @@ dependencies:
|
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 2.2.32
|
73
|
-
- !ruby/object:Gem::Dependency
|
74
|
-
name: codecov
|
75
|
-
requirement: !ruby/object:Gem::Requirement
|
76
|
-
requirements:
|
77
|
-
- - "~>"
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: 0.6.0
|
80
|
-
type: :development
|
81
|
-
prerelease: false
|
82
|
-
version_requirements: !ruby/object:Gem::Requirement
|
83
|
-
requirements:
|
84
|
-
- - "~>"
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: 0.6.0
|
87
73
|
- !ruby/object:Gem::Dependency
|
88
74
|
name: pry
|
89
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,6 +132,34 @@ dependencies:
|
|
146
132
|
- - "~>"
|
147
133
|
- !ruby/object:Gem::Version
|
148
134
|
version: '1.23'
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: simplecov
|
137
|
+
requirement: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0.22'
|
142
|
+
type: :development
|
143
|
+
prerelease: false
|
144
|
+
version_requirements: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - "~>"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0.22'
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: simplecov-cobertura
|
151
|
+
requirement: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - "~>"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '2.1'
|
156
|
+
type: :development
|
157
|
+
prerelease: false
|
158
|
+
version_requirements: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - "~>"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '2.1'
|
149
163
|
- !ruby/object:Gem::Dependency
|
150
164
|
name: webmock
|
151
165
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,23 +183,29 @@ executables:
|
|
169
183
|
extensions: []
|
170
184
|
extra_rdoc_files: []
|
171
185
|
files:
|
186
|
+
- ".github/dependabot.yml"
|
172
187
|
- ".github/workflows/build-and-publish.yml"
|
188
|
+
- ".github/workflows/dependency-analysis.yml"
|
173
189
|
- ".github/workflows/docs.yml"
|
174
190
|
- ".github/workflows/lint-pr-title.yml"
|
191
|
+
- ".github/workflows/release.yml"
|
175
192
|
- ".github/workflows/test-and-lint.yml"
|
176
193
|
- ".gitignore"
|
194
|
+
- ".release-it.json"
|
177
195
|
- ".rspec"
|
178
196
|
- ".rubocop.yml"
|
179
197
|
- ".rubocop_todo.yml"
|
180
198
|
- CODE_OF_CONDUCT.md
|
181
199
|
- CONTRIBUTING.md
|
182
200
|
- Gemfile
|
201
|
+
- Gemfile.lock
|
183
202
|
- LICENSE
|
184
203
|
- README.md
|
185
204
|
- Rakefile
|
186
205
|
- bin/crowdin-console
|
187
206
|
- crowdin-api.gemspec
|
188
207
|
- lib/crowdin-api.rb
|
208
|
+
- lib/crowdin-api/api_resources/applications.rb
|
189
209
|
- lib/crowdin-api/api_resources/bundles.rb
|
190
210
|
- lib/crowdin-api/api_resources/dictionaries.rb
|
191
211
|
- lib/crowdin-api/api_resources/distributions.rb
|
@@ -193,6 +213,7 @@ files:
|
|
193
213
|
- lib/crowdin-api/api_resources/labels.rb
|
194
214
|
- lib/crowdin-api/api_resources/languages.rb
|
195
215
|
- lib/crowdin-api/api_resources/machine_translation_engines.rb
|
216
|
+
- lib/crowdin-api/api_resources/notifications.rb
|
196
217
|
- lib/crowdin-api/api_resources/projects.rb
|
197
218
|
- lib/crowdin-api/api_resources/reports.rb
|
198
219
|
- lib/crowdin-api/api_resources/screenshots.rb
|
@@ -218,6 +239,7 @@ files:
|
|
218
239
|
- lib/crowdin-api/core/fetch_all_extensions.rb
|
219
240
|
- lib/crowdin-api/core/request.rb
|
220
241
|
- lib/crowdin-api/core/send_request.rb
|
242
|
+
- spec/api_resources/applications_spec.rb
|
221
243
|
- spec/api_resources/bundles_spec.rb
|
222
244
|
- spec/api_resources/dictionaries_spec.rb
|
223
245
|
- spec/api_resources/distributions_spec.rb
|
@@ -225,6 +247,7 @@ files:
|
|
225
247
|
- spec/api_resources/labels_spec.rb
|
226
248
|
- spec/api_resources/languages_spec.rb
|
227
249
|
- spec/api_resources/machine_translation_engines_spec.rb
|
250
|
+
- spec/api_resources/notifications_spec.rb
|
228
251
|
- spec/api_resources/projects_spec.rb
|
229
252
|
- spec/api_resources/reports_spec.rb
|
230
253
|
- spec/api_resources/screenshots_spec.rb
|
@@ -263,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
263
286
|
- !ruby/object:Gem::Version
|
264
287
|
version: '0'
|
265
288
|
requirements: []
|
266
|
-
rubygems_version: 3.
|
289
|
+
rubygems_version: 3.5.3
|
267
290
|
signing_key:
|
268
291
|
specification_version: 4
|
269
292
|
summary: Ruby Client for the Crowdin API
|