ruby-lokalise-api 5.0.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -2
  3. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/base_request.rb +4 -4
  4. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/client.rb +24 -24
  5. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/base.rb +10 -10
  6. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/branch.rb +1 -1
  7. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/contributor.rb +1 -1
  8. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/custom_translation_status.rb +1 -1
  9. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/file.rb +1 -1
  10. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key.rb +2 -2
  11. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key_comment.rb +1 -1
  12. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/order.rb +1 -1
  13. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/payment_card.rb +1 -1
  14. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project.rb +1 -1
  15. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_comment.rb +1 -1
  16. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_language.rb +1 -1
  17. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/queued_process.rb +1 -1
  18. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/screenshot.rb +1 -1
  19. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/segment.rb +1 -1
  20. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/snapshot.rb +1 -1
  21. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/system_language.rb +1 -1
  22. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/task.rb +1 -1
  23. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team.rb +1 -1
  24. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user.rb +1 -1
  25. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user_group.rb +1 -1
  26. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation.rb +1 -1
  27. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation_provider.rb +1 -1
  28. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/webhook.rb +1 -1
  29. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/connection.rb +2 -2
  30. data/lib/ruby_lokalise_api/data/attributes.yml +235 -0
  31. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/error.rb +14 -14
  32. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/json_handler.rb +1 -1
  33. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/auth.rb +2 -2
  34. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/connection.rb +2 -2
  35. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/request.rb +3 -3
  36. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2_client.rb +1 -1
  37. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/request.rb +3 -3
  38. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/base.rb +8 -8
  39. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/branch.rb +1 -1
  40. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/contributor.rb +1 -1
  41. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/custom_translation_status.rb +1 -1
  42. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/file.rb +2 -2
  43. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key.rb +1 -1
  44. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key_comment.rb +1 -1
  45. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/order.rb +1 -1
  46. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/payment_card.rb +1 -1
  47. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project.rb +1 -1
  48. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_comment.rb +1 -1
  49. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_language.rb +1 -1
  50. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/queued_process.rb +1 -1
  51. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/screenshot.rb +1 -1
  52. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/segment.rb +1 -1
  53. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/snapshot.rb +2 -2
  54. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/system_language.rb +1 -1
  55. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/task.rb +1 -1
  56. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team.rb +1 -1
  57. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user.rb +1 -1
  58. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_billing_details.rb +1 -1
  59. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_group.rb +1 -1
  60. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation.rb +1 -1
  61. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation_provider.rb +1 -1
  62. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/webhook.rb +1 -1
  63. data/lib/ruby_lokalise_api/rest/branches.rb +69 -0
  64. data/lib/ruby_lokalise_api/rest/comments.rb +61 -0
  65. data/lib/ruby_lokalise_api/rest/contributors.rb +58 -0
  66. data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +67 -0
  67. data/lib/ruby_lokalise_api/rest/files.rb +38 -0
  68. data/lib/ruby_lokalise_api/rest/keys.rb +79 -0
  69. data/lib/ruby_lokalise_api/rest/languages.rb +67 -0
  70. data/lib/ruby_lokalise_api/rest/orders.rb +37 -0
  71. data/lib/ruby_lokalise_api/rest/payment_cards.rb +43 -0
  72. data/lib/ruby_lokalise_api/rest/projects.rb +62 -0
  73. data/lib/ruby_lokalise_api/rest/queued_processes.rb +28 -0
  74. data/lib/ruby_lokalise_api/rest/screenshots.rb +58 -0
  75. data/lib/ruby_lokalise_api/rest/segments.rb +45 -0
  76. data/lib/ruby_lokalise_api/rest/snapshots.rb +47 -0
  77. data/lib/ruby_lokalise_api/rest/tasks.rb +58 -0
  78. data/lib/ruby_lokalise_api/rest/team_user_billing_details.rb +36 -0
  79. data/lib/ruby_lokalise_api/rest/team_user_groups.rb +109 -0
  80. data/lib/ruby_lokalise_api/rest/team_users.rb +48 -0
  81. data/lib/ruby_lokalise_api/rest/teams.rb +16 -0
  82. data/lib/ruby_lokalise_api/rest/translation_providers.rb +27 -0
  83. data/lib/ruby_lokalise_api/rest/translations.rb +39 -0
  84. data/lib/ruby_lokalise_api/rest/webhooks.rb +69 -0
  85. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/attribute_helpers.rb +7 -7
  86. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/endpoint_helpers.rb +1 -1
  87. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/string_utils.rb +1 -1
  88. data/lib/ruby_lokalise_api/version.rb +5 -0
  89. data/lib/ruby_lokalise_api.rb +50 -0
  90. data/ruby-lokalise-api.gemspec +6 -5
  91. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/branches_spec.rb +5 -5
  92. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/comments_spec.rb +7 -7
  93. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/contributors_spec.rb +9 -9
  94. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/custom_translation_statuses_spec.rb +7 -7
  95. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/files_spec.rb +2 -2
  96. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/keys_spec.rb +14 -14
  97. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/languages_spec.rb +4 -4
  98. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/orders_spec.rb +1 -1
  99. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/payment_cards_spec.rb +7 -7
  100. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/projects_spec.rb +10 -10
  101. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/queued_processes_spec.rb +1 -1
  102. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/screenshots_spec.rb +3 -3
  103. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/segments_spec.rb +4 -4
  104. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/snapshots_spec.rb +8 -8
  105. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/tasks_spec.rb +12 -12
  106. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/team_user_billing_details_spec.rb +1 -1
  107. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/team_user_groups_spec.rb +7 -7
  108. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/team_users_spec.rb +3 -3
  109. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/teams_spec.rb +1 -1
  110. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/translation_providers_spec.rb +2 -2
  111. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/translations_spec.rb +10 -10
  112. data/spec/lib/{ruby-lokalise-api/rest → ruby_lokalise_api/client}/webhooks_spec.rb +2 -2
  113. data/spec/lib/{ruby-lokalise-api → ruby_lokalise_api}/connection_spec.rb +8 -8
  114. data/spec/lib/{ruby-lokalise-api → ruby_lokalise_api}/custom_json_parser_spec.rb +3 -3
  115. data/spec/lib/{ruby-lokalise-api → ruby_lokalise_api}/error_spec.rb +10 -10
  116. data/spec/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/auth_spec.rb +3 -3
  117. data/spec/lib/{ruby-lokalise-api_spec.rb → ruby_lokalise_api_spec.rb} +5 -5
  118. data/spec/spec_helper.rb +1 -1
  119. data/spec/support/test_client.rb +3 -3
  120. metadata +163 -149
  121. data/lib/ruby-lokalise-api/data/attributes.json +0 -259
  122. data/lib/ruby-lokalise-api/rest/branches.rb +0 -67
  123. data/lib/ruby-lokalise-api/rest/comments.rb +0 -59
  124. data/lib/ruby-lokalise-api/rest/contributors.rb +0 -56
  125. data/lib/ruby-lokalise-api/rest/custom_translation_statuses.rb +0 -65
  126. data/lib/ruby-lokalise-api/rest/files.rb +0 -36
  127. data/lib/ruby-lokalise-api/rest/keys.rb +0 -77
  128. data/lib/ruby-lokalise-api/rest/languages.rb +0 -65
  129. data/lib/ruby-lokalise-api/rest/orders.rb +0 -35
  130. data/lib/ruby-lokalise-api/rest/payment_cards.rb +0 -41
  131. data/lib/ruby-lokalise-api/rest/projects.rb +0 -60
  132. data/lib/ruby-lokalise-api/rest/queued_processes.rb +0 -26
  133. data/lib/ruby-lokalise-api/rest/screenshots.rb +0 -56
  134. data/lib/ruby-lokalise-api/rest/segments.rb +0 -43
  135. data/lib/ruby-lokalise-api/rest/snapshots.rb +0 -45
  136. data/lib/ruby-lokalise-api/rest/tasks.rb +0 -56
  137. data/lib/ruby-lokalise-api/rest/team_user_billing_details.rb +0 -34
  138. data/lib/ruby-lokalise-api/rest/team_user_group.rb +0 -107
  139. data/lib/ruby-lokalise-api/rest/team_users.rb +0 -46
  140. data/lib/ruby-lokalise-api/rest/teams.rb +0 -14
  141. data/lib/ruby-lokalise-api/rest/translation_providers.rb +0 -25
  142. data/lib/ruby-lokalise-api/rest/translations.rb +0 -37
  143. data/lib/ruby-lokalise-api/rest/webhooks.rb +0 -67
  144. data/lib/ruby-lokalise-api/version.rb +0 -5
  145. data/lib/ruby-lokalise-api.rb +0 -111
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Rest
5
+ module TeamUsers
6
+ # Returns all team users for the given team
7
+ #
8
+ # @see https://app.lokalise.com/api2docs/curl/#transition-list-all-team-users-get
9
+ # @return [RubyLokaliseApi::Collection::TeamUser<RubyLokaliseApi::Resources::TeamUser>]
10
+ # @param team_id [String]
11
+ # @param params [Hash]
12
+ def team_users(team_id, params = {})
13
+ c_r RubyLokaliseApi::Collections::TeamUser, :all, team_id, params
14
+ end
15
+
16
+ # Returns team user from the given team
17
+ #
18
+ # @see https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-team-user-get
19
+ # @return [RubyLokaliseApi::Resources::TeamUser]
20
+ # @param team_id [String]
21
+ # @param user_id [String, Integer]
22
+ def team_user(team_id, user_id)
23
+ c_r RubyLokaliseApi::Resources::TeamUser, :find, [team_id, user_id]
24
+ end
25
+
26
+ # Updates team user for the given team
27
+ #
28
+ # @see https://app.lokalise.com/api2docs/curl/#transition-update-a-team-user-put
29
+ # @return [RubyLokaliseApi::Resources::TeamUser]
30
+ # @param team_id [String]
31
+ # @param user_id [String, Integer]
32
+ # @param params [Hash]
33
+ def update_team_user(team_id, user_id, params)
34
+ c_r RubyLokaliseApi::Resources::TeamUser, :update, [team_id, user_id], params
35
+ end
36
+
37
+ # Deletes team user from the given team
38
+ #
39
+ # @see https://app.lokalise.com/api2docs/curl/#transition-delete-a-team-user-delete
40
+ # @return [RubyLokaliseApi::Resources::TeamUser]
41
+ # @param team_id [String]
42
+ # @param user_id [String, Integer]
43
+ def destroy_team_user(team_id, user_id)
44
+ c_r RubyLokaliseApi::Resources::TeamUser, :destroy, [team_id, user_id]
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Rest
5
+ module Teams
6
+ # Returns all teams available to the user
7
+ #
8
+ # @see https://app.lokalise.com/api2docs/curl/#transition-list-all-teams-get
9
+ # @return [RubyLokaliseApi::Collection::Team<RubyLokaliseApi::Resources::Team>]
10
+ # @param params [Hash]
11
+ def teams(params = {})
12
+ c_r RubyLokaliseApi::Collections::Team, :all, nil, params
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Rest
5
+ module TranslationProviders
6
+ # Returns all translation providers for the given team
7
+ #
8
+ # @see https://app.lokalise.com/api2docs/curl/#transition-list-all-providers-get
9
+ # @return [RubyLokaliseApi::Collection::TranslationProvider<RubyLokaliseApi::Resources::TranslationProvider>]
10
+ # @param team_id [String]
11
+ # @param params [Hash]
12
+ def translation_providers(team_id, params = {})
13
+ c_r RubyLokaliseApi::Collections::TranslationProvider, :all, team_id, params
14
+ end
15
+
16
+ # Returns a single translation provider for the given team
17
+ #
18
+ # @see https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-provider-get
19
+ # @return [RubyLokaliseApi::Resources::TranslationProvider]
20
+ # @param team_id [String]
21
+ # @param provider_id [String, Integer]
22
+ def translation_provider(team_id, provider_id)
23
+ c_r RubyLokaliseApi::Resources::TranslationProvider, :find, [team_id, provider_id]
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Rest
5
+ module Translations
6
+ # Returns all translations for the given project (ungrouped)
7
+ #
8
+ # @see https://app.lokalise.com/api2docs/curl/#transition-list-all-translations-get
9
+ # @return [RubyLokaliseApi::Collection::Translation<RubyLokaliseApi::Resources::Translation>]
10
+ # @param project_id [String]
11
+ # @param params [Hash]
12
+ def translations(project_id, params = {})
13
+ c_r RubyLokaliseApi::Collections::Translation, :all, project_id, params
14
+ end
15
+
16
+ # Returns translation of the given project
17
+ #
18
+ # @see https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-translation-get
19
+ # @return [RubyLokaliseApi::Resources::Translation]
20
+ # @param project_id [String]
21
+ # @param translation_id [String, Integer]
22
+ # @param params [Hash]
23
+ def translation(project_id, translation_id, params = {})
24
+ c_r RubyLokaliseApi::Resources::Translation, :find, [project_id, translation_id], params
25
+ end
26
+
27
+ # Updates translation of the given project
28
+ #
29
+ # @see https://app.lokalise.com/api2docs/curl/#transition-update-a-translation-put
30
+ # @return [RubyLokaliseApi::Resources::Translation]
31
+ # @param project_id [String]
32
+ # @param translation_id [String, Integer]
33
+ # @param params [Hash]
34
+ def update_translation(project_id, translation_id, params)
35
+ c_r RubyLokaliseApi::Resources::Translation, :update, [project_id, translation_id], params
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Rest
5
+ module Webhooks
6
+ # Returns all webhooks for the given project
7
+ #
8
+ # @see https://app.lokalise.com/api2docs/curl/#transition-list-all-webhooks-get
9
+ # @return [RubyLokaliseApi::Collection::Webhook<RubyLokaliseApi::Resources::Webhook>]
10
+ # @param project_id [String]
11
+ # @param params [Hash]
12
+ def webhooks(project_id, params = {})
13
+ c_r RubyLokaliseApi::Collections::Webhook, :all, project_id, params
14
+ end
15
+
16
+ # Returns a single webhook for the given project
17
+ #
18
+ # @see https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-webhook-get
19
+ # @return [RubyLokaliseApi::Resources::Webhook]
20
+ # @param project_id [String]
21
+ # @param webhook_id [String, Integer]
22
+ def webhook(project_id, webhook_id)
23
+ c_r RubyLokaliseApi::Resources::Webhook, :find, [project_id, webhook_id]
24
+ end
25
+
26
+ # Creates webhook for the given project
27
+ #
28
+ # @see https://app.lokalise.com/api2docs/curl/#transition-create-a-webhook-post
29
+ # @return [RubyLokaliseApi::Resources::Webhook]
30
+ # @param project_id [String]
31
+ # @param params [Hash]
32
+ def create_webhook(project_id, params)
33
+ c_r RubyLokaliseApi::Resources::Webhook, :create, project_id, params
34
+ end
35
+
36
+ # Updates webhook for the given project
37
+ #
38
+ # @see https://app.lokalise.com/api2docs/curl/#transition-update-a-webhook-put
39
+ # @return [RubyLokaliseApi::Resources::Webhook]
40
+ # @param project_id [String]
41
+ # @param webhook_id [String, Integer]
42
+ # @param params [Hash]
43
+ def update_webhook(project_id, webhook_id, params = {})
44
+ c_r RubyLokaliseApi::Resources::Webhook, :update, [project_id, webhook_id], params
45
+ end
46
+
47
+ # Deletes webhook for the given project
48
+ #
49
+ # @see https://app.lokalise.com/api2docs/curl/#transition-delete-a-webhook-delete
50
+ # @return [Hash]
51
+ # @param project_id [String]
52
+ # @param webhook_id [String, Integer]
53
+ def destroy_webhook(project_id, webhook_id)
54
+ c_r RubyLokaliseApi::Resources::Webhook, :destroy, [project_id, webhook_id]
55
+ end
56
+
57
+ # Regenerates secret for the given webhook
58
+ #
59
+ # @see https://lokalise.com/api2docs/curl/#transition-regenerate-a-webhook-secret-patch
60
+ # @return [Hash]
61
+ # @param project_id [String]
62
+ # @param webhook_id [String, Integer]
63
+ def regenerate_webhook_secret(project_id, webhook_id)
64
+ c_r RubyLokaliseApi::Resources::Webhook, :regenerate_secret,
65
+ [project_id, webhook_id, 'secret', 'regenerate']
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Lokalise
3
+ module RubyLokaliseApi
4
4
  module Utils
