crowdin-api 1.2.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +102 -43
  3. data/README.md +37 -6
  4. data/bin/crowdin-console +1 -1
  5. data/crowdin-api.gemspec +1 -2
  6. data/lib/crowdin-api/api_resources/bundles.rb +81 -0
  7. data/lib/crowdin-api/{api-resources → api_resources}/dictionaries.rb +8 -10
  8. data/lib/crowdin-api/{api-resources → api_resources}/distributions.rb +25 -32
  9. data/lib/crowdin-api/{api-resources → api_resources}/glossaries.rb +64 -82
  10. data/lib/crowdin-api/{api-resources → api_resources}/labels.rb +28 -47
  11. data/lib/crowdin-api/api_resources/languages.rb +61 -0
  12. data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
  13. data/lib/crowdin-api/api_resources/projects.rb +124 -0
  14. data/lib/crowdin-api/api_resources/reports.rb +120 -0
  15. data/lib/crowdin-api/{api-resources → api_resources}/screenshots.rb +47 -61
  16. data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -131
  17. data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
  18. data/lib/crowdin-api/api_resources/storages.rb +54 -0
  19. data/lib/crowdin-api/{api-resources → api_resources}/string_comments.rb +18 -23
  20. data/lib/crowdin-api/{api-resources → api_resources}/string_translations.rb +64 -91
  21. data/lib/crowdin-api/{api-resources → api_resources}/tasks.rb +30 -41
  22. data/lib/crowdin-api/api_resources/teams.rb +135 -0
  23. data/lib/crowdin-api/{api-resources → api_resources}/translation_memory.rb +38 -52
  24. data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
  25. data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -58
  26. data/lib/crowdin-api/api_resources/users.rb +161 -0
  27. data/lib/crowdin-api/api_resources/vendors.rb +21 -0
  28. data/lib/crowdin-api/{api-resources → api_resources}/webhooks.rb +19 -24
  29. data/lib/crowdin-api/api_resources/workflows.rb +59 -0
  30. data/lib/crowdin-api/client/client.rb +134 -39
  31. data/lib/crowdin-api/client/configuration.rb +12 -12
  32. data/lib/crowdin-api/client/version.rb +1 -1
  33. data/lib/crowdin-api/core/errors.rb +1 -0
  34. data/lib/crowdin-api/core/errors_raisers.rb +1 -1
  35. data/lib/crowdin-api/core/fetch_all_extensions.rb +14 -0
  36. data/lib/crowdin-api/core/request.rb +50 -90
  37. data/lib/crowdin-api/core/send_request.rb +67 -0
  38. data/lib/crowdin-api.rb +18 -24
  39. data/spec/api_resources/bundles_spec.rb +61 -0
  40. data/spec/api_resources/dictionaries_spec.rb +23 -0
  41. data/spec/api_resources/distributions_spec.rb +71 -0
  42. data/spec/api_resources/glossaries_spec.rb +167 -0
  43. data/spec/api_resources/labels_spec.rb +71 -0
  44. data/spec/api_resources/languages_spec.rb +51 -0
  45. data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
  46. data/spec/api_resources/projects_spec.rb +215 -0
  47. data/spec/api_resources/reports_spec.rb +95 -0
  48. data/spec/api_resources/screenshots_spec.rb +134 -0
  49. data/spec/api_resources/source_files_spec.rb +184 -0
  50. data/spec/api_resources/source_strings_spec.rb +51 -0
  51. data/spec/api_resources/storages_spec.rb +41 -0
  52. data/spec/api_resources/string_comments_spec.rb +51 -0
  53. data/spec/api_resources/string_translations_spec.rb +141 -0
  54. data/spec/api_resources/tasks_spec.rb +79 -0
  55. data/spec/api_resources/teams_spec.rb +100 -0
  56. data/spec/api_resources/translation_memory_spec.rb +114 -0
  57. data/spec/api_resources/translation_status_spec.rb +61 -0
  58. data/spec/api_resources/translations_spec.rb +107 -0
  59. data/spec/api_resources/users_spec.rb +117 -0
  60. data/spec/api_resources/vendors_spec.rb +13 -0
  61. data/spec/api_resources/webhooks_spec.rb +51 -0
  62. data/spec/api_resources/workflows_spec.rb +41 -0
  63. data/spec/spec_helper.rb +23 -2
  64. data/spec/unit/client_spec.rb +85 -0
  65. metadata +67 -43
  66. data/bin/setup +0 -6
  67. data/lib/crowdin-api/api-resources/languages.rb +0 -82
  68. data/lib/crowdin-api/api-resources/machine_translation_engines.rb +0 -74
  69. data/lib/crowdin-api/api-resources/projects.rb +0 -148
  70. data/lib/crowdin-api/api-resources/reports.rb +0 -138
  71. data/lib/crowdin-api/api-resources/storages.rb +0 -106
  72. data/lib/crowdin-api/api-resources/teams.rb +0 -144
  73. data/lib/crowdin-api/api-resources/users.rb +0 -129
  74. data/lib/crowdin-api/api-resources/vendors.rb +0 -21
  75. data/lib/crowdin-api/api-resources/workflows.rb +0 -62
  76. data/lib/crowdin-api/core/utils.rb +0 -10
  77. data/spec/client/client-instance_spec.rb +0 -14
  78. data/spec/client/configuration-instance_spec.rb +0 -72
