ruby-lokalise-api 7.2.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ruby_lokalise_api/base_client.rb +2 -34
  3. data/lib/ruby_lokalise_api/client.rb +2 -31
  4. data/lib/ruby_lokalise_api/collections/base.rb +97 -70
  5. data/lib/ruby_lokalise_api/collections/branches.rb +11 -0
  6. data/lib/ruby_lokalise_api/collections/contributors.rb +10 -0
  7. data/lib/ruby_lokalise_api/collections/custom_translation_statuses.rb +10 -0
  8. data/lib/ruby_lokalise_api/collections/files.rb +10 -0
  9. data/lib/ruby_lokalise_api/collections/key_comments.rb +11 -0
  10. data/lib/ruby_lokalise_api/collections/keys.rb +10 -0
  11. data/lib/ruby_lokalise_api/collections/orders.rb +10 -0
  12. data/lib/ruby_lokalise_api/collections/payment_cards.rb +10 -0
  13. data/lib/ruby_lokalise_api/collections/project_comments.rb +12 -0
  14. data/lib/ruby_lokalise_api/collections/project_languages.rb +11 -0
  15. data/lib/ruby_lokalise_api/collections/projects.rb +10 -0
  16. data/lib/ruby_lokalise_api/collections/queued_processes.rb +11 -0
  17. data/lib/ruby_lokalise_api/collections/screenshots.rb +10 -0
  18. data/lib/ruby_lokalise_api/collections/segments.rb +10 -0
  19. data/lib/ruby_lokalise_api/collections/snapshots.rb +10 -0
  20. data/lib/ruby_lokalise_api/collections/system_languages.rb +11 -0
  21. data/lib/ruby_lokalise_api/collections/tasks.rb +10 -0
  22. data/lib/ruby_lokalise_api/collections/team_user_groups.rb +11 -0
  23. data/lib/ruby_lokalise_api/collections/team_users.rb +10 -0
  24. data/lib/ruby_lokalise_api/collections/teams.rb +10 -0
  25. data/lib/ruby_lokalise_api/collections/translation_providers.rb +10 -0
  26. data/lib/ruby_lokalise_api/collections/translations.rb +10 -0
  27. data/lib/ruby_lokalise_api/collections/webhooks.rb +10 -0
  28. data/lib/ruby_lokalise_api/concerns/attrs_loadable.rb +32 -0
  29. data/lib/ruby_lokalise_api/concerns/hash_accessible.rb +16 -0
  30. data/lib/ruby_lokalise_api/concerns/unsupportable.rb +16 -0
  31. data/lib/ruby_lokalise_api/connection.rb +17 -9
  32. data/lib/ruby_lokalise_api/data/collection_attributes.yml +52 -0
  33. data/lib/ruby_lokalise_api/data/{attributes.yml → resource_attributes.yml} +64 -6
  34. data/lib/ruby_lokalise_api/endpoints/base_endpoint.rb +66 -0
  35. data/lib/ruby_lokalise_api/endpoints/branches_endpoint.rb +16 -0
  36. data/lib/ruby_lokalise_api/endpoints/contributors_endpoint.rb +16 -0
  37. data/lib/ruby_lokalise_api/endpoints/custom_translation_statuses_endpoint.rb +16 -0
  38. data/lib/ruby_lokalise_api/endpoints/files_endpoint.rb +16 -0
  39. data/lib/ruby_lokalise_api/endpoints/jwts_endpoint.rb +15 -0
  40. data/lib/ruby_lokalise_api/endpoints/key_comments_endpoint.rb +17 -0
  41. data/lib/ruby_lokalise_api/endpoints/keys_endpoint.rb +16 -0
  42. data/lib/ruby_lokalise_api/endpoints/main_endpoint.rb +25 -0
  43. data/lib/ruby_lokalise_api/endpoints/oauth2/oauth2_endpoint.rb +33 -0
  44. data/lib/ruby_lokalise_api/endpoints/orders_endpoint.rb +16 -0
  45. data/lib/ruby_lokalise_api/endpoints/payment_cards_endpoint.rb +15 -0
  46. data/lib/ruby_lokalise_api/endpoints/project_comments_endpoint.rb +15 -0
  47. data/lib/ruby_lokalise_api/endpoints/project_languages_endpoint.rb +16 -0
  48. data/lib/ruby_lokalise_api/endpoints/projects_endpoint.rb +15 -0
  49. data/lib/ruby_lokalise_api/endpoints/queued_processes_endpoint.rb +16 -0
  50. data/lib/ruby_lokalise_api/endpoints/screenshots_endpoint.rb +16 -0
  51. data/lib/ruby_lokalise_api/endpoints/segments_endpoint.rb +17 -0
  52. data/lib/ruby_lokalise_api/endpoints/snapshots_endpoint.rb +16 -0
  53. data/lib/ruby_lokalise_api/endpoints/system_languages_endpoint.rb +15 -0
  54. data/lib/ruby_lokalise_api/endpoints/tasks_endpoint.rb +16 -0
  55. data/lib/ruby_lokalise_api/endpoints/team_user_billing_details_endpoint.rb +15 -0
  56. data/lib/ruby_lokalise_api/endpoints/team_user_groups_endpoint.rb +16 -0
  57. data/lib/ruby_lokalise_api/endpoints/team_users_endpoint.rb +16 -0
  58. data/lib/ruby_lokalise_api/endpoints/teams_endpoint.rb +13 -0
  59. data/lib/ruby_lokalise_api/endpoints/translation_providers_endpoint.rb +16 -0
  60. data/lib/ruby_lokalise_api/endpoints/translations_endpoint.rb +16 -0
  61. data/lib/ruby_lokalise_api/endpoints/webhooks_endpoint.rb +16 -0
  62. data/lib/ruby_lokalise_api/error.rb +1 -0
  63. data/lib/ruby_lokalise_api/generics.rb +25 -0
  64. data/lib/ruby_lokalise_api/json_handler.rb +1 -2
  65. data/lib/ruby_lokalise_api/oauth2/auth.rb +48 -39
  66. data/lib/ruby_lokalise_api/oauth2_client.rb +3 -0
  67. data/lib/ruby_lokalise_api/request.rb +66 -18
  68. data/lib/ruby_lokalise_api/resources/base.rb +41 -185
  69. data/lib/ruby_lokalise_api/resources/branch.rb +2 -21
  70. data/lib/ruby_lokalise_api/resources/comment.rb +11 -0
  71. data/lib/ruby_lokalise_api/resources/contributor.rb +1 -9
  72. data/lib/ruby_lokalise_api/resources/custom_translation_status.rb +1 -13
  73. data/lib/ruby_lokalise_api/resources/file.rb +2 -16
  74. data/lib/ruby_lokalise_api/resources/jwt.rb +2 -5
  75. data/lib/ruby_lokalise_api/resources/key.rb +5 -8
  76. data/lib/ruby_lokalise_api/resources/oauth2_refreshed_token.rb +9 -0
  77. data/lib/ruby_lokalise_api/resources/oauth2_token.rb +9 -0
  78. data/lib/ruby_lokalise_api/resources/order.rb +2 -9
  79. data/lib/ruby_lokalise_api/resources/payment_card.rb +2 -8
  80. data/lib/ruby_lokalise_api/resources/project.rb +85 -16
  81. data/lib/ruby_lokalise_api/resources/project_language.rb +2 -10
  82. data/lib/ruby_lokalise_api/resources/queued_process.rb +3 -10
  83. data/lib/ruby_lokalise_api/resources/screenshot.rb +1 -9
  84. data/lib/ruby_lokalise_api/resources/segment.rb +2 -11
  85. data/lib/ruby_lokalise_api/resources/snapshot.rb +3 -18
  86. data/lib/ruby_lokalise_api/resources/system_language.rb +2 -1
  87. data/lib/ruby_lokalise_api/resources/task.rb +1 -9
  88. data/lib/ruby_lokalise_api/resources/team.rb +2 -0
  89. data/lib/ruby_lokalise_api/resources/team_user.rb +1 -9
  90. data/lib/ruby_lokalise_api/resources/team_user_billing_details.rb +10 -5
  91. data/lib/ruby_lokalise_api/resources/team_user_group.rb +6 -14
  92. data/lib/ruby_lokalise_api/resources/translation.rb +2 -9
  93. data/lib/ruby_lokalise_api/resources/translation_provider.rb +2 -9
  94. data/lib/ruby_lokalise_api/resources/webhook.rb +2 -16
  95. data/lib/ruby_lokalise_api/response.rb +50 -0
  96. data/lib/ruby_lokalise_api/rest/branches.rb +52 -27
  97. data/lib/ruby_lokalise_api/rest/comments.rb +48 -23
  98. data/lib/ruby_lokalise_api/rest/contributors.rb +47 -23
  99. data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +60 -36
  100. data/lib/ruby_lokalise_api/rest/files.rb +43 -24
  101. data/lib/ruby_lokalise_api/rest/jwts.rb +21 -0
  102. data/lib/ruby_lokalise_api/rest/keys.rb +67 -34
  103. data/lib/ruby_lokalise_api/rest/languages.rb +57 -28
  104. data/lib/ruby_lokalise_api/rest/orders.rb +36 -14
  105. data/lib/ruby_lokalise_api/rest/payment_cards.rb +29 -12
  106. data/lib/ruby_lokalise_api/rest/projects.rb +55 -32
  107. data/lib/ruby_lokalise_api/rest/queued_processes.rb +21 -13
  108. data/lib/ruby_lokalise_api/rest/screenshots.rb +45 -20
  109. data/lib/ruby_lokalise_api/rest/segments.rb +31 -18
  110. data/lib/ruby_lokalise_api/rest/snapshots.rb +34 -14
  111. data/lib/ruby_lokalise_api/rest/tasks.rb +41 -19
  112. data/lib/ruby_lokalise_api/rest/team_user_billing_details.rb +33 -12
  113. data/lib/ruby_lokalise_api/rest/team_user_groups.rb +82 -50
  114. data/lib/ruby_lokalise_api/rest/team_users.rb +35 -18
  115. data/lib/ruby_lokalise_api/rest/teams.rb +10 -5
  116. data/lib/ruby_lokalise_api/rest/translation_providers.rb +24 -9
  117. data/lib/ruby_lokalise_api/rest/translations.rb +28 -15
  118. data/lib/ruby_lokalise_api/rest/webhooks.rb +54 -30
  119. data/lib/ruby_lokalise_api/rest.rb +31 -0
  120. data/lib/ruby_lokalise_api/utils/attributes.rb +37 -0
  121. data/lib/ruby_lokalise_api/utils/classes.rb +28 -0
  122. data/lib/ruby_lokalise_api/utils/keys.rb +33 -0
  123. data/lib/ruby_lokalise_api/utils/loaders.rb +27 -0
  124. data/lib/ruby_lokalise_api/utils/strings.rb +20 -0
  125. data/lib/ruby_lokalise_api/version.rb +1 -1
  126. data/lib/ruby_lokalise_api.rb +6 -2
  127. data/ruby-lokalise-api.gemspec +3 -3
  128. metadata +76 -47
  129. data/lib/ruby_lokalise_api/base_request.rb +0 -73
  130. data/lib/ruby_lokalise_api/collections/branch.rb +0 -15
  131. data/lib/ruby_lokalise_api/collections/contributor.rb +0 -13
  132. data/lib/ruby_lokalise_api/collections/custom_translation_status.rb +0 -15
  133. data/lib/ruby_lokalise_api/collections/file.rb +0 -13
  134. data/lib/ruby_lokalise_api/collections/key.rb +0 -20
  135. data/lib/ruby_lokalise_api/collections/key_comment.rb +0 -14
  136. data/lib/ruby_lokalise_api/collections/order.rb +0 -13
  137. data/lib/ruby_lokalise_api/collections/payment_card.rb +0 -13
  138. data/lib/ruby_lokalise_api/collections/project.rb +0 -13
  139. data/lib/ruby_lokalise_api/collections/project_comment.rb +0 -13
  140. data/lib/ruby_lokalise_api/collections/project_language.rb +0 -13
  141. data/lib/ruby_lokalise_api/collections/queued_process.rb +0 -15
  142. data/lib/ruby_lokalise_api/collections/screenshot.rb +0 -13
  143. data/lib/ruby_lokalise_api/collections/segment.rb +0 -15
  144. data/lib/ruby_lokalise_api/collections/snapshot.rb +0 -13
  145. data/lib/ruby_lokalise_api/collections/system_language.rb +0 -13
  146. data/lib/ruby_lokalise_api/collections/task.rb +0 -13
  147. data/lib/ruby_lokalise_api/collections/team.rb +0 -13
  148. data/lib/ruby_lokalise_api/collections/team_user.rb +0 -13
  149. data/lib/ruby_lokalise_api/collections/team_user_group.rb +0 -15
  150. data/lib/ruby_lokalise_api/collections/translation.rb +0 -13
  151. data/lib/ruby_lokalise_api/collections/translation_provider.rb +0 -13
  152. data/lib/ruby_lokalise_api/collections/webhook.rb +0 -13
  153. data/lib/ruby_lokalise_api/oauth2/refresh.rb +0 -16
  154. data/lib/ruby_lokalise_api/oauth2/token.rb +0 -16
  155. data/lib/ruby_lokalise_api/resources/key_comment.rb +0 -19
  156. data/lib/ruby_lokalise_api/resources/project_comment.rb +0 -10
  157. data/lib/ruby_lokalise_api/rest/jwt.rb +0 -15
  158. data/lib/ruby_lokalise_api/utils/attribute_helpers.rb +0 -86
  159. data/lib/ruby_lokalise_api/utils/endpoint_helpers.rb +0 -14
  160. data/lib/ruby_lokalise_api/utils/string_utils.rb +0 -33