5
5
  module AttributeHelpers
6
- using Lokalise::Utils::StringUtils
6
+ using RubyLokaliseApi::Utils::StringUtils
7
7
 
8
8
  UNIFIED_RESOURCES = %w[comment language].freeze
9
9
 
@@ -49,7 +49,7 @@ module Lokalise
49
49
  #
50
50
  # @return [Array<String>]
51
51
  def attributes_for(klass)
52
- @attributes ||= YAML.load_file(File.expand_path('../data/attributes.json', __dir__)).freeze
52
+ @attributes ||= YAML.load_file(File.expand_path('../data/attributes.yml', __dir__)).freeze
53
53
 
54
54
  name = unify klass.name.snakecase
55
55
  @attributes[name]
@@ -58,10 +58,10 @@ module Lokalise
58
58
  private
59
59
 
60
60
  def get_key(name:, model_class:, collection: false, strict: false)
61
- key = if collection && Module.const_defined?("Lokalise::Collections::#{model_class}::#{name}")
62
- Module.const_get "Lokalise::Collections::#{model_class}::#{name}"
63
- elsif Module.const_defined? "Lokalise::Resources::#{model_class}::#{name}"
64
- Module.const_get "Lokalise::Resources::#{model_class}::#{name}"
61
+ key = if collection && Module.const_defined?("RubyLokaliseApi::Collections::#{model_class}::#{name}")
62
+ Module.const_get "RubyLokaliseApi::Collections::#{model_class}::#{name}"
63
+ elsif Module.const_defined? "RubyLokaliseApi::Resources::#{model_class}::#{name}"
64
+ Module.const_get "RubyLokaliseApi::Resources::#{model_class}::#{name}"
65
65
  else
