ruby-lokalise-api 9.4.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: 629370ecc172cb152cfe2341dda5f25f671c6c7ee22694e85109817578bfb556
4
- data.tar.gz: c7e63178a3e34f5fd4be71ce877d9f8e13060a2faa92fcce02e8863239297af0
3
+ metadata.gz: bc7bacb7f1ff0d27112db67a6fb124f6eeb35bf878f23ae897a28144e5f559fa
4
+ data.tar.gz: 375fa427d45798133845573106c0a4cde68e3f26a14d0b3509a66b05823015fb
5
5
  SHA512:
6
- metadata.gz: 8abab50ba6b978a40a2e1f5797052b7cfeb9fb44ad4d4d5ca3265006d1388761a5f5b115d9bc5874a3b45f24117f75556999ce34c082a7789775c3a306cacb87
7
- data.tar.gz: d1c6236778bd2fe7b82318f6d7fc886479e01d544dc415fad08fa7c06c8b6ee6bf928b56fbe4a103a3d649b87afa4ab7655099a363f3e326986b86f33b58468c
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
@@ -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
@@ -39,6 +39,12 @@ module RubyLokaliseApi
39
39
  delegate_call :download_files_async
40
40
  delegate_call :destroy_file
41
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
+
42
48
  delegate_call :create_jwt
43
49
 
44
50
  delegate_call :keys
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyLokaliseApi
4
- VERSION = '9.4.0'
4
+ VERSION = '9.5.0'
5
5
  end
@@ -27,7 +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
+ spec.add_development_dependency 'base64', '~> 0.2.0'
31
31
  spec.add_development_dependency 'dotenv', '~> 3.0'
32
32
  spec.add_development_dependency 'oj', '~> 3.10'
33
33
  spec.add_development_dependency 'rake', '~> 13.0'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lokalise-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.4.0
4
+ version: 9.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Krukowski
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: addressable
@@ -278,6 +278,7 @@ files:
278
278
  - lib/ruby_lokalise_api/collections/contributors.rb
279
279
  - lib/ruby_lokalise_api/collections/custom_translation_statuses.rb
280
280
  - lib/ruby_lokalise_api/collections/files.rb
281
+ - lib/ruby_lokalise_api/collections/glossary_terms.rb
281
282
  - lib/ruby_lokalise_api/collections/key_comments.rb
282
283
  - lib/ruby_lokalise_api/collections/keys.rb
283
284
  - lib/ruby_lokalise_api/collections/orders.rb
@@ -309,6 +310,7 @@ files:
309
310
  - lib/ruby_lokalise_api/endpoints/contributors_endpoint.rb
310
311
  - lib/ruby_lokalise_api/endpoints/custom_translation_statuses_endpoint.rb
311
312
  - lib/ruby_lokalise_api/endpoints/files_endpoint.rb
313
+ - lib/ruby_lokalise_api/endpoints/glossary_terms_endpoint.rb
312
314
  - lib/ruby_lokalise_api/endpoints/jwts_endpoint.rb
313
315
  - lib/ruby_lokalise_api/endpoints/key_comments_endpoint.rb
314
316
  - lib/ruby_lokalise_api/endpoints/keys_endpoint.rb
@@ -345,6 +347,7 @@ files:
345
347
  - lib/ruby_lokalise_api/resources/contributor.rb
346
348
  - lib/ruby_lokalise_api/resources/custom_translation_status.rb
347
349
  - lib/ruby_lokalise_api/resources/file.rb
350
+ - lib/ruby_lokalise_api/resources/glossary_term.rb
348
351
  - lib/ruby_lokalise_api/resources/jwt.rb
349
352
  - lib/ruby_lokalise_api/resources/key.rb
350
353
  - lib/ruby_lokalise_api/resources/oauth2_refreshed_token.rb
@@ -374,6 +377,7 @@ files:
374
377
  - lib/ruby_lokalise_api/rest/contributors.rb
375
378
  - lib/ruby_lokalise_api/rest/custom_translation_statuses.rb
376
379
  - lib/ruby_lokalise_api/rest/files.rb
380
+ - lib/ruby_lokalise_api/rest/glossary_terms.rb
377
381
  - lib/ruby_lokalise_api/rest/jwts.rb
378
382
  - lib/ruby_lokalise_api/rest/keys.rb
379
383
  - lib/ruby_lokalise_api/rest/languages.rb
@@ -419,7 +423,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
419
423
  - !ruby/object:Gem::Version
420
424
  version: '0'
421
425
  requirements: []
422
- rubygems_version: 3.6.3
426
+ rubygems_version: 3.6.8
423
427
  specification_version: 4
424
428
  summary: Ruby interface to the Lokalise API
425
429
  test_files: []