ruby-lokalise-api 5.0.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +7 -5
  4. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/base_request.rb +4 -4
  5. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/client.rb +24 -24
  6. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/base.rb +10 -10
  7. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/branch.rb +1 -1
  8. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/contributor.rb +1 -1
  9. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/custom_translation_status.rb +1 -1
  10. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/file.rb +1 -1
  11. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key.rb +2 -2
  12. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key_comment.rb +1 -1
  13. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/order.rb +1 -1
  14. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/payment_card.rb +1 -1
  15. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project.rb +1 -1
  16. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_comment.rb +1 -1
  17. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_language.rb +1 -1
  18. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/queued_process.rb +1 -1
  19. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/screenshot.rb +1 -1
  20. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/segment.rb +1 -1
  21. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/snapshot.rb +1 -1
  22. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/system_language.rb +1 -1
  23. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/task.rb +1 -1
  24. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team.rb +1 -1
  25. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user.rb +1 -1
  26. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user_group.rb +1 -1
  27. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation.rb +1 -1
  28. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation_provider.rb +1 -1
  29. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/webhook.rb +1 -1
  30. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/connection.rb +2 -2
  31. data/lib/ruby_lokalise_api/data/attributes.yml +235 -0
  32. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/error.rb +14 -14
  33. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/json_handler.rb +1 -1
  34. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/auth.rb +2 -2
  35. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/connection.rb +2 -2
  36. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/request.rb +3 -3
  37. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2_client.rb +1 -1
  38. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/request.rb +3 -3
  39. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/base.rb +16 -8
  40. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/branch.rb +1 -1
  41. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/contributor.rb +1 -1
  42. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/custom_translation_status.rb +1 -1
  43. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/file.rb +2 -2
  44. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key.rb +1 -1
  45. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key_comment.rb +1 -1
  46. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/order.rb +1 -1
  47. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/payment_card.rb +1 -1
  48. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project.rb +1 -1
  49. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_comment.rb +1 -1
  50. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_language.rb +1 -1
  51. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/queued_process.rb +1 -1
  52. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/screenshot.rb +1 -1
  53. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/segment.rb +1 -1
  54. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/snapshot.rb +2 -2
  55. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/system_language.rb +1 -1
  56. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/task.rb +1 -1
  57. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team.rb +1 -1
  58. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user.rb +1 -1
  59. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_billing_details.rb +1 -1
  60. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_group.rb +1 -1
  61. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation.rb +1 -1
  62. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation_provider.rb +1 -1
  63. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/webhook.rb +1 -1
  64. data/lib/ruby_lokalise_api/rest/branches.rb +69 -0
  65. data/lib/ruby_lokalise_api/rest/comments.rb +61 -0
  66. data/lib/ruby_lokalise_api/rest/contributors.rb +58 -0
  67. data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +67 -0
  68. data/lib/ruby_lokalise_api/rest/files.rb +49 -0
  69. data/lib/ruby_lokalise_api/rest/keys.rb +79 -0
  70. data/lib/ruby_lokalise_api/rest/languages.rb +67 -0
  71. data/lib/ruby_lokalise_api/rest/orders.rb +37 -0
  72. data/lib/ruby_lokalise_api/rest/payment_cards.rb +43 -0
  73. data/lib/ruby_lokalise_api/rest/projects.rb +62 -0
  74. data/lib/ruby_lokalise_api/rest/queued_processes.rb +28 -0
  75. data/lib/ruby_lokalise_api/rest/screenshots.rb +58 -0
  76. data/lib/ruby_lokalise_api/rest/segments.rb +45 -0
  77. data/lib/ruby_lokalise_api/rest/snapshots.rb +47 -0
  78. data/lib/ruby_lokalise_api/rest/tasks.rb +58 -0
  79. data/lib/ruby_lokalise_api/rest/team_user_billing_details.rb +36 -0
  80. data/lib/ruby_lokalise_api/rest/team_user_groups.rb +109 -0
  81. data/lib/ruby_lokalise_api/rest/team_users.rb +48 -0
  82. data/lib/ruby_lokalise_api/rest/teams.rb +16 -0
  83. data/lib/ruby_lokalise_api/rest/translation_providers.rb +27 -0
  84. data/lib/ruby_lokalise_api/rest/translations.rb +39 -0
  85. data/lib/ruby_lokalise_api/rest/webhooks.rb +69 -0
  86. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/attribute_helpers.rb +7 -7
  87. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/endpoint_helpers.rb +1 -1
  88. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/string_utils.rb +1 -1
  89. data/lib/ruby_lokalise_api/version.rb +5 -0
  90. data/lib/ruby_lokalise_api.rb +50 -0
  91. data/ruby-lokalise-api.gemspec +8 -7
  92. metadata +125 -157
  93. data/lib/ruby-lokalise-api/data/attributes.json +0 -259
  94. data/lib/ruby-lokalise-api/rest/branches.rb +0 -67
  95. data/lib/ruby-lokalise-api/rest/comments.rb +0 -59
  96. data/lib/ruby-lokalise-api/rest/contributors.rb +0 -56
  97. data/lib/ruby-lokalise-api/rest/custom_translation_statuses.rb +0 -65
  98. data/lib/ruby-lokalise-api/rest/files.rb +0 -36
  99. data/lib/ruby-lokalise-api/rest/keys.rb +0 -77
  100. data/lib/ruby-lokalise-api/rest/languages.rb +0 -65
  101. data/lib/ruby-lokalise-api/rest/orders.rb +0 -35
  102. data/lib/ruby-lokalise-api/rest/payment_cards.rb +0 -41
  103. data/lib/ruby-lokalise-api/rest/projects.rb +0 -60
  104. data/lib/ruby-lokalise-api/rest/queued_processes.rb +0 -26
  105. data/lib/ruby-lokalise-api/rest/screenshots.rb +0 -56
  106. data/lib/ruby-lokalise-api/rest/segments.rb +0 -43
  107. data/lib/ruby-lokalise-api/rest/snapshots.rb +0 -45
  108. data/lib/ruby-lokalise-api/rest/tasks.rb +0 -56
  109. data/lib/ruby-lokalise-api/rest/team_user_billing_details.rb +0 -34
  110. data/lib/ruby-lokalise-api/rest/team_user_group.rb +0 -107
  111. data/lib/ruby-lokalise-api/rest/team_users.rb +0 -46
  112. data/lib/ruby-lokalise-api/rest/teams.rb +0 -14
  113. data/lib/ruby-lokalise-api/rest/translation_providers.rb +0 -25
  114. data/lib/ruby-lokalise-api/rest/translations.rb +0 -37
  115. data/lib/ruby-lokalise-api/rest/webhooks.rb +0 -67
  116. data/lib/ruby-lokalise-api/version.rb +0 -5
  117. data/lib/ruby-lokalise-api.rb +0 -111
  118. data/spec/lib/ruby-lokalise-api/connection_spec.rb +0 -68
  119. data/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb +0 -81
  120. data/spec/lib/ruby-lokalise-api/error_spec.rb +0 -41
  121. data/spec/lib/ruby-lokalise-api/oauth2/auth_spec.rb +0 -73
  122. data/spec/lib/ruby-lokalise-api/rest/branches_spec.rb +0 -140
  123. data/spec/lib/ruby-lokalise-api/rest/comments_spec.rb +0 -118
  124. data/spec/lib/ruby-lokalise-api/rest/contributors_spec.rb +0 -132
  125. data/spec/lib/ruby-lokalise-api/rest/custom_translation_statuses_spec.rb +0 -131
  126. data/spec/lib/ruby-lokalise-api/rest/files_spec.rb +0 -66
  127. data/spec/lib/ruby-lokalise-api/rest/keys_spec.rb +0 -199
  128. data/spec/lib/ruby-lokalise-api/rest/languages_spec.rb +0 -134
  129. data/spec/lib/ruby-lokalise-api/rest/orders_spec.rb +0 -113
  130. data/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb +0 -92
  131. data/spec/lib/ruby-lokalise-api/rest/projects_spec.rb +0 -150
  132. data/spec/lib/ruby-lokalise-api/rest/queued_processes_spec.rb +0 -57
  133. data/spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb +0 -127
  134. data/spec/lib/ruby-lokalise-api/rest/segments_spec.rb +0 -106
  135. data/spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb +0 -117
  136. data/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb +0 -145
  137. data/spec/lib/ruby-lokalise-api/rest/team_user_billing_details_spec.rb +0 -48
  138. data/spec/lib/ruby-lokalise-api/rest/team_user_groups_spec.rb +0 -278
  139. data/spec/lib/ruby-lokalise-api/rest/team_users_spec.rb +0 -95
  140. data/spec/lib/ruby-lokalise-api/rest/teams_spec.rb +0 -25
  141. data/spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb +0 -48
  142. data/spec/lib/ruby-lokalise-api/rest/translations_spec.rb +0 -118
  143. data/spec/lib/ruby-lokalise-api/rest/webhooks_spec.rb +0 -126
  144. data/spec/lib/ruby-lokalise-api_spec.rb +0 -47
  145. data/spec/spec_helper.rb +0 -22
  146. data/spec/support/test_client.rb +0 -15
  147. data/spec/support/vcr.rb +0 -15
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Rest
5
+ module TeamUserBillingDetails
6
+ # Returns team user billing details
7
+ #
8
+ # @see https://developers.lokalise.com/reference/retrieve-team-user-billing-details
9
+ # @return [RubyLokaliseApi::Resources::TeamUserBillingDetails]
10
+ # @param team_id [String]
11
+ def team_user_billing_details(team_id)
12
+ c_r RubyLokaliseApi::Resources::TeamUserBillingDetails, :find, team_id
13
+ end
14
+
15
+ # Creates team user billing details
16
+ #
17
+ # @see https://developers.lokalise.com/reference/create-team-user-billing-details
18
+ # @return [RubyLokaliseApi::Resources::TeamUserBillingDetails]
19
+ # @param team_id [String]
20
+ # @param params [Hash]
21
+ def create_team_user_billing_details(team_id, params)
22
+ c_r RubyLokaliseApi::Resources::TeamUserBillingDetails, :create, team_id, params
23
+ end
24
+
25
+ # Updates team user billing details
26
+ #
27
+ # @see https://developers.lokalise.com/reference/create-team-user-billing-details
28
+ # @return [RubyLokaliseApi::Resources::TeamUserBillingDetails]
29
+ # @param team_id [String]
30
+ # @param params [Hash]
31
+ def update_team_user_billing_details(team_id, params)
32
+ c_r RubyLokaliseApi::Resources::TeamUserBillingDetails, :update, team_id, params
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Rest
5
+ module TeamUserGroups
6
+ # Returns all team user groups for the given team
7
+ #
8
+ # @see https://developers.lokalise.com/reference/list-all-team-users
9
+ # @return [RubyLokaliseApi::Collection::TeamUserGroup<RubyLokaliseApi::Resources::TeamUserGroup>]
10
+ # @param team_id [String]
11
+ # @param params [Hash]
12
+ def team_user_groups(team_id, params = {})
13
+ c_r RubyLokaliseApi::Collections::TeamUserGroup, :all, team_id, params
14
+ end
15
+
16
+ # Returns team user from the given team
17
+ #
18
+ # @see https://developers.lokalise.com/reference/retrieve-a-team-user
19
+ # @return [RubyLokaliseApi::Resources::TeamUserGroup]
20
+ # @param team_id [String]
21
+ # @param group_id [String, Integer]
22
+ def team_user_group(team_id, group_id)
23
+ c_r RubyLokaliseApi::Resources::TeamUserGroup, :find, [team_id, group_id]
24
+ end
25
+
26
+ # Creates team user group
27
+ #
28
+ # @see https://developers.lokalise.com/reference/create-a-group
29
+ # @return [RubyLokaliseApi::Resources::TeamUserGroup]
30
+ # @param params [Hash]
31
+ def create_team_user_group(team_id, params)
32
+ c_r RubyLokaliseApi::Resources::TeamUserGroup, :create, team_id, params
33
+ end
34
+
35
+ # Updates team user group for the given team
36
+ #
37
+ # @see https://developers.lokalise.com/reference/update-a-group
38
+ # @return [RubyLokaliseApi::Resources::TeamUserGroup]
39
+ # @param team_id [String]
40
+ # @param group_id [String, Integer]
41
+ # @param params [Hash]
42
+ def update_team_user_group(team_id, group_id, params)
43
+ c_r RubyLokaliseApi::Resources::TeamUserGroup, :update, [team_id, group_id], params
44
+ end
45
+
46
+ # Deletes team user group from the given team
47
+ #
48
+ # @see https://developers.lokalise.com/reference/delete-a-group
49
+ # @return [RubyLokaliseApi::Resources::TeamUserGroup]
50
+ # @param team_id [String]
51
+ # @param group_id [String, Integer]
52
+ def destroy_team_user_group(team_id, group_id)
53
+ c_r RubyLokaliseApi::Resources::TeamUserGroup, :destroy, [team_id, group_id]
54
+ end
55
+
56
+ # Adds projects to the given group
57
+ #
58
+ # @see https://developers.lokalise.com/reference/add-projects-to-group
59
+ # @return [RubyLokaliseApi::Resources::TeamUserGroup]
60
+ # @param team_id [String]
61
+ # @param group_id [String, Integer]
62
+ # @param project_ids [String, Integer, Array<String>, Array<Integer>]
63
+ def add_projects_to_group(team_id, group_id, project_ids)
64
+ c_r RubyLokaliseApi::Resources::TeamUserGroup, :update,
65
+ [team_id, group_id, 'projects', 'add'],
66
+ project_ids, :projects, [team_id, group_id]
67
+ end
68
+
69
+ # Removes projects from the given group
70
+ #
71
+ # @see https://developers.lokalise.com/reference/remove-projects-from-group
72
+ # @return [RubyLokaliseApi::Resources::TeamUserGroup]
73
+ # @param team_id [String]
74
+ # @param group_id [String, Integer]
75
+ # @param project_ids [String, Integer, Array<String>, Array<Integer>]
76
+ def remove_projects_from_group(team_id, group_id, project_ids)
77
+ c_r RubyLokaliseApi::Resources::TeamUserGroup, :update,
78
+ [team_id, group_id, 'projects', 'remove'],
79
+ project_ids, :projects, [team_id, group_id]
80
+ end
81
+
82
+ # Adds users to the given group
83
+ #
84
+ # @see https://developers.lokalise.com/reference/add-members-to-group
85
+ # @return [RubyLokaliseApi::Resources::TeamUserGroup]
86
+ # @param team_id [String]
87
+ # @param group_id [String, Integer]
88
+ # @param users_ids [String, Integer, Array<String>, Array<Integer>]
89
+ def add_users_to_group(team_id, group_id, users_ids)
90
+ c_r RubyLokaliseApi::Resources::TeamUserGroup, :update,
91
+ [team_id, group_id, 'members', 'add'],
92
+ users_ids, :users, [team_id, group_id]
93
+ end
94
+
95
+ # Removes users from the given group
96
+ #
97
+ # @see https://developers.lokalise.com/reference/remove-members-from-group
98
+ # @return [RubyLokaliseApi::Resources::TeamUserGroup]
99
+ # @param team_id [String]
100
+ # @param group_id [String, Integer]
101
+ # @param users_ids [String, Integer, Array<String>, Array<Integer>]
102
+ def remove_users_from_group(team_id, group_id, users_ids)
103
+ c_r RubyLokaliseApi::Resources::TeamUserGroup, :update,
104
+ [team_id, group_id, 'members', 'remove'],
105
+ users_ids, :users, [team_id, group_id]
106
+ end
107
+ end
108
+ end
109
+ end
@@ -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://developers.lokalise.com/reference/list-all-team-users
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://developers.lokalise.com/reference/retrieve-a-team-user
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://developers.lokalise.com/reference/update-a-team-user
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://developers.lokalise.com/reference/delete-a-team-user
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://developers.lokalise.com/reference/list-all-teams
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://developers.lokalise.com/reference/list-all-providers
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://developers.lokalise.com/reference/retrieve-a-provider
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://developers.lokalise.com/reference/list-all-translations
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://developers.lokalise.com/reference/retrieve-a-translation
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://developers.lokalise.com/reference/update-a-translation
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://developers.lokalise.com/reference/list-all-webhooks
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://developers.lokalise.com/reference/retrieve-a-webhook
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://developers.lokalise.com/reference/create-a-webhook
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://developers.lokalise.com/reference/update-a-webhook
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://developers.lokalise.com/reference/delete-a-webhook
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://developers.lokalise.com/reference/regenerate-a-webhook-secret
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.2.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,31 +1,31 @@
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
8
- spec.authors = ['Ilya Bodrov-Krukowski']
7
+ spec.version = RubyLokaliseApi::VERSION
8
+ spec.authors = ['Ilya Krukowski']
9
9
  spec.email = ['golosizpru@gmail.com']