66
66
  strict ? nil : model_class
67
67
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Lokalise
3
+ module RubyLokaliseApi
4
4
  module Utils
5
5
  module EndpointHelpers
6
6
  def path_from(raw_mapping)
@@ -3,7 +3,7 @@
3
3
  # Initial code taken from Facets gem by Rubyworks
4
4
  # https://github.com/rubyworks/facets/blob/master/lib/core/facets/string/snakecase.rb
5
5
 
6
- module Lokalise
6
+ module RubyLokaliseApi
7
7
  module Utils
8
8
  module StringUtils
9
9
  refine String do
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ VERSION = '6.0.0'
5
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'zeitwerk'
4
+ require 'faraday'
5
+ require 'faraday/gzip'
6
+ require 'yaml'
7
+ require 'addressable'
8
+
9
+ loader = Zeitwerk::Loader.for_gem
10
+ loader.inflector.inflect(
11
+ 'oauth2' => 'OAuth2',
12
+ 'oauth2_client' => 'OAuth2Client'
13
+ )
14
+ loader.setup
15
+
16
+ module RubyLokaliseApi
17
+ class << self
18
+ # Initializes a new Client object
19
+ #
20
+ # @return [RubyLokaliseApi::Client]
21
+ # @param token [String]
22
+ # @param params [Hash]
23
+ def client(token, params = {})
24
+ @client = RubyLokaliseApi::Client.new token, params
25
+ end
26
+
27
+ # Reset the currently set client
28
+ def reset_client!
29
+ @client = nil
30
+ end
31
+
32
+ # Initializes a new OAuth2Client object
33
+ #
34
+ # @return [RubyLokaliseApi::OAuth2Client]
35
+ # @param token [String]
36
+ # @param params [Hash]
37
+ def oauth2_client(token, params = {})
38
+ @oauth2_client = RubyLokaliseApi::OAuth2Client.new token, params
39
+ end
40
+
41
+ # Reset the currently set OAuth2 client
42
+ def reset_oauth2_client!
43
+ @oauth2_client = nil
44
+ end
45
+
46
+ def auth_client(client_id, client_secret)
47
+ RubyLokaliseApi::OAuth2::Auth.new client_id, client_secret
48
+ end
49
+ end
50
+ end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('lib/ruby-lokalise-api/version', __dir__)
3
+ require File.expand_path('lib/ruby_lokalise_api/version', __dir__)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'ruby-lokalise-api'
7
- spec.version = Lokalise::VERSION
7
+ spec.version = RubyLokaliseApi::VERSION
8
8
  spec.authors = ['Ilya Bodrov-Krukowski']
