crowdin-api 1.8.0 → 1.9.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: e48386263c0d9c28eb7d659a8a35ee2b634991556f6d90794fe02edad4f76bb9
4
- data.tar.gz: dcdcfd4f4a1f9d0415d7eb8ec6e0db54adbf2e77db9da9dad40b3568aee3938e
3
+ metadata.gz: eb6299e8ac24c4e3bf9e7bbcf3d9741ded36842d56a7e294f9f534f4c05535a5
4
+ data.tar.gz: 04a58a1803638e00dd1c8b6a833fed4b8e01f56d19201a272ecbdeca4e0fd515
5
5
  SHA512:
6
- metadata.gz: 2702291c599443bbc8b8454bbe0755eaeaf08de6433fdf6f516014332fd262e6daa26f3944888ff42d4cf03647f840371f78cfbd5a7ada30264d30cfbb5ad214
7
- data.tar.gz: 160bada2b69cc096bca583296d8ee2d5bc390a72d0d62e633bd4f4ae7bde56ef169bf324f5b19d1d3d16ee18b906231d999198abb8cce2d6b3e99f51e3a524e5
6
+ metadata.gz: bb87a4d984c5f9955ac03908ba2d57eaa4ad5a06723de4683f513e3cf696a6b1013bcc1d2473a2aa231eea207afb8688a0baff61d9acc67fa53351a5284eaddd
7
+ data.tar.gz: d11b9902322de9ff89c6575e0b7915968d5627d887c144bcbe196021056399d80ded2f0ccae66e4a1b88eb8124b080f28cc30b552ca4df25d64b829bc4071ec6
@@ -29,7 +29,7 @@ jobs:
29
29
  bundle exec rake
30
30
 
31
31
  - name: Publish code coverage report
32
- uses: codecov/codecov-action@v3
32
+ uses: codecov/codecov-action@v4
33
33
  if: matrix.ruby-version == '3.0'
34
34
  with:
35
35
  token: ${{ secrets.CODECOV_TOKEN }}
data/Gemfile CHANGED
@@ -3,6 +3,6 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  # For Documentation
6
- gem 'yard', '~> 0.9.28'
6
+ gem 'yard', '~> 0.9.36'
7
7
 
8
8
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crowdin-api (1.8.0)
4
+ crowdin-api (1.9.0)
5
5
  open-uri (>= 0.1.0, < 0.2.0)
6
6
  rest-client (>= 2.0.0, < 2.2.0)
7
7
 
@@ -14,7 +14,7 @@ GEM
14
14
  coderay (1.1.3)
15
15
  crack (0.4.5)
16
16
  rexml
17
- diff-lcs (1.5.0)
17
+ diff-lcs (1.5.1)
18
18
  docile (1.4.0)
19
19
  domain_name (0.5.20190701)
20
20
  unf (>= 0.0.5, < 1.0.0)
@@ -47,19 +47,19 @@ GEM
47
47
  mime-types (>= 1.16, < 4.0)
48
48
  netrc (~> 0.8)
49
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)
50
+ rspec (3.13.0)
51
+ rspec-core (~> 3.13.0)
52
+ rspec-expectations (~> 3.13.0)
53
+ rspec-mocks (~> 3.13.0)
54
+ rspec-core (3.13.0)
55
+ rspec-support (~> 3.13.0)
56
+ rspec-expectations (3.13.0)
57
57
  diff-lcs (>= 1.2.0, < 2.0)
58
- rspec-support (~> 3.12.0)
59
- rspec-mocks (3.12.6)
58
+ rspec-support (~> 3.13.0)
59
+ rspec-mocks (3.13.0)
60
60
  diff-lcs (>= 1.2.0, < 2.0)
61
- rspec-support (~> 3.12.0)
62
- rspec-support (3.12.1)
61
+ rspec-support (~> 3.13.0)
62
+ rspec-support (3.13.1)
63
63
  rubocop (1.50.2)
64
64
  json (~> 2.3)
65
65
  parallel (~> 1.10)
@@ -90,7 +90,7 @@ GEM
90
90
  addressable (>= 2.8.0)
91
91
  crack (>= 0.3.2)
92
92
  hashdiff (>= 0.4.0, < 2.0.0)
93
- yard (0.9.34)
93
+ yard (0.9.36)
94
94
 
95
95
  PLATFORMS
96
96
  arm64-darwin-23
@@ -106,7 +106,7 @@ DEPENDENCIES
106
106
  simplecov (~> 0.22)
107
107
  simplecov-cobertura (~> 2.1)
108
108
  webmock (~> 3.14)
109
- yard (~> 0.9.28)
109
+ yard (~> 0.9.36)
110
110
 
111
111
  BUNDLED WITH
