ruby-lokalise-api 9.3.0 → 9.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a734c5288ebac29f39891c5d83af1a5e183232bca6c163d308ea17fa2b40f71
4
- data.tar.gz: cd8cf158d27398557b9b2d24e70a6b3c8cf845e9cc44065d22de24497a69d06a
3
+ metadata.gz: bc7bacb7f1ff0d27112db67a6fb124f6eeb35bf878f23ae897a28144e5f559fa
4
+ data.tar.gz: 375fa427d45798133845573106c0a4cde68e3f26a14d0b3509a66b05823015fb
5
5
  SHA512:
6
- metadata.gz: 7f005996fb4ee75f9dc7b1b9064897aa3574e3dbf4afc2faad78f9bba09d088c560628ea798f3b8f5acc577596342c06b521bb233d6037c319fd901ca8694733
7
- data.tar.gz: b4327dc17efb6ffa8b05cfad19d63a6eccc652cc0167afd152863509bf5a7a8b415dfc955901b5586a6f020e067096dd4b920b43b7d759209e07e7687e3634f8
6
+ metadata.gz: 6e1c5f558238f260eb8b612555a403d9162660da9b4e346f29d1e42e4f0ca5a51e0d0b97917be622bf849ff6ff68c7feaf4bcaf32df3eba4b924347ddf884016
7
+ data.tar.gz: d3f8e93c4664337c946defe4f058a8ec16ae280336e97fc69ba1b71bcedffa4e1db0b26ad03c7434a8b6bece88cebed98fcf35635a5e51de14dd5937992cab8c
@@ -54,7 +54,7 @@ module RubyLokaliseApi
54
54
  # Checks whether the next page is available
55
55
  # @return [Boolean]
56
56
  def next_page?
57
- current_page.positive? && current_page < total_pages
57
+ !current_page.nil? && current_page.positive? && current_page < total_pages
58
58
  end
59
59
 
60
60
  # Checks whether the current page is the last one
@@ -66,7 +66,7 @@ module RubyLokaliseApi
66
66
  # Checks whether the previous page is available
67
67
  # @return [Boolean]
68
68
  def prev_page?
69
- current_page > 1
69
+ !current_page.nil? && current_page > 1
70
70
  end
71
71
 
72
72
  # Checks whether the current page is the first one
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Collections
5
+ class GlossaryTerms < Base
6
+ ENDPOINT = RubyLokaliseApi::Endpoints::GlossaryTermsEndpoint
7
+ RESOURCE = RubyLokaliseApi::Resources::GlossaryTerm
8
+ DATA_KEY = 'data'
9
+ end
10
+ end
11
+ end
@@ -54,7 +54,7 @@ module RubyLokaliseApi
54
54
  accept: 'application/json',
55
55
  user_agent: "ruby-lokalise-api gem/#{RubyLokaliseApi::VERSION}"
56
56
  },
57
- url: (endpoint.client.api_host || endpoint.base_url)
57
+ url: endpoint.client.api_host || endpoint.base_url
58
58
  }
59
59
  end
60
60
 
@@ -41,6 +41,18 @@ file:
41
41
  - file_id
42
42
  - filename
43
43
  - key_count
44
+ glossary_term:
45
+ - id
46
+ - projectId
47
+ - term
48
+ - description
49
+ - caseSensitive
50
+ - translatable
51
+ - forbidden
52
+ - translations
53
+ - tags
54
+ - createdAt
55
+ - updatedAt
44
56
  jwt:
45
57
  - jwt
46
58
  key:
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Endpoints
5
+ class GlossaryTermsEndpoint < MainEndpoint
6
+ private
7
+
8
+ def base_query(project_id, term_id = nil)
9
+ {
10
+ projects: project_id,
11
+ 'glossary-terms': term_id
12
+ }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -40,7 +40,7 @@ module RubyLokaliseApi
40
40
  # Delegates instance method calls to the client methods
41
41
  def delegate_call(from, to = nil)
42
42
  define_method(from) do |*args|
43
- @self_endpoint.client.send((to || from), *read_main_params.push(*args))
43
+ @self_endpoint.client.send(to || from, *read_main_params.push(*args))
44
44
  end
45
45
  end
46
46
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Resources
5
+ class GlossaryTerm < Base
6
+ MAIN_PARAMS = %i[projectId id].freeze
7
+ DATA_KEY = 'data'
8
+ no_support_for %i[update destroy]
9
+ end
10
+ end
11
+ end
@@ -36,8 +36,15 @@ module RubyLokaliseApi
36
36
  delegate_call :files
37
37
  delegate_call :upload_file
38
38
  delegate_call :download_files
39
+ delegate_call :download_files_async
39
40
  delegate_call :destroy_file
40
41
 