9
9
  spec.email = ['golosizpru@gmail.com']
10
10
  spec.summary = 'Ruby interface to the Lokalise API'
@@ -12,10 +12,10 @@ Gem::Specification.new do |spec|
12
12
  spec.homepage = 'https://github.com/lokalise/ruby-lokalise-api'
13
13
  spec.license = 'BSD-3-Clause'
14
14
  spec.platform = Gem::Platform::RUBY
15
- spec.required_ruby_version = '>= 2.5.0'
15
+ spec.required_ruby_version = '>= 2.7'
16
16
 
17
17
  spec.files = Dir['README.md', 'LICENSE',
18
- 'CHANGELOG.md', 'lib/**/*.rb', 'lib/ruby-lokalise-api/data/attributes.json',
18
+ 'CHANGELOG.md', 'lib/**/*.rb', 'lib/ruby_lokalise_api/data/attributes.yml',
19
19
  'ruby-lokalise-api.gemspec', '.github/*.md',
20
20
  'Gemfile', 'Rakefile']
21
21
  spec.test_files = Dir['spec/**/*.rb']
@@ -25,7 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency 'addressable', '~> 2.5'
26
26
  spec.add_dependency 'faraday', '~> 2.0'
27
27
  spec.add_dependency 'faraday-gzip', '~> 0.1'