@@ -3,59 +3,82 @@
3
3
  module RubyLokaliseApi
4
4
  module Rest
5
5
  module Projects
6
- # Returns all projects available to the user authorized with the API token
7
- #
8
- # @see https://developers.lokalise.com/reference/list-all-projects
9
- # @return [RubyLokaliseApi::Collection::Project<RubyLokaliseApi::Resources::Project>]
10
- # @param params [Hash]
11
- def projects(params = {})
12
- c_r RubyLokaliseApi::Collections::Project, :all, nil, params
13
- end
14
-
15
6
  # Returns a single project
16
7
  #
17
8
  # @see https://developers.lokalise.com/reference/retrieve-a-project
18
9
  # @return [RubyLokaliseApi::Resources::Project]
19
- # @param project_id [String, Integer]
10
+ # @param project_id [String]
20
11
  def project(project_id)
21
- c_r RubyLokaliseApi::Resources::Project, :find, project_id
12
+ params = { query: project_id }
13
+
14
+ data = endpoint(name: 'Projects', params: params).do_get
15
+
16
+ resource 'Project', data
17
+ end
18
+
19
+ # Returns a collection of projects
20
+ #
21
+ # @see https://developers.lokalise.com/reference/list-all-projects
22
+ # @return [RubyLokaliseApi::Collections::Projects]
23
+ # @param req_params [Hash]
24
+ def projects(req_params = {})
25
+ name = 'Projects'
26
+ params = { req: req_params }
27
+
28
+ data = endpoint(name: name, params: params).do_get
29
+
30
+ collection name, data
22
31
  end
