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,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
@@ -1,129 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module ApiResources
5
- module Users
6
- def get_authenticated_user
7
- request = Web::Request.new(
8
- self,
9
- :get,
10
- '/user'
11
- )
12
-
13
- request.perform
14
- end
15
-
16
- def list_project_members(query = {}, project_id = config.project_id)
17
- project_id || raise_project_id_is_required_error
18
-
19
- request = Web::Request.new(
20
- self,
21
- :get,
22
- "/projects/#{project_id}/members",
23
- query
24
- )
25
-
26
- request.perform
27
- end
28
-
29
- def get_member_info(member_id = nil, project_id = config.project_id)
30
- member_id || raise_parameter_is_required_error(:member_id)
31
- project_id || raise_project_id_is_required_error
32
-
33
- request = Web::Request.new(
34
- self,
35
- :get,
36
- "/projects/#{project_id}/members/#{member_id}"
37
- )
38
-
39
- request.perform
40
- end
41
-
42
- # -- For Enterprise mode only --
43
-
44
- def add_project_member(query = {}, project_id = config.project_id)
45
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
46
- project_id || raise_project_id_is_required_error
47
-
48
- request = Web::Request.new(
49
- self,
50
- :post,
51
- "/projects/#{project_id}/members",
52
- query
53
- )
54
-
55
- request.perform
56
- end
57
-
58
- def get_project_member_permissions(member_id = nil, project_id = config.project_id)
59
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
60
- member_id || raise_parameter_is_required_error(:member_id)
61
- project_id || raise_project_id_is_required_error
62
-
63
- request = Web::Request.new(
64
- self,
65
- :get,
66
- "/projects/#{project_id}/members/#{member_id}"
67
- )
68
-
69
- request.perform
70
- end
71
-
72
- def replace_project_permissions(member_id = nil, query = {}, project_id = config.project_id)
73
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
74
- member_id || raise_parameter_is_required_error(:member_id)
75
- project_id || raise_project_id_is_required_error
76
-
77
- request = Web::Request.new(
78
- self,
79
- :put,
80
- "/projects/#{project_id}/members/#{member_id}",
81
- query
82
- )
83
-
84
- request.perform
85
- end
86
-
87
- def delete_member_from_project(member_id = nil, query = {}, project_id = config.project_id)
88
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
89
- member_id || raise_parameter_is_required_error(:member_id)
90
- project_id || raise_project_id_is_required_error
91
-
92
- request = Web::Request.new(
93
- self,
94
- :delete,
95
- "/projects/#{project_id}/members/#{member_id}",
96
- query
97
- )
98
-
99
- request.perform
100
- end
101
-
102
- def list_users(query = {})
103
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
104
-
105
- request = Web::Request.new(
106
- self,
107
- :get,
108
- '/users',
109
- query
110
- )
111
-
112
- request.perform
113
- end
114
-
115
- def get_user(user_id = nil)
116
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
117
- user_id || raise_parameter_is_required_error(:user_id)
118
-
119
- request = Web::Request.new(
120
- self,
121
- :get,
122
- "/users/#{user_id}"
123
- )
124
-
125
- request.perform
126
- end
127
- end
128
- end
129
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Crowdin
4
- module ApiResources
5
- # -- For Enterprise mode only --
6
- module Vendors
7
- def list_vendors(query = {})
8
- config.enterprise_mode? || raise_only_for_enterprise_mode_error
9
-
10
- request = Web::Request.new(
11
- self,
12
- :get,
13
- '/vendors',
14
- query
15
- )
16
-
17
- request.perform
18
- end
19
- end
20
- end
21
- end