28
- spec.add_dependency 'json', '>= 1.8.0'
28
+ spec.add_dependency 'json', '~> 2'
29
+ spec.add_dependency 'zeitwerk', '~> 2.4'
29
30
 
30
31
  spec.add_development_dependency 'codecov', '~> 0.1'
31
32
  spec.add_development_dependency 'dotenv', '~> 2.5'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Lokalise::Client do
3
+ RSpec.describe RubyLokaliseApi::Client do
4
4
  let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
5
  let(:branch_id) { 41_302 }
6
6
 
@@ -74,7 +74,7 @@ RSpec.describe Lokalise::Client do
74
74
  end
75
75
 
76
76
  expect(response['project_id']).to eq(project_id)
77
- expect(response['branch_deleted']).to eq(true)
77
+ expect(response['branch_deleted']).to be(true)
78
78
  end
79
79
 
80
80
  specify '#merge_branch' do
@@ -91,7 +91,7 @@ RSpec.describe Lokalise::Client do
91
91
  end
92
92
 
93
93
  expect(response['project_id']).to eq(project_id)
94
- expect(response['branch_merged']).to eq(true)
94
+ expect(response['branch_merged']).to be(true)
95
95
  expect(response['branch']['branch_id']).to eq(branch_id)
96
96
  expect(response['branch']['name']).to eq(branch.name)