23
32
 
24
- # Creates project
33
+ # Creates a project
25
34
  #
26
35
  # @see https://developers.lokalise.com/reference/create-a-project
27
36
  # @return [RubyLokaliseApi::Resources::Project]
28
- # @param params [Hash]
29
- def create_project(params)
30
- c_r RubyLokaliseApi::Resources::Project, :create, nil, params
37
+ # @param req_params [Hash]
38
+ def create_project(req_params)
39
+ params = { req: req_params }
40
+
41
+ data = endpoint(name: 'Projects', params: params).do_post
42
+
43
+ resource 'Project', data
31
44
  end
32
45
 
33
- # Updates project
46
+ # Updates a project
34
47
  #
35
48
  # @see https://developers.lokalise.com/reference/update-a-project
36
49
  # @return [RubyLokaliseApi::Resources::Project]
37
- # @param project_id [String, Integer]
38
- # @param params [Hash]
39
- def update_project(project_id, params)
40
- c_r RubyLokaliseApi::Resources::Project, :update, project_id, params
41
- end
50
+ # @param project_id [String]
51
+ # @param req_params [Hash]
52
+ def update_project(project_id, req_params)
53
+ params = { query: project_id, req: req_params }
42
54
 
43
- # Deletes all keys and translations from the project
44
- #
45
- # @see https://developers.lokalise.com/reference/empty-a-project
46
- # @return [Hash]
47
- # @param project_id [String, Integer]
48
- def empty_project(project_id)
49
- c_r RubyLokaliseApi::Resources::Project, :empty, [project_id, 'empty']
55
+ data = endpoint(name: 'Projects', params: params).do_put
56
+
57
+ resource 'Project', data
50
58
  end