42
+ delegate_call :glossary_terms
43
+ delegate_call :glossary_term
44
+ delegate_call :create_glossary_terms
45
+ delegate_call :update_glossary_terms
46
+ delegate_call :destroy_glossary_terms
47
+
41
48
  delegate_call :create_jwt
42
49
 
43
50
  delegate_call :keys
@@ -50,6 +50,24 @@ module RubyLokaliseApi
50
50
  RubyLokaliseApi::Generics::DownloadBundle.new data.content
51
51
  end
52
52
 
53
+ # Downloads translation files from the project asynchronously
54
+ #
55
+ # @see https://developers.lokalise.com/reference/download-files-async
56
+ # @return [RubyLokaliseApi::Resources::QueuedProcess]
57
+ # @param project_id [String]
58
+ # @param req_params [Hash]
59
+ def download_files_async(project_id, req_params)
60
+ params = { query: [project_id, :'async-download'], req: req_params }
61
+
62
+ response = endpoint(name: 'Files', params: params).do_post
63
+
64
+ process_id = response.content['process_id']
65
+
66
+ response.patch_endpoint_with endpoint(name: 'QueuedProcesses', params: { query: [project_id, process_id] })
67
+
68
+ resource 'QueuedProcess', response
69
+ end
70
+
53
71
  # Deletes a single file from the project.
54
72
  # Only the "Documents" projects are supported
55
73
  #
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Rest
5
+ module GlossaryTerms
6
+ using RubyLokaliseApi::Utils::Classes
7
+
8
+ # Returns a single glossary term
9
+ #
10
+ # @see https://developers.lokalise.com/reference/retrieve-a-glossary-term
11
+ # @return [RubyLokaliseApi::Resources::GlossaryTerm]
12
+ # @param project_id [String]
13
+ # @param term_id [String, Integer]
14
+ def glossary_term(project_id, term_id)
15
+ params = { query: [project_id, term_id] }
16
+
17
+ data = endpoint(name: 'GlossaryTerms', params: params).do_get
18
+
19
+ resource 'GlossaryTerm', data
20
+ end
21
+
22
+ # Returns glossary terms
23
+ #
24
+ # @see https://developers.lokalise.com/reference/list-glossary-terms
25
+ # @return [RubyLokaliseApi::Collections::GlossaryTerms]
26
+ # @param project_id [String]
27
+ # @param req_params [Hash]
28
+ def glossary_terms(project_id, req_params = {})
29
+ name = 'GlossaryTerms'
30
+ params = { query: project_id, req: req_params }
31
+
32
+ data = endpoint(name: name, params: params).do_get
33
+
34
+ collection name, data
35
+ end
36
+
37
+ # Creates one or multiple glossary terms in the project
38
+ #
39
+ # @see https://developers.lokalise.com/reference/create-glossary-terms
40
+ # @return [RubyLokaliseApi::Collections::GlossaryTerms]
41
+ # @param project_id [String]
42
+ # @param req_params [Hash, Array]
43
+ def create_glossary_terms(project_id, req_params)
44
+ name = 'GlossaryTerms'
45
+ params = { query: project_id, req: req_params.to_array_obj(:terms) }
46
+
47
+ data = endpoint(name: name, params: params).do_post
48
+
49
+ collection name, data
50
+ end
51
+
52
+ # Updates one or multiple glossary terms in the project
53
+ #
54
+ # @see https://developers.lokalise.com/reference/update-glossary-terms
55
+ # @return [RubyLokaliseApi::Collections::GlossaryTerms]
56
+ # @param project_id [String]
57
+ # @param req_params [Hash, Array]
58
+ def update_glossary_terms(project_id, req_params)
59
+ name = 'GlossaryTerms'
60
+ params = { query: project_id, req: req_params.to_array_obj(:terms) }
61
+
62
+ data = endpoint(name: name, params: params).do_put
63
+
64
+ collection name, data
65
+ end
66
+
67
+ # Deletes one or multiple glossary terms from the project
68
+ #
69
+ # @see https://developers.lokalise.com/reference/delete-glossary-terms
70
+ # @return [RubyLokaliseApi::Generics::DeletedResource]
71
+ # @param project_id [String]
72
+ # @param term_ids [Array, String]
73
+ def destroy_glossary_terms(project_id, term_ids)
74
+ params = { query: project_id, req: term_ids.to_array_obj(:terms) }
75
+
76
+ data = endpoint(name: 'GlossaryTerms', params: params).do_delete
77
+
78
+ RubyLokaliseApi::Generics::DeletedResource.new data.content
79
+ end
80
+ end
81
+ end
82
+ end
@@ -9,6 +9,7 @@ module RubyLokaliseApi
9
9
  include Rest::Contributors
10
10
  include Rest::CustomTranslationStatuses
11
11
  include Rest::Files
12
+ include Rest::GlossaryTerms
12
13
  include Rest::Jwts