97
97
  end
@@ -111,7 +111,7 @@ RSpec.describe Lokalise::Client do
111
111
  end
112
112
 
113
113
  expect(response['project_id']).to eq(project_id)
114
- expect(response['branch_merged']).to eq(true)
114
+ expect(response['branch_merged']).to be(true)
115
115
  expect(response['branch']['branch_id']).to eq(branch_id)
116
116
  expect(response['branch']['name']).to eq(branch.name)
117
117
  end
@@ -134,7 +134,7 @@ RSpec.describe Lokalise::Client do
134
134
  end
135
135
 
136
136
  expect(response['project_id']).to eq(project_id)
137
- expect(response['branch_deleted']).to eq(true)
137
+ expect(response['branch_deleted']).to be(true)
138
138
  end
139
139
  end
140
140
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Lokalise::Client do
3
+ RSpec.describe RubyLokaliseApi::Client do
4
4
  let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
5
  let(:key_id) { 15_305_182 }
6
6
  let(:another_key_id) { 15_519_786 }
@@ -26,10 +26,10 @@ RSpec.describe Lokalise::Client do
26
26
  expect(comments.current_page).to eq(2)
27
27
  expect(comments.collection.first.comment).to eq('demo comment')
28
28
 
29
- expect(comments.next_page?).to eq(true)
30
- expect(comments.last_page?).to eq(false)
31
- expect(comments.prev_page?).to eq(true)
32
- expect(comments.first_page?).to eq(false)
29
+ expect(comments.next_page?).to be(true)
30
+ expect(comments.last_page?).to be(false)
31
+ expect(comments.prev_page?).to be(true)
32
+ expect(comments.first_page?).to be(false)
33
33
 
34
34
  expect(comments.client).to be_an_instance_of(described_class)
35
35
  end
@@ -96,7 +96,7 @@ RSpec.describe Lokalise::Client do
96
96
  test_client.destroy_comment project_id, key_id, 767_938
97
97
  end
98
98
  expect(response['project_id']).to eq(project_id)
99
- expect(response['comment_deleted']).to eq(true)
99
+ expect(response['comment_deleted']).to be(true)
100
100
  end
101
101
 
102
102
  context 'when comment methods are chained' do
@@ -112,7 +112,7 @@ RSpec.describe Lokalise::Client do
112
112
  end
113
113
 
114
114
  expect(delete_response['project_id']).to eq(project_id)
115
- expect(delete_response['comment_deleted']).to eq(true)
115
+ expect(delete_response['comment_deleted']).to be(true)
116
116
  end
117
117
  end
118
118
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Lokalise::Client do
3
+ RSpec.describe RubyLokaliseApi::Client do
4
4
  let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
5
  let(:contributor_id) { 25_953 }
6
6
 
@@ -25,10 +25,10 @@ RSpec.describe Lokalise::Client do
25
25
  expect(contributors.results_per_page).to eq(1)
26
26
  expect(contributors.current_page).to eq(2)
27
27
 
28
- expect(contributors.next_page?).to eq(false)
29
- expect(contributors.last_page?).to eq(true)
30
- expect(contributors.prev_page?).to eq(true)
31
- expect(contributors.first_page?).to eq(false)
28
+ expect(contributors.next_page?).to be(false)
29
+ expect(contributors.last_page?).to be(true)
30
+ expect(contributors.prev_page?).to be(true)
31
+ expect(contributors.first_page?).to be(false)
32
32
  end