51
59
 
52
- # Deletes the project
60
+ # Deletes a project
53
61
  #
54
62
  # @see https://developers.lokalise.com/reference/delete-a-project
55
- # @return [Hash]
56
- # @param project_id [String, Integer]
63
+ # @return [RubyLokaliseApi::Generics::DeletedResource]
64
+ # @param project_id [String]
57
65
  def destroy_project(project_id)
58
- c_r RubyLokaliseApi::Resources::Project, :destroy, project_id
66
+ params = { query: project_id }
67
+
68
+ data = endpoint(name: 'Projects', params: params).do_delete
69
+
70
+ RubyLokaliseApi::Generics::DeletedResource.new data.content
71
+ end
72
+
73
+ # Empties a project by deleting all keys and translations
74
+ #
75
+ # @see https://developers.lokalise.com/reference/empty-a-project
76
+ # @return [RubyLokaliseApi::Generics::EmptiedResource]
77
+ # @param project_id [String]
78
+ def empty_project(project_id)
79
+ data = endpoint(name: 'Projects', params: { query: [project_id, :empty] }).do_put
80
+
81
+ RubyLokaliseApi::Generics::EmptiedResource.new data.content
59
82
  end
60
83
  end
61
84
  end
@@ -3,25 +3,33 @@
3
3
  module RubyLokaliseApi
4
4
  module Rest
5
5
  module QueuedProcesses
6
- # Returns all queued processes for the given project
6
+ # Returns a single queued process
7
7
  #
8
- # @see https://developers.lokalise.com/reference/list-all-processes
9
- # @return [RubyLokaliseApi::Collection::QueuedProcess<RubyLokaliseApi::Resources::QueuedProcess>]
8
+ # @see https://developers.lokalise.com/reference/retrieve-a-process
9
+ # @return [RubyLokaliseApi::Resources::QueuedProcess]
10
10
  # @param project_id [String]
11
- # @param params [Hash]
12
- def queued_processes(project_id, params = {})
13
- c_r RubyLokaliseApi::Collections::QueuedProcess, :all, project_id, params
11
+ # @param process_id [String, Integer]
12
+ def queued_process(project_id, process_id)
13
+ params = { query: [project_id, process_id] }
14
+
15
+ data = endpoint(name: 'QueuedProcesses', params: params).do_get
16
+
17
+ resource 'QueuedProcess', data
14
18
  end