10
10
  spec.summary = 'Ruby interface to the Lokalise API'
11
11
  spec.description = 'Opinionated Ruby client for the Lokalise platform API allowing to work with translations, projects, users and other resources as with Ruby objects.'
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
- spec.test_files = Dir['spec/**/*.rb']
22
21
  spec.extra_rdoc_files = ['README.md']
23
22
  spec.require_paths = ['lib']
24
23
 
25
24
  spec.add_dependency 'addressable', '~> 2.5'
26
25
  spec.add_dependency 'faraday', '~> 2.0'
27
26
  spec.add_dependency 'faraday-gzip', '~> 0.1'
28
- spec.add_dependency 'json', '>= 1.8.0'
27
+ spec.add_dependency 'json', '~> 2'
28
+ spec.add_dependency 'zeitwerk', '~> 2.4'
29
29
 
30
30
  spec.add_development_dependency 'codecov', '~> 0.1'
31
31
  spec.add_development_dependency 'dotenv', '~> 2.5'
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
38
38
  spec.add_development_dependency 'simplecov', '~> 0.16'
39
39
  spec.add_development_dependency 'vcr', '~> 6.0'
40
+ spec.add_development_dependency 'webmock', '~> 3.14'
40
41
  spec.metadata = {
41
42
  'rubygems_mfa_required' => 'true'
42
43
  }