33
33
  end
34
34
 
@@ -41,8 +41,8 @@ RSpec.describe Lokalise::Client do
41
41
  expect(contributor.email).to eq('bodrovis@protonmail.com')
42
42
  expect(contributor.fullname).to eq('Ilya B')
43
43
  expect(contributor.created_at).to eq('2018-08-21 15:35:25 (Etc/UTC)')
44
- expect(contributor.is_admin).to eq(true)
45
- expect(contributor.is_reviewer).to eq(true)
44
+ expect(contributor.is_admin).to be(true)
45
+ expect(contributor.is_reviewer).to be(true)
46
46
  expect(contributor.languages.first['lang_id']).to eq(803)
47
47
  expect(contributor.admin_rights.first).to eq('upload')
48
48
  expect(contributor.created_at_timestamp).to eq(1_534_865_725)
@@ -94,7 +94,7 @@ RSpec.describe Lokalise::Client do
94
94
  test_client.destroy_contributor project_id, contributor_id
95
95
  end
96
96
  expect(response['project_id']).to eq(project_id)
97
- expect(response['contributor_deleted']).to eq(true)
97
+ expect(response['contributor_deleted']).to be(true)
98
98
  end
99
99
 
100
100
  context 'when contributor methods are chained' do
@@ -126,7 +126,7 @@ RSpec.describe Lokalise::Client do
126
126
  end
127
127
 
128
128
  expect(delete_response['project_id']).to eq(project_id)
129
- expect(delete_response['contributor_deleted']).to eq(true)
129
+ expect(delete_response['contributor_deleted']).to be(true)
130
130
  end
131
131
  end
132
132
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Lokalise::Client do
3
+ RSpec.describe RubyLokaliseApi::Client do
4
4
  let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
5
  let(:status_id) { 128 }
6
6
  let(:new_status_id) { 126 }
@@ -26,10 +26,10 @@ RSpec.describe Lokalise::Client do
26
26
  expect(statuses.results_per_page).to eq(1)
27
27
  expect(statuses.current_page).to eq(2)
28
28
 
29
- expect(statuses.next_page?).to eq(true)
30
- expect(statuses.last_page?).to eq(false)
31
- expect(statuses.prev_page?).to eq(true)
32
- expect(statuses.first_page?).to eq(false)
29
+ expect(statuses.next_page?).to be(true)
30
+ expect(statuses.last_page?).to be(false)
31
+ expect(statuses.prev_page?).to be(true)
32
+ expect(statuses.first_page?).to be(false)
33
33
  end
34
34
  end
35
35
 
@@ -87,7 +87,7 @@ RSpec.describe Lokalise::Client do
87
87
  end
88
88
 
89
89
  expect(response['project_id']).to eq(project_id)
90
- expect(response['custom_translation_status_deleted']).to eq(true)
90
+ expect(response['custom_translation_status_deleted']).to be(true)
91
91
  end
92
92
 
93
93
  specify '#translation_status_colors' do
@@ -125,7 +125,7 @@ RSpec.describe Lokalise::Client do
125
125
  end
126
126
 
127
127
  expect(response['project_id']).to eq(project_id)
128
- expect(response['custom_translation_status_deleted']).to eq(true)
128
+ expect(response['custom_translation_status_deleted']).to be(true)
129
129
  end
130
130
  end
131
131
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Lokalise::Client do
3
+ RSpec.describe RubyLokaliseApi::Client do
4
4
  let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
5
 
6
6
  describe '#files' do
@@ -51,7 +51,7 @@ RSpec.describe Lokalise::Client do
51
51
  lang_iso: 'ru'
52
52
  end
53
53
 
54
- expect(process).to be_an_instance_of(Lokalise::Resources::QueuedProcess)
54
+ expect(process).to be_an_instance_of(RubyLokaliseApi::Resources::QueuedProcess)
55
55
  expect(process.process_id).to eq('85c42bf5eff44648ca2f01f9db67b7d306a2f282')
56
56
  expect(process.status).to eq('queued')
57
57
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Lokalise::Client do
3
+ RSpec.describe RubyLokaliseApi::Client do
4
4
  let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
5
  let(:key_id) { 15_305_182 }
6
6
  let(:new_key_id) { 15_519_770 }
@@ -25,10 +25,10 @@ RSpec.describe Lokalise::Client do
25
25
  expect(keys.results_per_page).to eq(2)
26
26
  expect(keys.current_page).to eq(3)
27
27
 