15
19
 
16
- # Returns a queued process for the given project
20
+ # Returns queued processes
17
21
  #
18
- # @see https://developers.lokalise.com/reference/retrieve-a-process
19
- # @return [RubyLokaliseApi::Resources::QueuedProcess]
22
+ # @see https://developers.lokalise.com/reference/list-all-processes
23
+ # @return [RubyLokaliseApi::Collections::QueuedProcesses]
20
24
  # @param project_id [String]
21
- # @param process_id [String]
22
- def queued_process(project_id, process_id)
23
- c_r RubyLokaliseApi::Resources::QueuedProcess, :find,
24
- [project_id, process_id]
25
+ # @param req_params [Hash]
26
+ def queued_processes(project_id, req_params = {})
27
+ name = 'QueuedProcesses'
28
+ params = { query: project_id, req: req_params }
29
+
30
+ data = endpoint(name: name, params: params).do_get
31
+
32
+ collection name, data
25
33
  end
26
34
  end
27
35
  end
@@ -3,55 +3,80 @@
3
3
  module RubyLokaliseApi
4
4
  module Rest
5
5
  module Screenshots
6
- # Returns all screenshots for the given project
6
+ using RubyLokaliseApi::Utils::Classes
7
+
8
+ # Returns project screenshots
7
9
  #
8
10
  # @see https://developers.lokalise.com/reference/list-all-screenshots
9
- # @return [RubyLokaliseApi::Collection::Screenshot<RubyLokaliseApi::Resources::Screenshot>]
11
+ # @return [RubyLokaliseApi::Collections::Screenshots]
10
12
  # @param project_id [String]
11
- # @param params [Hash]
12
- def screenshots(project_id, params = {})
13
- c_r RubyLokaliseApi::Collections::Screenshot, :all, project_id, params
13
+ # @param req_params [Hash]
14
+ def screenshots(project_id, req_params = {})
15
+ name = 'Screenshots'
16
+ params = { query: project_id, req: req_params }
17
+
18
+ data = endpoint(name: name, params: params).do_get
19
+
20
+ collection name, data
14
21
  end
15
22
 
16
- # Returns a single screenshot for the given project
23
+ # Returns a single screenshot
17
24
  #
18
25
  # @see https://developers.lokalise.com/reference/retrieve-a-screenshot
19
26
  # @return [RubyLokaliseApi::Resources::Screenshot]
20
27
  # @param project_id [String]
21
28
  # @param screenshot_id [String, Integer]
22
- def screenshot(project_id, screenshot_id)
23
- c_r RubyLokaliseApi::Resources::Screenshot, :find, [project_id, screenshot_id]
29
+ # @param req_params[Hash]
30
+ def screenshot(project_id, screenshot_id, req_params = {})
31
+ params = { query: [project_id, screenshot_id], req: req_params }
32
+
33
+ data = endpoint(name: 'Screenshots', params: params).do_get
34
+
35
+ resource 'Screenshot', data
24
36
  end
25
37
 
26
- # Creates one or more screenshots for the given project
38
+ # Creates a new order
27
39
  #
28
40
  # @see https://developers.lokalise.com/reference/create-screenshots
29
- # @return [RubyLokaliseApi::Collection::Screenshot<RubyLokaliseApi::Resources::Screenshot>]
41
+ # @return [RubyLokaliseApi::Collections::Screenshots]
30
42
  # @param project_id [String]
31
- # @param params [Hash]
32
- def create_screenshots(project_id, params = {})
33
- c_r RubyLokaliseApi::Resources::Screenshot, :create, project_id, params, :screenshots
43
+ # @param req_params [Hash, Array]
44
+ def create_screenshots(project_id, req_params)
45
+ name = 'Screenshots'
46
+ params = { query: project_id, req: req_params.to_array_obj(:screenshots) }
47
+
48
+ data = endpoint(name: name, params: params).do_post
49
+
50
+ collection name, data
34
51
  end
35
52
 
36
- # Updates screenshot
53
+ # Updates a screenshot
37
54
  #
38
55
  # @see https://developers.lokalise.com/reference/update-a-screenshot
39
56
  # @return [RubyLokaliseApi::Resources::Screenshot]
40
57
  # @param project_id [String]
41
58
  # @param screenshot_id [String, Integer]
42
- # @param params [Hash]
43
- def update_screenshot(project_id, screenshot_id, params = {})
44
- c_r RubyLokaliseApi::Resources::Screenshot, :update, [project_id, screenshot_id], params
59
+ # @param req_params [Hash]
60
+ def update_screenshot(project_id, screenshot_id, req_params = {})
61
+ params = { query: [project_id, screenshot_id], req: req_params }
62
+
63
+ data = endpoint(name: 'Screenshots', params: params).do_put
64
+
65
+ resource 'Screenshot', data
45
66
  end