@@ -1,82 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module ApiResources
5
- module Languages
6
- def list_languages(query = {})
7
- request = Web::Request.new(
8
- self,
9
- :get,
10
- '/languages',
11
- query
12
- )
13
-
14
- request.perform
15
- end
16
-
17
- #
18
- # Add custom language.
19
- #
20
- # === Parameters
21
- #
22
- # * +:name+ [String] - Language name
23
- # * +:code+ [String] - Custom language code
24
- # * +:localeCode+ [String] - Custom language locale code
25
- # * +:textDirection+ [String ltr/rtl] - Text direction in custom language
26
- # * +:pluralCategoryNames+ [String] - Array with category names
27
- # * +:threeLettersCode+ [String] - Custom language 3 letters code. Format: ISO 6393 code
28
- #
29
- # === Example
30
- #
31
- # crowdin.add_custom_language(name: 'your_name', code: 'your_code' ..)
32
- #
33
- def add_custom_language(query = {})
34
- request = Web::Request.new(
35
- self,
36
- :post,
37
- '/languages',
38
- query
39
- )
40
-
41
- request.perform
42
- end
43
-
44
- def get_language(language_id = nil)
45
- language_id || raise_parameter_is_required_error(:language_id)
46
-
47
- request = Web::Request.new(
48
- self,
49
- :get,
50
- "/languages/#{language_id}"
51
- )
52
-
53
- request.perform
54
- end
55
-
56
- def delete_custom_language(language_id = nil)
57
- language_id || raise_parameter_is_required_error(:language_id)
58
-
59
- request = Web::Request.new(
60
- self,
61
- :delete,
62
- "/languages/#{language_id}"
63
- )
64
-
65
- request.perform
66
- end
67
-
68
- def edit_custom_language(language_id = nil)
69
- language_id || raise_parameter_is_required_error(:language_id)
70
-
71
- request = Web::Request.new(
72
- self,
73
- :patch,
74
- "/languages/#{language_id}",
75
- query
76
- )
77
-
78
- request.perform
79
- end
80
- end
81
- end
82
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module ApiResources
5
- # -- For Enterprise mode only --
6
- module MachineTranslationEngines
7
- def list_mts(query = {})
8
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
9
-
10
- request = Web::Request.new(
11
- self,
12
- :get,
13
- '/mts',
14
- query
15
- )
16
-
17
- request.perform
18
- end
19
-
20
- def add_mt(query = {})
21
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
22
-
23
- request = Web::Request.new(
24
- self,
25
- :post,
26
- '/mts',
27
- query
28
- )
29
-
30
- request.perform
31
- end
32
-
33
- def get_mt(mt_id = nil)
34
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
35
- mt_id || raise_parameter_is_required_error(:mt_id)
36
-
37
- request = Web::Request.new(
38
- self,
39
- :get,
40
- "/mts/#{mt_id}"
41
- )
42
-
43
- request.perform
44
- end
45
-
46
- def delete_mt(mt_id = nil)
47
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
48
- mt_id || raise_parameter_is_required_error(:mt_id)
49
-
50
- request = Web::Request.new(
51
- self,
52
- :delete,
53
- "/mts/#{mt_id}"
54
- )
55
-
56
- request.perform
57
- end
58
-
59
- def edit_mt(mt_id = nil, query = {})
60
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
61
- mt_id || raise_parameter_is_required_error(:mt_id)
62
-
63
- request = Web::Request.new(
64
- self,
65
- :patch,
66
- "/mts/#{mt_id}",
67
- query
68
- )
69
-
70
- request.perform
71
- end
72
- end
73
- end
74
- end
@@ -1,148 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module ApiResources
5
- module Projects
6
- def list_projects(query = {})
7
- request = Web::Request.new(
8
- self,
9
- :get,
10
- '/projects',
11
- query
12
- )
13
-
14
- request.perform
15
- end
16
-
17
- def add_project(query = {})
18
- request = Web::Request.new(
19
- self,
20
- :post,
21
- '/projects',
22
- query
23
- )
24
-
25
- request.perform
26
- end
27
-
28
- def get_project(project_id = nil)
29
- project_id || raise_parameter_is_required_error(:project_id)
30
-
31
- request = Web::Request.new(
32
- self,
33
- :get,
34
- "/projects/#{project_id}"
35
- )
36
-
37
- request.perform
38
- end
39
-
40
- def delete_project(project_id = nil)
41
- project_id || raise_parameter_is_required_error(:project_id)
42
-
43
- request = Web::Request.new(
44
- self,
45
- :delete,
46
- "/projects/#{project_id}"
47
- )
48
-
49
- request.perform
50
- end
51
-
52
- #
53
- # Edit project.
54
- #
55
- # === Parameters
56
- #
57
- # * +:projectId+ [Integer] - Project Identifier. Get via list_projects. Can be initialized with the Crowdin Client
58
- # * +:value+ [String] - String or Array of strings.
59
- # * +:op+ [String] - Path operation to perform.
60
- # * +:projectId+ [String <json-pointer>] - Enum, for instance '/name'. Full list you can see on the developers site.
61
- #
62
- # === Example
63
- #
64
- # crowdin.edit_project(project_id, [{op: 'replace', path: '/name', value: 'your_new_project_name'}])
65
- #
66
- def edit_project(project_id = nil, query = {})
67
- project_id || raise_parameter_is_required_error(:project_id)
68
-
69
- request = Web::Request.new(
70
- self,
71
- :patch,
72
- "/projects/#{project_id}",
73
- query
74
- )
75
-
76
- request.perform
77
- end
78
-
79
- # -- For Enterprise mode only --
80
-
81
- def list_groups(query = {})
82
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
83
-
84
- request = Web::Request.new(
85
- self,
86
- :get,
87
- '/groups',
88
- query
89
- )
90
-
91
- request.perform
92
- end
93
-
94
- def add_group(query = {})
95
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
96
-
97
- request = Web::Request.new(
98
- self,
99
- :post,
100
- '/groups',
101
- query
102
- )
103
-
104
- request.perform
105
- end
106
-
107
- def get_group(group_id = nil)
108
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
109
- group_id || raise_parameter_is_required_error(:group_id)
110
-
111
- request = Web::Request.new(
112
- self,
113
- :get,
114
- "/groups/#{group_id}"
115
- )
116
-
117
- request.perform
118
- end
119
-
120
- def delete_group(group_id = nil)
121
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
122
- group_id || raise_parameter_is_required_error(:group_id)
123
-
124
- request = Web::Request.new(
125
- self,
126
- :delete,
127
- "/groups/#{group_id}"
128
- )
129
-
130
- request.perform
131
- end
132
-
133
- def edit_group(group_id = nil, query = {})
134
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
135
- group_id || raise_parameter_is_required_error(:group_id)
136
-
137
- request = Web::Request.new(
138
- self,
139
- :patch,
140
- "/groups/#{group_id}",
141
- query
142
- )
143
-
144
- request.perform
145
- end
146
- end
147
- end
148
- end
@@ -1,138 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module ApiResources
5
- module Reports
6
- def generate_report(query = {}, project_id = config.project_id)
7
- project_id || raise_project_id_is_required_error
8
-
9
- request = Web::Request.new(
10
- self,
11
- :post,
12
- "/projects/#{project_id}/reports",
13
- query
14
- )
15
-
16
- request.perform
17
- end
18
-
19
- def check_report_generation_status(report_id = nil, project_id = config.project_id)
20
- report_id || raise_parameter_is_required_error(:report_id)
21
- project_id || raise_project_id_is_required_error
22
-
23
- request = Web::Request.new(
24
- self,
25
- :get,
26
- "/projects/#{project_id}/reports/#{report_id}"
27
- )
28
-
29
- request.perform
30
- end
31
-
32
- def download_report(report_id = nil, destination = nil, project_id = config.project_id)
33
- report_id || raise_parameter_is_required_error(:report_id)
34
- project_id || raise_project_id_is_required_error
35
-
36
- request = Web::Request.new(
37
- self,
38
- :get,
39
- "/projects/#{project_id}/reports/#{report_id}/download",
40
- {},
41
- {},
42
- destination
43
- )
44
-
45
- request.perform
46
- end
47
-
48
- # -- For Enterprise mode only --
49
-
50
- def generate_group_report(group_id = nil, query = {})
51
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
52
- group_id || raise_parameter_is_required_error(:group_id)
53
-
54
- request = Web::Request.new(
55
- self,
56
- :post,
57
- "/groups/#{group_id}/reports",
58
- query
59
- )
60
-
61
- request.perform
62
- end
63
-
64
- def check_group_report_generation_status(group_id = nil, report_id = nil)
65
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
66
- group_id || raise_parameter_is_required_error(:group_id)
67
- report_id || raise_parameter_is_required_error(:report_id)
68
-
69
- request = Web::Request.new(
70
- self,
71
- :get,
72
- "/groups/#{group_id}/reports/#{report_id}"
73
- )
74
-
75
- request.perform
76
- end
77
-
78
- def download_group_report(group_id = nil, report_id = nil, destination = nil)
79
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
80
- group_id || raise_parameter_is_required_error(:group_id)
81
- report_id || raise_parameter_is_required_error(:report_id)
82
-
83
- request = Web::Request.new(
84
- self,
85
- :get,
86
- "/groups/#{group_id}/reports/#{report_id}/download",
87
- {},
88
- {},
89
- destination
90
- )
91
-
92
- request.perform
93
- end
94
-
95
- def generate_organization_report(query = {})
96
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
97
-
98
- request = Web::Request.new(
99
- self,
100
- :post,
101
- '/reports',
102
- query
103
- )
104
-
105
- request.perform
106
- end
107
-
108
- def check_organization_report_generation_status(report_id = nil)
109
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
110
- report_id || raise_parameter_is_required_error(:report_id)
111
-
112
- request = Web::Request.new(
113
- self,
114
- :get,
115
- "/reports/#{report_id}"
116
- )
117
-
118
- request.perform
119
- end
120
-
121
- def download_organization_report(report_id = nil, destination = nil)
122
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
123
- report_id || raise_parameter_is_required_error(:report_id)
124
-
125
- request = Web::Request.new(
126
- self,
127
- :get,
128
- "/reports/#{report_id}/download",
129
- {},
130
- {},
131
- destination
132
- )
133
-
134
- request.perform
135
- end
136
- end
137
- end
138
- end
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module ApiResources
5
- module Storages
6
- #
7
- # Get storages list.
8
- #
9
- # === Parameters
10
- #
11
- # Optional:
12
- # * +:limit+ [Integer 1..500] - A maximum number of items to retrieve, default - 25
13
- # * +:offset+ [Integer >= 0] - A starting offset in the collection, default - 0
14
- #
15
- # === Example
16
- #
17
- # crowdin.list_projects(limit: your_value)
18
- #
19
- def list_storages(query = {})
20
- request = Web::Request.new(
21
- self,
22
- :get,
23
- '/storages',
24
- query
25
- )
26
-
27
- request.perform
28
- end
29
-
30
- #
31
- # Add storage.
32
- #
33
- # === Parameters
34
- #
35
- # * +File+ - File class object or full path to file
36
- #
37
- # === Example
38
- #
39
- # crowdin.add_storage(File.open('your_filename.extension', 'r'))
40
- # or
41
- # crowdin.add_storage('your_filename.extension')
42
- #
43
- def add_storage(file = nil)
44
- file || raise_parameter_is_required_error(:file)
45
-
46
- file = file.is_a?(File) ? file : File.open(file, 'r')
47
-
48
- request = Web::Request.new(
49
- self,
50
- :post,
51
- '/storages',
52
- file,
53
- { 'Content-Type' => 'application/octet-stream', 'Crowdin-API-FileName' => File.basename(file) }
54
- )
55
-
56
- request.perform
57
- end
58
-
59
- #
60
- # Get storage information.
61
- #
62
- # === Parameters
63
- #
64
- # * +:storage_id+ [Integer] - Storage Identifier. Get via list_storages
65
- #
66
- # === Example
67
- #
68
- # crowdin.get_storage(your_storage_id)
69
- #
70
- def get_storage(storage_id = nil)
71
- storage_id || raise_parameter_is_required_error(:storage_id)
72
-
73
- request = Web::Request.new(
74
- self,
75
- :get,
76
- "/storages/#{storage_id}"
77
- )
78
-
79
- request.perform
80
- end
81
-
82
- #
83
- # Delete storage.
84
- #
85
- # === Parameters
86
- #
87
- # * +:storage_id+ [Integer] - Storage Identifier. Get via list_storages
88
- #
89
- # === Example
90
- #
91
- # crowdin.delete_storage(your_storage_id)
92
- #
93
- def delete_storage(storage_id = nil)
94
- storage_id || raise_parameter_is_required_error(:storage_id)
95
-
96
- request = Web::Request.new(
97
- self,
98
- :delete,
99
- "/storages/#{storage_id}"
100
- )
101
-
102
- request.perform
103
- end
104
- end
105
- end
106
- end
@@ -1,144 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module ApiResources
5
- # -- For Enterprise mode only --
6
- module Teams
7
- def add_team_to_project(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
- :post,
14
- "/projects/#{project_id}/teams",
15
- query
16
- )
17
-
18
- request.perform
19
- end
20
-
21
- def list_teams(query = {})
22
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
23
-
24
- request = Web::Request.new(
25
- self,
26
- :get,
27
- '/teams',
28
- query
29
- )
30
-
31
- request.perform
32
- end
33
-
34
- def add_team(query = {})
35
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
36
-
37
- request = Web::Request.new(
38
- self,
39
- :post,
40
- '/teams',
41
- query
42
- )
43
-
44
- request.perform
45
- end
46
-
47
- def get_team(team_id = nil, query = {})
48
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
49
- team_id || raise_parameter_is_required_error(:team_id)
50
-
51
- request = Web::Request.new(
52
- self,
53
- :get,
54
- "/teams/#{team_id}",
55
- query
56
- )
57
-
58
- request.perform
59
- end
60
-
61
- def delete_team(team_id = nil)
62
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
63
- team_id || raise_parameter_is_required_error(:team_id)
64
-
65
- request = Web::Request.new(
66
- self,
67
- :delete,
68
- "/teams/#{team_id}"
69
- )
70
-
71
- request.perform
72
- end
73
-
74
- def edit_team(team_id = nil, query = {})
75
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
76
- team_id || raise_parameter_is_required_error(:team_id)
77
-
78
- request = Web::Request.new(
79
- self,
80
- :patch,
81
- "/teams/#{team_id}",
82
- query
83
- )
84
-
85
- request.perform
86
- end
87
-
88
- def team_members_list(team_id = nil, query = {})
89
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
90
- team_id || raise_parameter_is_required_error(:team_id)
91
-
92
- request = Web::Request.new(
93
- self,
94
- :get,
95
- "/teams/#{team_id}/members",
96
- query
97
- )
98
-
99
- request.perform
100
- end
101
-
102
- def add_team_members(team_id = nil, query = {})
103
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
104
- team_id || raise_parameter_is_required_error(:team_id)
105
-
106
- request = Web::Request.new(
107
- self,
108
- :post,
109
- "/teams/#{team_id}/members",
110
- query
111
- )
112
-
113
- request.perform
114
- end
115
-
116
- def delete_all_team_members(team_id = nil)
117
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
118
- team_id || raise_parameter_is_required_error(:team_id)
119
-
120
- request = Web::Request.new(
121
- self,
122
- :delete,
123
- "/teams/#{team_id}/members"
124
- )
125
-
126
- request.perform
127
- end
128
-
129
- def delete_team_member(team_id = nil, member_id = nil)
130
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
131
- team_id || raise_parameter_is_required_error(:team_id)
132
- member_id || raise_parameter_is_required_error(:member_id)
133
-
134
- request = Web::Request.new(
135
- self,
136
- :delete,
137
- "/teams/#{team_id}/members/#{member_id}"
138
- )
139
-
140
- request.perform
141
- end
142
- end
143
- end
144
- end