ruby-lokalise-api 9.4.0 → 9.6.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: 626901ad0ff2b3ba8be2bae730baa6673a377123890981e5f67db31e1d137fc9
4
+ data.tar.gz: d3cd767767f3d467ae94e113a74e876670f430e0d080416e45f250d99851735d
5
5
  SHA512:
6
- metadata.gz: 8abab50ba6b978a40a2e1f5797052b7cfeb9fb44ad4d4d5ca3265006d1388761a5f5b115d9bc5874a3b45f24117f75556999ce34c082a7789775c3a306cacb87
7
- data.tar.gz: d1c6236778bd2fe7b82318f6d7fc886479e01d544dc415fad08fa7c06c8b6ee6bf928b56fbe4a103a3d649b87afa4ab7655099a363f3e326986b86f33b58468c
6
+ metadata.gz: c1e45a7a061aec930386ce7c96ef19b924e4f4c64e5396a8a16e20419998bdc95e4115c0e19a1f25b9a11ef4c0dfa3ab6345caa38503ca534b1ef213b7c4b7a1
7
+ data.tar.gz: bdc8fb68cbbd264a996e626b1a1c904d7a8336fd60ac32327fadd35be5eb57d67250ec513674e7264ddfee4030b5e65c35babf41a9ceb4c5d4945af37a8de01d
@@ -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
@@ -5,8 +5,10 @@ module RubyLokaliseApi
5
5
  class TeamsEndpoint < MainEndpoint
6
6
  private
7
7
 
8
- def base_query(*_args)
9
- [:teams]
8
+ def base_query(team_id = nil, *_args)
9
+ {
10
+ teams: [team_id]
11
+ }
10
12
  end
11
13
  end
12
14
  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
@@ -22,6 +22,7 @@ module RubyLokaliseApi
22
22
 
23
23
  delegate_call :contributor
24
24
  delegate_call :contributors
25
+ delegate_call :current_contributor
25
26
  delegate_call :create_contributors
26
27
  delegate_call :update_contributor
27
28
  delegate_call :destroy_contributor
@@ -39,6 +40,12 @@ module RubyLokaliseApi
39
40
  delegate_call :download_files_async
40
41
  delegate_call :destroy_file
41
42
 
43
+ delegate_call :glossary_terms
44
+ delegate_call :glossary_term
45
+ delegate_call :create_glossary_terms
46
+ delegate_call :update_glossary_terms
47
+ delegate_call :destroy_glossary_terms
48
+
42
49
  delegate_call :create_jwt
43
50
 
44
51
  delegate_call :keys
@@ -3,8 +3,8 @@
3
3
  module RubyLokaliseApi
4
4
  module Resources
5
5
  class Team < Base
6
- MAIN_PARAMS = [].freeze
7
- no_support_for %i[update destroy reload_data]
6
+ MAIN_PARAMS = %i[team_id].freeze
7
+ no_support_for %i[update destroy]
8
8
  end
9
9
  end
10
10
  end
@@ -19,6 +19,19 @@ module RubyLokaliseApi
19
19
  resource 'Contributor', data
20
20
  end
21
21
 
22
+ # Returns current contributor (me)
23
+ #
24
+ # @see https://developers.lokalise.com/reference/retrieve-me-as-a-contributor
25
+ # @return [RubyLokaliseApi::Resources::Contributor]
26
+ # @param project_id [String]
27
+ def current_contributor(project_id)
28
+ params = { query: [project_id, :me] }
29
+
30
+ data = endpoint(name: 'Contributors', params: params).do_get
31
+
32
+ resource 'Contributor', data
33
+ end
34
+
22
35
  # Returns project contributors
23
36
  #
24
37
  # @see https://developers.lokalise.com/reference/list-all-contributors
@@ -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
@@ -16,6 +16,19 @@ module RubyLokaliseApi
16
16
 
17
17
  collection name, data
18
18
  end
19
+
20
+ # Returns a single team
21
+ #
22
+ # @see https://developers.lokalise.com/reference/get-team-details
23
+ # @return [RubyLokaliseApi::Resources::Team]
24
+ # @param team_id [String, Integer]
25
+ def team(team_id)
26
+ params = { query: team_id }
27
+
28
+ data = endpoint(name: 'Teams', params: params).do_get
29
+
30
+ resource 'Team', data
31
+ end
19
32
  end
20
33
  end
21
34
  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.6.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.6.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: []