28
- expect(keys.next_page?).to eq(true)
29
- expect(keys.last_page?).to eq(false)
30
- expect(keys.prev_page?).to eq(true)
31
- expect(keys.first_page?).to eq(false)
28
+ expect(keys.next_page?).to be(true)
29
+ expect(keys.last_page?).to be(false)
30
+ expect(keys.prev_page?).to be(true)
31
+ expect(keys.first_page?).to be(false)
32
32
  end
33
33
  end
34
34
 
@@ -50,10 +50,10 @@ RSpec.describe Lokalise::Client do
50
50
  expect(key.comments).to eq([])
51
51
  expect(key.screenshots).to eq([])
52
52
  expect(key.translations.first['modified_by_email']).to eq('bodrovis@protonmail.com')
53
- expect(key.is_plural).to eq(false)
53
+ expect(key.is_plural).to be(false)
54
54
  expect(key.plural_name).to eq('')
55
- expect(key.is_hidden).to eq(true)
56
- expect(key.is_archived).to eq(false)
55
+ expect(key.is_hidden).to be(true)
56
+ expect(key.is_archived).to be(false)
57
57
  expect(key.context).to eq('')
58
58
  expect(key.base_words).to eq(1)
59
59
  expect(key.char_limit).to eq(0)
@@ -113,8 +113,8 @@ RSpec.describe Lokalise::Client do
113
113
  end
114
114
 
115
115
  # `update_keys` returns a collection but it should not be paginated
116
- expect(keys.next_page?).to eq(false)
117
- expect(keys.prev_page?).to eq(false)
116
+ expect(keys.next_page?).to be(false)
117
+ expect(keys.prev_page?).to be(false)
118
118
 
119
119
  first_key = keys.collection.first
120
120
  second_key = keys.collection[1]
@@ -134,7 +134,7 @@ RSpec.describe Lokalise::Client do
134
134
  end
135
135
 
136
136
  expect(response['project_id']).to eq(project_id)
137
- expect(response['key_removed']).to eq(true)
137
+ expect(response['key_removed']).to be(true)
138
138
  end
139
139
 
140
140
  specify '#destroy_keys' do
@@ -143,7 +143,7 @@ RSpec.describe Lokalise::Client do
143
143
  end
144
144
 
145
145
  expect(response['project_id']).to eq(project_id)
146
- expect(response['keys_removed']).to eq(true)
146
+ expect(response['keys_removed']).to be(true)
147
147
  end
148
148
 
149
149
  context 'when key methods are chained' do
@@ -169,7 +169,7 @@ RSpec.describe Lokalise::Client do
169
169
  end
170
170
 
171
171
  expect(delete_response['project_id']).to eq(project_id)
172
- expect(delete_response['key_removed']).to eq(true)
172
+ expect(delete_response['key_removed']).to be(true)
173
173
  end
174
174
  end
175
175
 
@@ -193,7 +193,7 @@ RSpec.describe Lokalise::Client do
193
193
  end
194
194
 
195
195
  expect(delete_response['project_id']).to eq(project_id)
196
- expect(delete_response['keys_removed']).to eq(true)
196
+ expect(delete_response['keys_removed']).to be(true)
197
197
  end
198
198
  end
199
199
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Lokalise::Client do
3
+ RSpec.describe RubyLokaliseApi::Client do
4
4
  let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
5
  let(:language_id) { 640 }
6
6
  let(:new_language_id) { 894 }
@@ -59,7 +59,7 @@ RSpec.describe Lokalise::Client do
59
59
  expect(language.lang_id).to eq(language_id)
60
60
  expect(language.lang_iso).to eq('en')
61
61
  expect(language.lang_name).to eq('English')
62
- expect(language.is_rtl).to eq(false)
62
+ expect(language.is_rtl).to be(false)
63
63
  expect(language.plural_forms).to eq(%w[one other])
64
64
  end
65
65
 
@@ -100,7 +100,7 @@ RSpec.describe Lokalise::Client do
100
100
  test_client.destroy_language project_id, new_language_id
101
101
  end
102
102
  expect(response['project_id']).to eq(project_id)
103
- expect(response['language_deleted']).to eq(true)
103
+ expect(response['language_deleted']).to be(true)
104
104
  end
105
105
 
106
106
  context 'when project language methods are chained' do
@@ -128,7 +128,7 @@ RSpec.describe Lokalise::Client do
128
128
  end
129
129
 
130
130
  expect(delete_response['project_id']).to eq(project_id)
131
- expect(delete_response['language_deleted']).to eq(true)
131
+ expect(delete_response['language_deleted']).to be(true)
132
132
  end
133
133
  end
134
134
  end