crowdin-api 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c30c686d6eb10b527235cfbb182aad55d47ad1a8a546b96a4215a60b1b2e29fd
4
- data.tar.gz: cec244035e78c4abef7de5e44d845f4ccc306fd12a6b60e33762f26d88dca5f1
3
+ metadata.gz: 48893708d5c6c19787dec33d3e7f19c87809e6ab33e17d6b54821483cae925d0
4
+ data.tar.gz: 4b43a6b919c72b31da170f6d30e771faa07e85e7ebc7845d732a528262e8271d
5
5
  SHA512:
6
- metadata.gz: 73df7b0e5b4a5281d9894f45ca81bf77e4afa2404ea84c6b50c5a6a97d146b629d610d9131cb0962e4f4dfeccfaafd290e2b225271e40691d18c602d53872201
7
- data.tar.gz: 388067874b3264c10e38eef41270416637b93a1b4affad5427e05f4fe246fc3f39377e5b25fb1e1f21d641dea6a3ba6165e75f9aeca0fd621028a0db09d07177
6
+ metadata.gz: b99fa959c8338fb9c5557eab55e1dd76964d139eb5e4e411fee8d7cb2b352b559beec71974202c76b0e84995042152fbfe244ef1c56a4618081faa4e03c20c4f
7
+ data.tar.gz: 90f971f1453892aa47fb7a1ac25bcd8a91a92273b32022b41b647a54a762f180f68d45562f8d009a8a6cd512f217cb25ebedd98927c9f714501c8a229ff1c870
@@ -0,0 +1,9 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: '/'
5
+ schedule:
6
+ interval: monthly
7
+ ignore:
8
+ - dependency-name: "*"
9
+ update-types: [ "version-update:semver-major" ]
@@ -1,9 +1,10 @@
1
1
  name: Build and Publish
2
2
 
3
3
  on:
4
- push:
5
- tags:
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@v3
16
+ - uses: actions/checkout@v4
16
17
 
17
- - name: Set up Ruby 2.6
18
+ - name: Set up Ruby 3.0
18
19
  uses: ruby/setup-ruby@v1
19
20
  with:
20
- ruby-version: 2.6
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 }}
@@ -1,20 +1,21 @@
1
1
  name: Docs
2
2
 
3
3
  on:
4
- push:
5
- tags:
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@v3
13
+ - uses: actions/checkout@v4
13
14
 
14
- - name: Set up Ruby 2.6
15
+ - name: Set up Ruby 3.0
15
16
  uses: ruby/setup-ruby@v1
16
17
  with:
17
- ruby-version: 2.6
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.4.1
31
+ uses: JamesIves/github-pages-deploy-action@v4
31
32
  with:
32
33
  branch: gh-pages
33
- folder: doc
34
+ folder: doc
@@ -1,4 +1,4 @@
1
- name: lint-pr-title
1
+ name: Lint PR Title
2
2
 
3
3
  on:
4
4
  pull_request_target:
@@ -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: [ '2.6', '2.7', '3.0' ]
15
+ ruby-version: [ '3.0', '3.1', '3.2', '3.3' ]
16
16
  steps:
17
17
  - name: Checkout code
18
- uses: actions/checkout@v3
18
+ uses: actions/checkout@v4
19
19
 
20
20
  - name: Set up Ruby
21
21
  uses: ruby/setup-ruby@v1
data/.gitignore CHANGED
@@ -5,7 +5,6 @@
5
5
  .DS_Store
6
6
 
7
7
  # Ignore versioning files
8
- Gemfile.lock
9
8
  .ruby-version
10
9
 
11
10
  # Ignore tests coverage folder