46
67
 
47
- # Deletes screenshot
68
+ # Deletes a screenshot
48
69
  #
49
70
  # @see https://developers.lokalise.com/reference/delete-a-screenshot
50
- # @return [Hash]
71
+ # @return [RubyLokaliseApi::Generics::DeletedResource]
51
72
  # @param project_id [String]
52
73
  # @param screenshot_id [String, Integer]
53
74
  def destroy_screenshot(project_id, screenshot_id)
54
- c_r RubyLokaliseApi::Resources::Screenshot, :destroy, [project_id, screenshot_id]
75
+ params = { query: [project_id, screenshot_id] }
76
+
77
+ data = endpoint(name: 'Screenshots', params: params).do_delete
78
+
79
+ RubyLokaliseApi::Generics::DeletedResource.new data.content
55
80
  end
56
81
  end
57
82
  end
@@ -3,42 +3,55 @@
3
3
  module RubyLokaliseApi
4
4
  module Rest
5
5
  module Segments
6
- # Returns all segments for the given key and language ISO code
6
+ # Returns project segments
7
7
  #
8
8
  # @see https://developers.lokalise.com/reference/list-all-segments-for-key-language
9
- # @return [RubyLokaliseApi::Collection::Segments<RubyLokaliseApi::Resources::Segment>]
9
+ # @return [RubyLokaliseApi::Collections::Segments]
10
10
  # @param project_id [String]
11
11
  # @param key_id [String, Integer]
12
- # @param lang_iso [String]
13
- # @param params [Hash]
14
- def segments(project_id, key_id, lang_iso, params = {})
15
- c_r RubyLokaliseApi::Collections::Segment, :all, [project_id, key_id, lang_iso], params
12
+ # @param language_iso [String]
13
+ # @param req_params [Hash]
14
+ def segments(project_id, key_id, language_iso, req_params = {})
15
+ name = 'Segments'
16
+ params = { query: [project_id, key_id, language_iso], req: req_params }
17
+
18
+ data = endpoint(name: name, params: params).do_get
19
+
20
+ collection name, data
16
21
  end
17
22
 
18
- # Returns a segment under a given number for the given key and language ISO code
23
+ # Returns a single project segment
19
24
  #
20
25
  # @see https://developers.lokalise.com/reference/retrieve-a-segment-for-key-language
21
26
  # @return [RubyLokaliseApi::Resources::Segment]
22
27
  # @param project_id [String]
23
28
  # @param key_id [String, Integer]
24
- # @param lang_iso [String]
25
- # @params segment_number [Integer, String]
26
- # @param params [Hash]
27
- def segment(project_id, key_id, lang_iso, segment_number, params = {})
28
- c_r RubyLokaliseApi::Resources::Segment, :find, [project_id, key_id, lang_iso, segment_number], params
29
+ # @param language_iso [String]
30
+ # @param segment_number [String, Integer]
31
+ # @param req_params [Hash]
32
+ def segment(project_id, key_id, language_iso, segment_number, req_params = {})
33
+ params = { query: [project_id, key_id, language_iso, segment_number], req: req_params }
34
+
35
+ data = endpoint(name: 'Segments', params: params).do_get
36
+
37
+ resource 'Segment', data
29
38
  end
30
39
 
31
- # Updates a segment under a given number for the given key and language ISO code
40
+ # Updates a segment
32
41
  #
33
42
  # @see https://developers.lokalise.com/reference/update-a-segment
34
43
  # @return [RubyLokaliseApi::Resources::Segment]
35
44
  # @param project_id [String]
36
45
  # @param key_id [String, Integer]
37
- # @param lang_iso [String]
38
- # @params segment_number [Integer, String]
39
- # @param params [Hash]
40
- def update_segment(project_id, key_id, lang_iso, segment_number, params = {})
41
- c_r RubyLokaliseApi::Resources::Segment, :update, [project_id, key_id, lang_iso, segment_number], params
46
+ # @param language_iso [String]
47
+ # @param segment_number [String, Integer]
48
+ # @param req_params [Hash]
49
+ def update_segment(project_id, key_id, language_iso, segment_number, req_params = {})
50
+ params = { query: [project_id, key_id, language_iso, segment_number], req: req_params }
51
+
52
+ data = endpoint(name: 'Segments', params: params).do_put
53
+
54
+ resource 'Segment', data
42
55
  end
43
56
  end
44
57
  end
@@ -3,44 +3,64 @@
3
3
  module RubyLokaliseApi
4
4
  module Rest
5
5
  module Snapshots
6
- # Returns all snapshots for the given project
6
+ # Returns project snapshots
7
7
  #
8
8
  # @see https://developers.lokalise.com/reference/list-all-snapshots