13
14
  include Rest::Keys
14
15
  include Rest::Languages
@@ -6,10 +6,10 @@ module RubyLokaliseApi
6
6
  using RubyLokaliseApi::Utils::Strings
7
7
  using RubyLokaliseApi::Utils::Classes
8
8
 
9
- private
10
-
11
9
  UNIFIED_RESOURCES = %w[comment].freeze
12
10
 
11
+ private
12
+
13
13
  # Loads attributes for the given resource based on its name
14
14
  #
15
15
  # @return [Array<String>]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyLokaliseApi
4
- VERSION = '9.3.0'
4
+ VERSION = '9.5.0'
5
5
  end
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency 'json', '~> 2'
28
28
  spec.add_dependency 'zeitwerk', '~> 2.4'
29
29
 
30
+ spec.add_development_dependency 'base64', '~> 0.2.0'
30
31
  spec.add_development_dependency 'dotenv', '~> 3.0'
31
32
  spec.add_development_dependency 'oj', '~> 3.10'
32
33
  spec.add_development_dependency 'rake', '~> 13.0'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lokalise-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.3.0
4
+ version: 9.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Krukowski
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: addressable
@@ -86,6 +85,20 @@ dependencies:
86
85
  - - "~>"
87
86
  - !ruby/object:Gem::Version
88
87
  version: '2.4'
88
+ - !ruby/object:Gem::Dependency
89
+ name: base64
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: 0.2.0
95
+ type: :development
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: 0.2.0
89
102
  - !ruby/object:Gem::Dependency
90
103
  name: dotenv
91
104
  requirement: !ruby/object:Gem::Requirement
@@ -265,6 +278,7 @@ files:
265
278
  - lib/ruby_lokalise_api/collections/contributors.rb
266
279
  - lib/ruby_lokalise_api/collections/custom_translation_statuses.rb
267
280
  - lib/ruby_lokalise_api/collections/files.rb
281
+ - lib/ruby_lokalise_api/collections/glossary_terms.rb
268
282
  - lib/ruby_lokalise_api/collections/key_comments.rb
269
283
  - lib/ruby_lokalise_api/collections/keys.rb
270
284
  - lib/ruby_lokalise_api/collections/orders.rb
@@ -296,6 +310,7 @@ files:
296
310
  - lib/ruby_lokalise_api/endpoints/contributors_endpoint.rb
297
311
  - lib/ruby_lokalise_api/endpoints/custom_translation_statuses_endpoint.rb
298
312
  - lib/ruby_lokalise_api/endpoints/files_endpoint.rb
313
+ - lib/ruby_lokalise_api/endpoints/glossary_terms_endpoint.rb
299
314
  - lib/ruby_lokalise_api/endpoints/jwts_endpoint.rb
300
315
  - lib/ruby_lokalise_api/endpoints/key_comments_endpoint.rb
301
316
  - lib/ruby_lokalise_api/endpoints/keys_endpoint.rb
@@ -332,6 +347,7 @@ files:
332
347
  - lib/ruby_lokalise_api/resources/contributor.rb
333
348
  - lib/ruby_lokalise_api/resources/custom_translation_status.rb
334
349
  - lib/ruby_lokalise_api/resources/file.rb
350
+ - lib/ruby_lokalise_api/resources/glossary_term.rb
335
351
  - lib/ruby_lokalise_api/resources/jwt.rb
336
352
  - lib/ruby_lokalise_api/resources/key.rb
337
353
  - lib/ruby_lokalise_api/resources/oauth2_refreshed_token.rb
@@ -361,6 +377,7 @@ files:
361
377
  - lib/ruby_lokalise_api/rest/contributors.rb
362
378
  - lib/ruby_lokalise_api/rest/custom_translation_statuses.rb
363
379
  - lib/ruby_lokalise_api/rest/files.rb
380
+ - lib/ruby_lokalise_api/rest/glossary_terms.rb
364
381
  - lib/ruby_lokalise_api/rest/jwts.rb
365
382
  - lib/ruby_lokalise_api/rest/keys.rb
366
383
  - lib/ruby_lokalise_api/rest/languages.rb
@@ -392,7 +409,6 @@ licenses:
392
409
  - BSD-3-Clause
393
410
  metadata:
394
411
  rubygems_mfa_required: 'true'
395
- post_install_message:
396
412
  rdoc_options: []
397
413
  require_paths:
398
414
  - lib
@@ -407,8 +423,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
407
423
  - !ruby/object:Gem::Version
408
424
  version: '0'
409
425
  requirements: []
410
- rubygems_version: 3.5.23
411
- signing_key:
426
+ rubygems_version: 3.6.8
412
427
  specification_version: 4
413
428
  summary: Ruby interface to the Lokalise API
414
429
  test_files: []