crowdin-api 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +96 -31
  3. data/README.md +8 -6
  4. data/bin/crowdin-console +1 -1
  5. data/crowdin-api.gemspec +1 -2
  6. data/lib/crowdin-api/{api-resources → api_resources}/dictionaries.rb +8 -10
  7. data/lib/crowdin-api/{api-resources → api_resources}/distributions.rb +25 -32
  8. data/lib/crowdin-api/{api-resources → api_resources}/glossaries.rb +64 -82
  9. data/lib/crowdin-api/{api-resources → api_resources}/labels.rb +28 -47
  10. data/lib/crowdin-api/api_resources/languages.rb +61 -0
  11. data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
  12. data/lib/crowdin-api/api_resources/projects.rb +124 -0
  13. data/lib/crowdin-api/api_resources/reports.rb +120 -0
  14. data/lib/crowdin-api/{api-resources → api_resources}/screenshots.rb +47 -61
  15. data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -131
  16. data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
  17. data/lib/crowdin-api/api_resources/storages.rb +54 -0
  18. data/lib/crowdin-api/{api-resources → api_resources}/string_comments.rb +18 -23
  19. data/lib/crowdin-api/{api-resources → api_resources}/string_translations.rb +63 -90
  20. data/lib/crowdin-api/{api-resources → api_resources}/tasks.rb +30 -41
  21. data/lib/crowdin-api/api_resources/teams.rb +135 -0
  22. data/lib/crowdin-api/{api-resources → api_resources}/translation_memory.rb +38 -52
  23. data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
  24. data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +40 -58
  25. data/lib/crowdin-api/api_resources/users.rb +161 -0
  26. data/lib/crowdin-api/api_resources/vendors.rb +21 -0
  27. data/lib/crowdin-api/{api-resources → api_resources}/webhooks.rb +19 -24
  28. data/lib/crowdin-api/api_resources/workflows.rb +59 -0
  29. data/lib/crowdin-api/client/client.rb +51 -42
  30. data/lib/crowdin-api/client/configuration.rb +12 -12
  31. data/lib/crowdin-api/client/version.rb +1 -1
  32. data/lib/crowdin-api/core/errors_raisers.rb +1 -1
  33. data/lib/crowdin-api/core/request.rb +53 -88
  34. data/lib/crowdin-api/core/send_request.rb +67 -0
  35. data/lib/crowdin-api.rb +17 -24
  36. data/spec/api_resources/dictionaries_spec.rb +23 -0
  37. data/spec/api_resources/distributions_spec.rb +71 -0
  38. data/spec/api_resources/glossaries_spec.rb +167 -0
  39. data/spec/api_resources/labels_spec.rb +71 -0
  40. data/spec/api_resources/languages_spec.rb +51 -0
  41. data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
  42. data/spec/api_resources/projects_spec.rb +215 -0
  43. data/spec/api_resources/reports_spec.rb +95 -0
  44. data/spec/api_resources/screenshots_spec.rb +134 -0
  45. data/spec/api_resources/source_files_spec.rb +13 -0
  46. data/spec/api_resources/source_strings_spec.rb +51 -0
  47. data/spec/api_resources/storages_spec.rb +13 -0
  48. data/spec/api_resources/string_comments_spec.rb +13 -0
  49. data/spec/api_resources/string_translations_spec.rb +13 -0
  50. data/spec/api_resources/tasks_spec.rb +79 -0
  51. data/spec/api_resources/teams_spec.rb +13 -0
  52. data/spec/api_resources/translation_memory_spec.rb +13 -0
  53. data/spec/api_resources/translation_status_spec.rb +15 -0
  54. data/spec/api_resources/translations_spec.rb +107 -0
  55. data/spec/api_resources/users_spec.rb +117 -0
  56. data/spec/api_resources/vendors_spec.rb +13 -0
  57. data/spec/api_resources/webhooks_spec.rb +51 -0
  58. data/spec/api_resources/workflows_spec.rb +41 -0
  59. data/spec/spec_helper.rb +20 -2
  60. data/spec/unit/client_spec.rb +85 -0
  61. metadata +64 -43
  62. data/bin/setup +0 -6
  63. data/lib/crowdin-api/api-resources/languages.rb +0 -82
  64. data/lib/crowdin-api/api-resources/machine_translation_engines.rb +0 -74
  65. data/lib/crowdin-api/api-resources/projects.rb +0 -148
  66. data/lib/crowdin-api/api-resources/reports.rb +0 -138
  67. data/lib/crowdin-api/api-resources/storages.rb +0 -106
  68. data/lib/crowdin-api/api-resources/teams.rb +0 -144
  69. data/lib/crowdin-api/api-resources/users.rb +0 -129
  70. data/lib/crowdin-api/api-resources/vendors.rb +0 -21
  71. data/lib/crowdin-api/api-resources/workflows.rb +0 -62
  72. data/lib/crowdin-api/core/utils.rb +0 -10
  73. data/spec/client/client-instance_spec.rb +0 -14
  74. data/spec/client/configuration-instance_spec.rb +0 -72
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module ApiResources
5
- # -- For Enterprise mode only --
6
- module Workflows
7
- def list_workflow_steps(query = {}, project_id = config.project_id)
8
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
9
- project_id || raise_project_id_is_required_error
10
-
11
- request = Web::Request.new(
12
- self,
13
- :get,
14
- "/projects/#{project_id}/workflow-steps",
15
- query
16
- )
17
-
18
- request.perform
19
- end
20
-
21
- def get_workflow_step(step_id = nil, project_id = config.project_id)
22
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
23
- step_id || raise_parameter_is_required_error(:step_id)
24
- project_id || raise_project_id_is_required_error
25
-
26
- request = Web::Request.new(
27
- self,
28
- :get,
29
- "/projects/#{project_id}/workflow-steps/#{step_id}"
30
- )
31
-
32
- request.perform
33
- end
34
-
35
- def list_workflow_templates(query = {})
36
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
37
-
38
- request = Web::Request.new(
39
- self,
40
- :get,
41
- '/workflow-templates',
42
- query
43
- )
44
-
45
- request.perform
46
- end
47
-
48
- def get_workflow_template(template_id = nil)
49
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
50
- template_id || raise_parameter_is_required_error(:template_id)
51
-
52
- request = Web::Request.new(
53
- self,
54
- :get,
55
- "/workflow-templates/#{template_id}"
56
- )
57
-
58
- request.perform
59
- end
60
- end
61
- end
62
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module Utils
5
- # Method for extract module namespaces from a string
6
- def fetch_module_full_name_from_string(string)
7
- string.split('::').inject(Module) { |acc, val| acc.const_get(val) }
8
- end
9
- end
10
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Config instance' do
4
- before do
5
- @crowdin = Crowdin::Client.new do |config|
6
- config.api_token = 'api_token'
7
- config.project_id = 1
8
- end
9
- end
10
-
11
- it 'should have a version' do
12
- expect(Crowdin::Client::VERSION).to_not be_nil
13
- end
14
- end
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Config instance' do
4
- before do
5
- @crowdin = Crowdin::Client.new do |config|
6
- config.api_token = 'api_token'
7
- config.project_id = 1
8
- end
9
- end
10
-
11
- it 'should have a #project_id' do
12
- expect(@crowdin.config.project_id).to_not be_nil
13
- end
14
-
15
- it 'should have a #api_token' do
16
- expect(@crowdin.config.api_token).to_not be_nil
17
- end
18
-
19
- it '#target_api_url should equal \'api/v2\' by default' do
20
- expect(@crowdin.config.target_api_url).to eq('/api/v2')
21
- end
22
-
23
- describe '#logger_enabled?' do
24
- it 'should equal false by default' do
25
- expect(@crowdin.config.logger_enabled?).to be_falsey
26
- end
27
-
28
- it 'should equal specified argument' do
29
- @crowdin = Crowdin::Client.new do |config|
30
- config.enable_logger = true
31
- end
32
-
33
- expect(@crowdin.config.logger_enabled?).to be_truthy
34
- end
35
- end
36
-
37
- describe '#enterprise_mode?' do
38
- it 'should equal false by default' do
39
- expect(@crowdin.config.enterprise_mode?).to be_falsey
40
- end
41
-
42
- it 'should equal true if user specify organization domain' do
43
- @crowdin = Crowdin::Client.new do |config|
44
- config.organization_domain = 'organization_domain'
45
- end
46
-
47
- expect(@crowdin.config.enterprise_mode?).to be_truthy
48
- end
49
- end
50
-
51
- describe '#base_url' do
52
- it 'should equal \'https://api.crowdin.com\' by default' do
53
- expect(@crowdin.config.base_url).to eq('https://api.crowdin.com')
54
- end
55
-
56
- it 'should equal specified organization domain' do
57
- @crowdin = Crowdin::Client.new do |config|
58
- config.organization_domain = 'organization_domain'
59
- end
60
-
61
- expect(@crowdin.config.base_url).to eq('https://organization_domain.api.crowdin.com')
62
- end
63
-
64
- it 'should equal full specified organization domain when user specify full url (with \'.com\')' do
65
- @crowdin = Crowdin::Client.new do |config|
66
- config.organization_domain = 'organization_domain.com'
67
- end
68
-
69
- expect(@crowdin.config.base_url).to eq('organization_domain.com')
70
- end
71
- end
72
- end