9
- # @return [RubyLokaliseApi::Collection::Snapshot<RubyLokaliseApi::Resources::Snapshot>]
9
+ # @return [RubyLokaliseApi::Collections::Snapshots]
10
10
  # @param project_id [String]
11
- # @param params [Hash]
12
- def snapshots(project_id, params = {})
13
- c_r RubyLokaliseApi::Collections::Snapshot, :all, project_id, params
11
+ # @param req_params [Hash]
12
+ def snapshots(project_id, req_params = {})
13
+ name = 'Snapshots'
14
+ params = { query: project_id, req: req_params }
15
+
16
+ data = endpoint(name: name, params: params).do_get
17
+
18
+ collection name, data
14
19
  end
15
20
 
16
- # Creates snapshot for the given project
21
+ # Creates a snapshot
17
22
  #
18
23
  # @see https://developers.lokalise.com/reference/create-a-snapshot
19
24
  # @return [RubyLokaliseApi::Resources::Snapshot]
20
25
  # @param project_id [String]
21
- # @param params [Hash]
22
- def create_snapshot(project_id, params = {})
23
- c_r RubyLokaliseApi::Resources::Snapshot, :create, project_id, params
26
+ # @param req_params [Hash]
27
+ def create_snapshot(project_id, req_params = {})
28
+ params = { query: project_id, req: req_params }
29
+
30
+ data = endpoint(name: 'Snapshots', params: params).do_post
31
+
32
+ resource 'Snapshot', data
24
33
  end
25
34
 
26
- # Restore project from the given snapshot by producing project's copy
35
+ # Restores a snapshot by creating a project copy
27
36
  #
28
37
  # @see https://developers.lokalise.com/reference/restore-a-snapshot
29
38
  # @return [RubyLokaliseApi::Resources::Project]
30
39
  # @param project_id [String]
31
40
  # @param snapshot_id [String, Integer]
32
41
  def restore_snapshot(project_id, snapshot_id)
33
- c_r RubyLokaliseApi::Resources::Snapshot, :restore, [project_id, snapshot_id]
42
+ params = { query: [project_id, snapshot_id] }
43
+
44
+ response = endpoint(name: 'Snapshots', params: params).do_post
45
+
46
+ # We restore a project so its endpoint is different
47
+ response.patch_endpoint_with endpoint(name: 'Projects', params: { query: [project_id] })
48
+
49
+ resource 'Project', response
34
50
  end
35
51
 
36
- # Deletes snapshot
52
+ # Deletes a snapshot
37
53
  #
38
54
  # @see https://developers.lokalise.com/reference/delete-a-snapshot
39
- # @return [Hash]
55
+ # @return [RubyLokaliseApi::Generics::DeletedResource]
40
56
  # @param project_id [String]
41
57
  # @param snapshot_id [String, Integer]
42
58
  def destroy_snapshot(project_id, snapshot_id)
43
- c_r RubyLokaliseApi::Resources::Snapshot, :destroy, [project_id, snapshot_id]
59
+ params = { query: [project_id, snapshot_id] }
60
+
61
+ data = endpoint(name: 'Snapshots', params: params).do_delete
62
+
63
+ RubyLokaliseApi::Generics::DeletedResource.new data.content
44
64
  end
45
65
  end
46
66
  end
@@ -3,55 +3,77 @@
3
3
  module RubyLokaliseApi
4
4
  module Rest
5
5
  module Tasks
6
- # Returns all tasks for the given project
6
+ # Returns project tasks
7
7
  #
8
8
  # @see https://developers.lokalise.com/reference/list-all-tasks
9
- # @return [RubyLokaliseApi::Collection::Task<RubyLokaliseApi::Resources::Task>]
9
+ # @return [RubyLokaliseApi::Collections::Tasks]
10
10
  # @param project_id [String]
11
- # @param params [Hash]
12
- def tasks(project_id, params = {})
13
- c_r RubyLokaliseApi::Collections::Task, :all, project_id, params
11
+ # @param req_params [Hash]
12
+ def tasks(project_id, req_params = {})
13
+ name = 'Tasks'
14
+ params = { query: project_id, req: req_params }
15
+
16
+ data = endpoint(name: name, params: params).do_get
17
+
18
+ collection name, data
14
19
  end
15
20
 
16
- # Returns a single task for the given project
21
+ # Returns a single task
17
22
  #
18
23
  # @see https://developers.lokalise.com/reference/retrieve-a-task
19
24
  # @return [RubyLokaliseApi::Resources::Task]
20
25
  # @param project_id [String]
21
26
  # @param task_id [String, Integer]
22
- def task(project_id, task_id)
23
- c_r RubyLokaliseApi::Resources::Task, :find, [project_id, task_id]
27
+ # @param req_params[Hash]
28
+ def task(project_id, task_id, req_params = {})
29
+ params = { query: [project_id, task_id], req: req_params }
30
+
31
+ data = endpoint(name: 'Tasks', params: params).do_get
32
+
33
+ resource 'Task', data
24
34
  end