data/.release-it.json ADDED
@@ -0,0 +1,31 @@
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
+ }
30
+ }
31
+ }
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,109 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ crowdin-api (1.7.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
+ codecov (0.6.0)
15
+ simplecov (>= 0.15, < 0.22)
16
+ coderay (1.1.3)
17
+ crack (0.4.5)
18
+ rexml
19
+ diff-lcs (1.5.0)
20
+ docile (1.4.0)
21
+ domain_name (0.5.20190701)
22
+ unf (>= 0.0.5, < 1.0.0)
23
+ hashdiff (1.1.0)
24
+ http-accept (1.7.0)
25
+ http-cookie (1.0.5)
26
+ domain_name (~> 0.5)
27
+ json (2.7.1)
28
+ method_source (1.0.0)
29
+ mime-types (3.5.2)
30
+ mime-types-data (~> 3.2015)
31
+ mime-types-data (3.2023.1205)
32
+ netrc (0.11.0)
33
+ open-uri (0.1.0)
34
+ parallel (1.24.0)
35
+ parser (3.2.2.4)
36
+ ast (~> 2.4.1)
37
+ racc
38
+ pry (0.14.2)
39
+ coderay (~> 1.1)
40
+ method_source (~> 1.0)
41
+ public_suffix (5.0.4)
42
+ racc (1.7.3)
43
+ rainbow (3.1.1)
44
+ rake (13.1.0)
45
+ regexp_parser (2.8.3)
46
+ rest-client (2.1.0)
47
+ http-accept (>= 1.7.0, < 2.0)
48
+ http-cookie (>= 1.0.2, < 2.0)
49
+ mime-types (>= 1.16, < 4.0)
50
+ netrc (~> 0.8)
51
+ rexml (3.2.6)
52
+ rspec (3.12.0)
53
+ rspec-core (~> 3.12.0)
54
+ rspec-expectations (~> 3.12.0)
55
+ rspec-mocks (~> 3.12.0)
56
+ rspec-core (3.12.2)
57
+ rspec-support (~> 3.12.0)
58
+ rspec-expectations (3.12.3)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.12.0)
61
+ rspec-mocks (3.12.6)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.12.0)
64
+ rspec-support (3.12.1)
65
+ rubocop (1.50.2)
66
+ json (~> 2.3)
67
+ parallel (~> 1.10)
68
+ parser (>= 3.2.0.0)
69
+ rainbow (>= 2.2.2, < 4.0)
70
+ regexp_parser (>= 1.8, < 3.0)
71
+ rexml (>= 3.2.5, < 4.0)
72
+ rubocop-ast (>= 1.28.0, < 2.0)
73
+ ruby-progressbar (~> 1.7)
74
+ unicode-display_width (>= 2.4.0, < 3.0)
75
+ rubocop-ast (1.30.0)
76
+ parser (>= 3.2.1.0)
77
+ ruby-progressbar (1.13.0)
78
+ simplecov (0.21.2)
79
+ docile (~> 1.1)
80
+ simplecov-html (~> 0.11)
81
+ simplecov_json_formatter (~> 0.1)
82
+ simplecov-html (0.12.3)
83
+ simplecov_json_formatter (0.1.4)
84
+ unf (0.1.4)
85
+ unf_ext
86
+ unf_ext (0.0.9.1)
87
+ unicode-display_width (2.5.0)
88
+ webmock (3.19.1)
89
+ addressable (>= 2.8.0)
90
+ crack (>= 0.3.2)
91
+ hashdiff (>= 0.4.0, < 2.0.0)
92
+ yard (0.9.34)
93
+
94
+ PLATFORMS
95
+ x86_64-linux
96
+
97
+ DEPENDENCIES
98
+ bundler (~> 2.2, >= 2.2.32)
99
+ codecov (~> 0.6.0)
100
+ crowdin-api!
101
+ pry (~> 0.14.1)
102
+ rake (~> 13.0, >= 13.0.6)
103
+ rspec (~> 3.10)
104
+ rubocop (~> 1.23)
105
+ webmock (~> 3.14)
106
+ yard (~> 0.9.28)
107
+
108
+ BUNDLED WITH
109
+ 2.4.22
data/README.md CHANGED
@@ -1,4 +1,10 @@
1
- [<p align='center'><img src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' data-canonical-src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' width='150' height='150' align='center'/></p>](https://crowdin.com)
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.6.0'
38
+ gem 'crowdin-api', '~> 1.7.0'
35
39
  ```
36
40
 
37
41
  And then execute:
data/crowdin-api.gemspec CHANGED
@@ -20,7 +20,7 @@ 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.1.0'
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
26
  gem.add_development_dependency 'codecov', '~> 0.6.0'
@@ -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 = file.is_a?(File) ? file : File.open(file, 'r')
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(
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Crowdin
4
4
  class Client
5
- VERSION = '1.6.0'
5
+ VERSION = '1.7.0'
6
6
  end
7
7
  end
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].freeze
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
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.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crowdin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-15 00:00:00.000000000 Z
11
+ date: 2024-01-16 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.1.0
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.1.0
52
+ version: 2.2.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: bundler
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -169,23 +169,29 @@ executables:
169
169
  extensions: []
170
170
  extra_rdoc_files: []
171
171
  files:
172
+ - ".github/dependabot.yml"
172
173
  - ".github/workflows/build-and-publish.yml"
174
+ - ".github/workflows/dependency-analysis.yml"
173
175
  - ".github/workflows/docs.yml"
174
176
  - ".github/workflows/lint-pr-title.yml"
177
+ - ".github/workflows/release.yml"
175
178
  - ".github/workflows/test-and-lint.yml"
176
179
  - ".gitignore"
180
+ - ".release-it.json"
177
181
  - ".rspec"
178
182
  - ".rubocop.yml"
179
183
  - ".rubocop_todo.yml"
180
184
  - CODE_OF_CONDUCT.md
181
185
  - CONTRIBUTING.md
182
186
  - Gemfile
187
+ - Gemfile.lock
183
188
  - LICENSE
184
189
  - README.md
185
190
  - Rakefile
186
191
  - bin/crowdin-console
187
192
  - crowdin-api.gemspec
188
193
  - lib/crowdin-api.rb
194
+ - lib/crowdin-api/api_resources/applications.rb
189
195
  - lib/crowdin-api/api_resources/bundles.rb
190
196
  - lib/crowdin-api/api_resources/dictionaries.rb
191
197
  - lib/crowdin-api/api_resources/distributions.rb
@@ -193,6 +199,7 @@ files:
193
199
  - lib/crowdin-api/api_resources/labels.rb
194
200
  - lib/crowdin-api/api_resources/languages.rb
195
201
  - lib/crowdin-api/api_resources/machine_translation_engines.rb
202
+ - lib/crowdin-api/api_resources/notifications.rb
196
203
  - lib/crowdin-api/api_resources/projects.rb
197
204
  - lib/crowdin-api/api_resources/reports.rb
198
205
  - lib/crowdin-api/api_resources/screenshots.rb
@@ -218,6 +225,7 @@ files:
218
225
  - lib/crowdin-api/core/fetch_all_extensions.rb
219
226
  - lib/crowdin-api/core/request.rb
220
227
  - lib/crowdin-api/core/send_request.rb
228
+ - spec/api_resources/applications_spec.rb
221
229
  - spec/api_resources/bundles_spec.rb
222
230
  - spec/api_resources/dictionaries_spec.rb
223
231
  - spec/api_resources/distributions_spec.rb
@@ -225,6 +233,7 @@ files:
225
233
  - spec/api_resources/labels_spec.rb
226
234
  - spec/api_resources/languages_spec.rb
227
235
  - spec/api_resources/machine_translation_engines_spec.rb
236
+ - spec/api_resources/notifications_spec.rb
228
237
  - spec/api_resources/projects_spec.rb
229
238
  - spec/api_resources/reports_spec.rb
230
239
  - spec/api_resources/screenshots_spec.rb
@@ -263,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
272
  - !ruby/object:Gem::Version
264
273
  version: '0'
265
274
  requirements: []
266
- rubygems_version: 3.0.3.1
275
+ rubygems_version: 3.5.3
267
276
  signing_key:
268
277
  specification_version: 4
269
278
  summary: Ruby Client for the Crowdin API