112
112
  2.4.22
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.8.0'
38
+ gem 'crowdin-api', '~> 1.9.0'
39
39
  ```
40
40
 
41
41
  And then execute:
@@ -120,8 +120,8 @@ storage = crowdin.add_storage('YourFilename.extension')
120
120
 
121
121
  # Download file
122
122
  file = crowdin.download_file(your_file_id, your_destination, your_project_id)
123
- # your_destination - filename or absolute path to file, optional
124
- # Without destination option file will be saved to the current directory with a default filename
123
+ # your_destination - filename or absolute path to the file, optional
124
+ # Without a destination option, the file will not be saved automatically
125
125
  # project_id is optional, as it can be initialized with a Crowdin Client
126
126
 
127
127
  # File revisions
@@ -70,9 +70,10 @@ module Crowdin
70
70
 
71
71
  # @param bundle_id [Integer] Bundle ID
72
72
  # @param export_id [String] Export ID
73
+ # @param destination [String] Destination of File
73
74
  # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.exports.download.get API Documentation}
74
75
  # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.exports.download.get Enterprise API Documentation}
75
- def download_bundle(bundle_id, export_id, project_id = config.project_id)
76
+ def download_bundle(bundle_id, export_id, destination = nil, project_id = config.project_id)
76
77
  bundle_id || raise_parameter_is_required_error(:bundle_id)
77
78
  export_id || raise_parameter_is_required_error(:export_id)
78
79
  project_id || raise_project_id_is_required_error
@@ -82,7 +83,7 @@ module Crowdin
82
83
  :get,
83
84
  "#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}/download"
84
85
  )
85
- Web::SendRequest.new(request).perform
86
+ Web::SendRequest.new(request, destination).perform
86
87
  end
87
88
 
88
89
  # @param bundle_id [Integer] Bundle ID
@@ -44,7 +44,8 @@ module Crowdin
44
44
  file_id || raise_parameter_is_required_error(:file_id)
45
45
  project_id || raise_project_id_is_required_error
46
46
 
47
- headers = query[:eTag] ? { 'If-None-Match' => query[:eTag] } : {}
47
+ etag = query.delete(:eTag)
48
+ headers = etag ? { 'If-None-Match' => etag } : {}
48
49
 
49
50
  request = Web::Request.new(
50
51
  connection,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Crowdin
4
4
  class Client
5
- VERSION = '1.8.0'
5
+ VERSION = '1.9.0'
6
6
  end
7
7
  end
@@ -44,7 +44,7 @@ describe Crowdin::ApiResources::Bundles do
44
44
 
45
45
  it 'when request are valid', :default do
46
46
  stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}/download")
47
- download_bundle = @crowdin.download_bundle(bundle_id, export_id, project_id)
47
+ download_bundle = @crowdin.download_bundle(bundle_id, export_id, nil, project_id)
48
48
  expect(download_bundle).to eq(200)
49
49
  end
50
50
  end
@@ -31,12 +31,49 @@ describe Crowdin::ApiResources::Translations do
31
31
  end
32
32
 
33
33
  describe '#build_project_file_translation' do
34
+ subject(:build_project_file_translation) do
35
+ @crowdin.build_project_file_translation(file_id, query, destination, project_id)
36
+ end
37
+
34
38
  let(:file_id) { 1 }
39
+ let(:query) { { targetLanguageId: target_language_id } }
40
+ let(:destination) { nil }
41
+
42
+ let(:target_language_id) { 'expected_language_id' }
43
+
44
+ it 'builds project file translation', :default do
45
+ expected_response = 'expected_response'
35
46
 
36
- it 'when request are valid', :default do
37
47
  stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds/files/#{file_id}")
38
- build_project_file_translation = @crowdin.build_project_file_translation(file_id, {}, nil, project_id)
39
- expect(build_project_file_translation).to eq(200)
48
+ .with(
49
+ body: JSON.dump(query)
50
+ )
51
+ .to_return(
52
+ body: JSON.dump(expected_response)
53
+ )
54
+
55
+ is_expected.to eq(expected_response)
56
+ end
57
+
58
+ context 'when the `eTag` query param is passed' do
59
+ let(:query) { { targetLanguageId: 'expected_language_id', eTag: etag } }
60
+
61
+ let(:etag) { 'expected_etag' }
62
+
63
+ it 'builds project file translation for new changes after the passed `eTag`', :default do
64
+ expected_response = 'expected_response'
65
+
66
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds/files/#{file_id}")
67
+ .with(
68
+ body: JSON.dump({ targetLanguageId: target_language_id }),
69
+ headers: { 'If-None-Match' => etag }
70
+ )
71
+ .to_return(
72
+ body: JSON.dump(expected_response)
73
+ )
74
+
75
+ is_expected.to eq(expected_response)
76
+ end
40
77
  end
41
78
  end
42
79
 
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.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crowdin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-05 00:00:00.000000000 Z
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open-uri