25
35
 
26
- # Creates task for the given project
36
+ # Creates a new task
27
37
  #
28
38
  # @see https://developers.lokalise.com/reference/create-a-task
29
39
  # @return [RubyLokaliseApi::Resources::Task]
30
40
  # @param project_id [String]
31
- # @param params [Hash]
32
- def create_task(project_id, params)
33
- c_r RubyLokaliseApi::Resources::Task, :create, project_id, params
41
+ # @param req_params [Hash, Array]
42
+ def create_task(project_id, req_params)
43
+ params = { query: project_id, req: req_params }
44
+
45
+ data = endpoint(name: 'Tasks', params: params).do_post
46
+
47
+ resource 'Task', data
34
48
  end
35
49
 
36
- # Updates task for the given project
50
+ # Updates a task
37
51
  #
38
52
  # @see https://developers.lokalise.com/reference/update-a-task
39
53
  # @return [RubyLokaliseApi::Resources::Task]
40
54
  # @param project_id [String]
41
55
  # @param task_id [String, Integer]
42
- # @param params [Hash]
43
- def update_task(project_id, task_id, params = {})
44
- c_r RubyLokaliseApi::Resources::Task, :update, [project_id, task_id], params
56
+ # @param req_params [Hash]
57
+ def update_task(project_id, task_id, req_params = {})
58
+ params = { query: [project_id, task_id], req: req_params }
59
+
60
+ data = endpoint(name: 'Tasks', params: params).do_put
61
+
62
+ resource 'Task', data
45
63
  end
46
64
 
47
- # Deletes task for the given project
65
+ # Deletes a task
48
66
  #
49
67
  # @see https://developers.lokalise.com/reference/delete-a-task
50
- # @return [Hash]
68
+ # @return [RubyLokaliseApi::Generics::DeletedResource]
51
69
  # @param project_id [String]
52
70
  # @param task_id [String, Integer]
53
71
  def destroy_task(project_id, task_id)
54
- c_r RubyLokaliseApi::Resources::Task, :destroy, [project_id, task_id]
72
+ params = { query: [project_id, task_id] }
73
+
74
+ data = endpoint(name: 'Tasks', params: params).do_delete
75
+
76
+ RubyLokaliseApi::Generics::DeletedResource.new data.content
55
77
  end
56
78
  end
57
79
  end
@@ -3,33 +3,54 @@
3
3
  module RubyLokaliseApi
4
4
  module Rest
5
5
  module TeamUserBillingDetails
6
- # Returns team user billing details
6
+ # Returns billing details for a team user
7
7
  #
8
8
  # @see https://developers.lokalise.com/reference/retrieve-team-user-billing-details
9
9
  # @return [RubyLokaliseApi::Resources::TeamUserBillingDetails]
10
- # @param team_id [String]
10
+ # @param team_id [String, Integer]
11
11
  def team_user_billing_details(team_id)
12
- c_r RubyLokaliseApi::Resources::TeamUserBillingDetails, :find, team_id
12
+ params = { query: team_id }
13
+
14
+ response = endpoint(name: 'TeamUserBillingDetails', params: params).do_get
15
+
16
+ # We must patch content because the API does not return team_id and it's mandatory to build resource URLs
17
+ response.patch_content_with 'team_id', team_id
18
+
19
+ resource 'TeamUserBillingDetails', response
13
20
  end
14
21
 
15
22
  # Creates team user billing details
16
23
  #
17
24
  # @see https://developers.lokalise.com/reference/create-team-user-billing-details
18
25
  # @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
26
+ # @param team_id [String, Integer]
27
+ # @param req_params [Hash, Array]
28
+ def create_team_user_billing_details(team_id, req_params)
29
+ params = { query: team_id, req: req_params }
30
+
31
+ response = endpoint(name: 'TeamUserBillingDetails', params: params).do_post
32
+
33
+ # We must patch content because the API does not return team_id and it's mandatory to build resource URL
34
+ response.patch_content_with 'team_id', team_id
35
+
36
+ resource 'TeamUserBillingDetails', response
23
37
  end
24
38
 
25
39
  # Updates team user billing details
26
40
  #
27
- # @see https://developers.lokalise.com/reference/create-team-user-billing-details
41
+ # @see https://developers.lokalise.com/reference/update-team-user-billing-details
28
42
  # @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
43
+ # @param team_id [String, Integer]
44
+ # @param req_params [Hash]
45
+ def update_team_user_billing_details(team_id, req_params = {})
46
+ params = { query: team_id, req: req_params }
47
+
48
+ data = endpoint(name: 'TeamUserBillingDetails', params: params).do_put
49
+
50
+ # We must patch content because the API does not return team_id and it's mandatory to build resource URL
51
+ data.patch_content_with 'team_id', team_id
52
+
53
+ resource 'TeamUserBillingDetails', data
33
54
  end
34
55
  end
35
56
  end