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
@@ -5,85 +5,78 @@ module Crowdin
5
5
  module TranslationMemory
6
6
  def list_tms(query = {})
7
7
  request = Web::Request.new(
8
- self,
8
+ connection,
9
9
  :get,
10
- '/tms',
11
- query
10
+ "#{config.target_api_url}/tms",
11
+ { params: query }
12
12
  )
13
-
14
- request.perform
13
+ Web::SendRequest.new(request).perform
15
14
  end
16
15
 
17
16
  def add_tm(query = {})
18
17
  request = Web::Request.new(
19
- self,
18
+ connection,
20
19
  :post,
21
- '/tms',
22
- query
20
+ "#{config.target_api_url}/tms",
21
+ { params: query }
23
22
  )
24
-
25
- request.perform
23
+ Web::SendRequest.new(request).perform
26
24
  end
27
25
 
28
26
  def get_tm(tm_id = nil)
29
27
  tm_id || raise_parameter_is_required_error(:tm_id)
30
28
 
31
29
  request = Web::Request.new(
32
- self,
30
+ connection,
33
31
  :get,
34
- "/tms/#{tm_id}"
32
+ "#{config.target_api_url}/tms/#{tm_id}"
35
33
  )
36
-
37
- request.perform
34
+ Web::SendRequest.new(request).perform
38
35
  end
39
36
 
40
37
  def delete_tm(tm_id = nil)
41
38
  tm_id || raise_parameter_is_required_error(:tm_id)
42
39
 
43
40
  request = Web::Request.new(
44
- self,
41
+ connection,
45
42
  :delete,
46
- "/tms/#{tm_id}"
43
+ "#{config.target_api_url}/tms/#{tm_id}"
47
44
  )
48
-
49
- request.perform
45
+ Web::SendRequest.new(request).perform
50
46
  end
51
47
 
52
48
  def edit_tm(tm_id = nil, query = {})
53
49
  tm_id || raise_parameter_is_required_error(:tm_id)
54
50
 
55
51
  request = Web::Request.new(
56
- self,
57
- :delete,
58
- "/tms/#{tm_id}",
59
- query
52
+ connection,
53
+ :patch,
54
+ "#{config.target_api_url}/tms/#{tm_id}",
55
+ { params: query }
60
56
  )
61
-
62
- request.perform
57
+ Web::SendRequest.new(request).perform
63
58
  end
64
59
 
65
60
  def clear_tm(tm_id = nil)
66
61
  tm_id || raise_parameter_is_required_error(:tm_id)
67
62
 
68
63
  request = Web::Request.new(
69
- self,
64
+ connection,
70
65
  :delete,
71
- "/tms/#{tm_id}/segments"
66
+ "#{config.target_api_url}/tms/#{tm_id}/segments"
72
67
  )
73
-
74
- request.perform
68
+ Web::SendRequest.new(request).perform
75
69
  end
76
70
 
77
71
  def export_tm(tm_id = nil)
78
72
  tm_id || raise_parameter_is_required_error(:tm_id)
79
73
 
80
74
  request = Web::Request.new(
81
- self,
75
+ connection,
82
76
  :post,
83
- "/tms/#{tm_id}/exports"
77
+ "#{config.target_api_url}/tms/#{tm_id}/exports"
84
78
  )
85
-
86
- request.perform
79
+ Web::SendRequest.new(request).perform
87
80
  end
88
81
 
89
82
  def check_tm_export_status(tm_id = nil, export_id = nil)
@@ -91,12 +84,11 @@ module Crowdin
91
84
  export_id || raise_parameter_is_required_error(:export_id)
92
85
 
93
86
  request = Web::Request.new(
94
- self,
87
+ connection,
95
88
  :get,
96
- "/tms/#{tm_id}/exports/#{export_id}"
89
+ "#{config.target_api_url}/tms/#{tm_id}/exports/#{export_id}"
97
90
  )
98
-
99
- request.perform
91
+ Web::SendRequest.new(request).perform
100
92
  end
101
93
 
102
94
  def download_tm(tm_id = nil, export_id = nil, destination = nil)
@@ -104,28 +96,23 @@ module Crowdin
104
96
  export_id || raise_parameter_is_required_error(:export_id)
105
97
 
106
98
  request = Web::Request.new(
107
- self,
99
+ connection,
108
100
  :get,
109
- "/tms/#{tm_id}/exports/#{export_id}/download",
110
- {},
111
- {},
112
- destination
101
+ "#{config.target_api_url}/tms/#{tm_id}/exports/#{export_id}/download"
113
102
  )
114
-
115
- request.perform
103
+ Web::SendRequest.new(request, destination).perform
116
104
  end
117
105
 
118
106
  def import_tm(tm_id = nil, query = {})
119
107
  tm_id || raise_parameter_is_required_error(:tm_id)
120
108
 
121
109
  request = Web::Request.new(
122
- self,
110
+ connection,
123
111
  :post,
124
- "/tms/#{tm_id}/imports",
125
- query
112
+ "#{config.target_api_url}/tms/#{tm_id}/imports",
113
+ { params: query }
126
114
  )
127
-
128
- request.perform
115
+ Web::SendRequest.new(request).perform
129
116
  end
130
117
 
131
118
  def check_tm_import_status(tm_id = nil, import_id = nil)
@@ -133,12 +120,11 @@ module Crowdin
133
120
  import_id || raise_parameter_is_required_error(:import_id)
134
121
 
135
122
  request = Web::Request.new(
136
- self,
123
+ connection,
137
124
  :get,
138
- "/tms/#{tm_id}/imports/#{import_id}"
125
+ "#{config.target_api_url}/tms/#{tm_id}/imports/#{import_id}"
139
126
  )
140
-
141
- request.perform
127
+ Web::SendRequest.new(request).perform
142
128
  end
143
129
  end
144
130
  end
@@ -8,13 +8,12 @@ module Crowdin
8
8
  project_id || raise_project_id_is_required_error
9
9
 
10
10
  request = Web::Request.new(
11
- self,
11
+ connection,
12
12
  :get,
13
- "/projects/#{project_id}/branches/#{branch_id}/languages/progress",
14
- query
13
+ "#{config.target_api_url}/projects/#{project_id}/branches/#{branch_id}/languages/progress",
14
+ { params: query }
15
15
  )
16
-
17
- request.perform
16
+ Web::SendRequest.new(request).perform
18
17
  end
19
18
 
20
19
  def get_directory_progress(directory_id = nil, query = {}, project_id = config.project_id)
@@ -22,13 +21,12 @@ module Crowdin
22
21
  project_id || raise_project_id_is_required_error
23
22
 
24
23
  request = Web::Request.new(
25
- self,
24
+ connection,
26
25
  :get,
27
- "/projects/#{project_id}/directories/#{directory_id}/languages/progress",
28
- query
26
+ "#{config.target_api_url}/projects/#{project_id}/directories/#{directory_id}/languages/progress",
27
+ { params: query }
29
28
  )
30
-
31
- request.perform
29
+ Web::SendRequest.new(request).perform
32
30
  end
33
31
 
34
32
  def get_file_progress(file_id = nil, query = {}, project_id = config.project_id)
@@ -36,13 +34,12 @@ module Crowdin
36
34
  project_id || raise_project_id_is_required_error
37
35
 
38
36
  request = Web::Request.new(
39
- self,
37
+ connection,
40
38
  :get,
41
- "/projects/#{project_id}/files/#{file_id}/languages/progress",
42
- query
39
+ "#{config.target_api_url}/projects/#{project_id}/files/#{file_id}/languages/progress",
40
+ { params: query }
43
41
  )
44
-
45
- request.perform
42
+ Web::SendRequest.new(request).perform
46
43
  end
47
44
 
48
45
  def get_language_progress(language_id = nil, query = {}, project_id = config.project_id)
@@ -50,39 +47,36 @@ module Crowdin
50
47
  project_id || raise_project_id_is_required_error
51
48
 
52
49
  request = Web::Request.new(
53
- self,
50
+ connection,
54
51
  :get,
55
- "/projects/#{project_id}/languages/#{language_id}/progress",
56
- query
52
+ "#{config.target_api_url}/projects/#{project_id}/languages/#{language_id}/progress",
53
+ { params: query }
57
54
  )
58
-
59
- request.perform
55
+ Web::SendRequest.new(request).perform
60
56
  end
61
57
 
62
58
  def get_project_progress(query = {}, project_id = config.project_id)
63
59
  project_id || raise_project_id_is_required_error
64
60
 
65
61
  request = Web::Request.new(
66
- self,
62
+ connection,
67
63
  :get,
68
- "/projects/#{project_id}/languages/progress",
69
- query
64
+ "#{config.target_api_url}/projects/#{project_id}/languages/progress",
65
+ { params: query }
70
66
  )
71
-
72
- request.perform
67
+ Web::SendRequest.new(request).perform
73
68
  end
74
69
 
75
70
  def get_qa_progress(query = {}, project_id = config.project_id)
76
71
  project_id || raise_project_id_is_required_error
77
72
 
78
73
  request = Web::Request.new(
79
- self,
74
+ connection,
80
75
  :get,
81
- "/projects/#{project_id}/qa-checks",
82
- query
76
+ "#{config.target_api_url}/projects/#{project_id}/qa-checks",
77
+ { params: query }
83
78
  )
84
-
85
- request.perform
79
+ Web::SendRequest.new(request).perform
86
80
  end
87
81
  end
88
82
  end
@@ -8,25 +8,23 @@ module Crowdin
8
8
  project_id || raise_project_id_is_required_error
9
9
 
10
10
  request = Web::Request.new(
11
- self,
11
+ connection,
12
12
  :get,
13
- "/projects/#{project_id}/pre-translations/#{pre_translation_id}"
13
+ "#{config.target_api_url}/projects/#{project_id}/pre-translations/#{pre_translation_id}"
14
14
  )
15
-
16
- request.perform
15
+ Web::SendRequest.new(request).perform
17
16
  end
18
17
 
19
18
  def apply_pre_translation(query = {}, project_id = config.project_id)
20
19
  project_id || raise_project_id_is_required_error
21
20
 
22
21
  request = Web::Request.new(
23
- self,
22
+ connection,
24
23
  :post,
25
- "/projects/#{project_id}/pre-translations",
26
- query
24
+ "#{config.target_api_url}/projects/#{project_id}/pre-translations",
25
+ { params: query }
27
26
  )
28
-
29
- request.perform
27
+ Web::SendRequest.new(request).perform
30
28
  end
31
29
 
32
30
  def build_project_directory_translation(directory_id = nil, query = {}, project_id = config.project_id)
@@ -34,13 +32,12 @@ module Crowdin
34
32
  project_id || raise_project_id_is_required_error
35
33
 
36
34
  request = Web::Request.new(
37
- self,
35
+ connection,
38
36
  :post,
39
- "/projects/#{project_id}/translations/builds/directories/#{directory_id}",
40
- query
37
+ "#{config.target_api_url}/projects/#{project_id}/translations/builds/directories/#{directory_id}",
38
+ { params: query }
41
39
  )
42
-
43
- request.perform
40
+ Web::SendRequest.new(request).perform
44
41
  end
45
42
 
46
43
  def build_project_file_translation(file_id = nil, query = {}, destination = nil, project_id = config.project_id)
@@ -50,41 +47,36 @@ module Crowdin
50
47
  headers = query[:eTag] ? { 'If-None-Match' => query[:eTag] } : {}
51
48
 
52
49
  request = Web::Request.new(
53
- self,
50
+ connection,
54
51
  :post,
55
- "/projects/#{project_id}/translations/builds/files/#{file_id}",
56
- query,
57
- headers,
58
- destination
52
+ "#{config.target_api_url}/projects/#{project_id}/translations/builds/files/#{file_id}",
53
+ { params: query, headers: headers }
59
54
  )
60
-
61
- request.perform
55
+ Web::SendRequest.new(request, destination).perform
62
56
  end
63
57
 
64
58
  def list_project_builds(query = {}, project_id = config.project_id)
65
59
  project_id || raise_project_id_is_required_error
66
60
 
67
61
  request = Web::Request.new(
68
- self,
62
+ connection,
69
63
  :get,
70
- "/projects/#{project_id}/translations/builds",
71
- query
64
+ "#{config.target_api_url}/projects/#{project_id}/translations/builds",
65
+ { params: query }
72
66
  )
73
-
74
- request.perform
67
+ Web::SendRequest.new(request).perform
75
68
  end
76
69
 
77
70
  def build_project_translation(query = {}, project_id = config.project_id)
78
71
  project_id || raise_project_id_is_required_error
79
72
 
80
73
  request = Web::Request.new(
81
- self,
74
+ connection,
82
75
  :post,
83
- "/projects/#{project_id}/translations/builds",
84
- query
76
+ "#{config.target_api_url}/projects/#{project_id}/translations/builds",
77
+ { params: query }
85
78
  )
86
-
87
- request.perform
79
+ Web::SendRequest.new(request).perform
88
80
  end
89
81
 
90
82
  def upload_translations(language_id = nil, query = {}, project_id = config.project_id)
@@ -92,13 +84,12 @@ module Crowdin
92
84
  project_id || raise_project_id_is_required_error
93
85
 
94
86
  request = Web::Request.new(
95
- self,
87
+ connection,
96
88
  :post,
97
- "/projects/#{project_id}/translations/#{language_id}",
98
- query
89
+ "#{config.target_api_url}/projects/#{project_id}/translations/#{language_id}",
90
+ { params: query }
99
91
  )
100
-
101
- request.perform
92
+ Web::SendRequest.new(request).perform
102
93
  end
103
94
 
104
95
  def download_project_translations(build_id = nil, destination = nil, project_id = config.project_id)
@@ -106,15 +97,11 @@ module Crowdin
106
97
  project_id || raise_project_id_is_required_error
107
98
 
108
99
  request = Web::Request.new(
109
- self,
100
+ connection,
110
101
  :get,
111
- "/projects/#{project_id}/translations/builds/#{build_id}/download",
112
- {},
113
- {},
114
- destination
102
+ "#{config.target_api_url}/projects/#{project_id}/translations/builds/#{build_id}/download"
115
103
  )
116
-
117
- request.perform
104
+ Web::SendRequest.new(request, destination).perform
118
105
  end
119
106
 
120
107
  def check_project_build_status(build_id = nil, project_id = config.project_id)
@@ -122,12 +109,11 @@ module Crowdin
122
109
  project_id || raise_project_id_is_required_error
123
110
 
124
111
  request = Web::Request.new(
125
- self,
112
+ connection,
126
113
  :get,
127
- "/projects/#{project_id}/translations/builds/#{build_id}"
114
+ "#{config.target_api_url}/projects/#{project_id}/translations/builds/#{build_id}"
128
115
  )
129
-
130
- request.perform
116
+ Web::SendRequest.new(request).perform
131
117
  end
132
118
 
133
119
  def cancel_build(build_id = nil, project_id = config.project_id)
@@ -135,27 +121,23 @@ module Crowdin
135
121
  project_id || raise_project_id_is_required_error
136
122
 
137
123
  request = Web::Request.new(
138
- self,
124
+ connection,
139
125
  :delete,
140
- "/projects/#{project_id}/translations/builds/#{build_id}"
126
+ "#{config.target_api_url}/projects/#{project_id}/translations/builds/#{build_id}"
141
127
  )
142
-
143
- request.perform
128
+ Web::SendRequest.new(request).perform
144
129
  end
145
130
 
146
131
  def export_project_translation(query = {}, destination = nil, project_id = config.project_id)
147
132
  project_id || raise_project_id_is_required_error
148
133
 
149
134
  request = Web::Request.new(
150
- self,
135
+ connection,
151
136
  :post,
152
- "/projects/#{project_id}/translations/exports",
153
- query,
154
- {},
155
- destination
137
+ "#{config.target_api_url}/projects/#{project_id}/translations/exports",
138
+ { params: query }
156
139
  )
157
-
158
- request.perform
140
+ Web::SendRequest.new(request, destination).perform
159
141
  end
160
142
  end
161
143
  end
@@ -0,0 +1,161 @@
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
+ connection,
9
+ :get,
10
+ "#{config.target_api_url}/user"
11
+ )
12
+ Web::SendRequest.new(request).perform
13
+ end
14
+
15
+ def list_project_members(query = {}, project_id = config.project_id)
16
+ project_id || raise_project_id_is_required_error
17
+
18
+ request = Web::Request.new(
19
+ connection,
20
+ :get,
21
+ "#{config.target_api_url}/projects/#{project_id}/members",
22
+ { params: query }
23
+ )
24
+ Web::SendRequest.new(request).perform
25
+ end
26
+
27
+ def get_member_info(member_id = nil, project_id = config.project_id)
28
+ member_id || raise_parameter_is_required_error(:member_id)
29
+ project_id || raise_project_id_is_required_error
30
+
31
+ request = Web::Request.new(
32
+ connection,
33
+ :get,
34
+ "#{config.target_api_url}/projects/#{project_id}/members/#{member_id}"
35
+ )
36
+ Web::SendRequest.new(request).perform
37
+ end
38
+
39
+ # -- For Enterprise mode only --
40
+
41
+ def add_project_member(query = {}, project_id = config.project_id)
42
+ enterprise_mode? || raise_only_for_enterprise_mode_error
43
+ project_id || raise_project_id_is_required_error
44
+
45
+ request = Web::Request.new(
46
+ connection,
47
+ :post,
48
+ "#{config.target_api_url}/projects/#{project_id}/members",
49
+ { params: query }
50
+ )
51
+ Web::SendRequest.new(request).perform
52
+ end
53
+
54
+ def get_project_member_permissions(member_id = nil, project_id = config.project_id)
55
+ enterprise_mode? || raise_only_for_enterprise_mode_error
56
+ member_id || raise_parameter_is_required_error(:member_id)
57
+ project_id || raise_project_id_is_required_error
58
+
59
+ request = Web::Request.new(
60
+ connection,
61
+ :get,
62
+ "#{config.target_api_url}/projects/#{project_id}/members/#{member_id}"
63
+ )
64
+ Web::SendRequest.new(request).perform
65
+ end
66
+
67
+ def replace_project_permissions(member_id = nil, query = {}, project_id = config.project_id)
68
+ enterprise_mode? || raise_only_for_enterprise_mode_error
69
+ member_id || raise_parameter_is_required_error(:member_id)
70
+ project_id || raise_project_id_is_required_error
71
+
72
+ request = Web::Request.new(
73
+ connection,
74
+ :put,
75
+ "#{config.target_api_url}/projects/#{project_id}/members/#{member_id}",
76
+ { params: query }
77
+ )
78
+ Web::SendRequest.new(request).perform
79
+ end
80
+
81
+ def delete_member_from_project(member_id = nil, query = {}, project_id = config.project_id)
82
+ enterprise_mode? || raise_only_for_enterprise_mode_error
83
+ member_id || raise_parameter_is_required_error(:member_id)
84
+ project_id || raise_project_id_is_required_error
85
+
86
+ response = ::RestClient::Request.execute(
87
+ {
88
+ method: :delete,
89
+ url: config.base_url + config.target_api_url + "/projects/#{project_id}/members/#{member_id}",
90
+ payload: query.to_json
91
+ }.merge(@options)
92
+ )
93
+
94
+ response.body.empty? ? response.code : JSON.parse(response.body)
95
+ rescue StandardError => e
96
+ e.message
97
+ end
98
+
99
+ def list_users(query = {})
100
+ enterprise_mode? || raise_only_for_enterprise_mode_error
101
+
102
+ request = Web::Request.new(
103
+ connection,
104
+ :get,
105
+ "#{config.target_api_url}/users",
106
+ { params: query }
107
+ )
108
+ Web::SendRequest.new(request).perform
109
+ end
110
+
111
+ def invite_user(query = {})
112
+ enterprise_mode? || raise_only_for_enterprise_mode_error
113
+
114
+ request = Web::Request.new(
115
+ connection,
116
+ :post,
117
+ "#{config.target_api_url}/users",
118
+ { params: query }
119
+ )
120
+ Web::SendRequest.new(request).perform
121
+ end
122
+
123
+ def get_user(user_id = nil)
124
+ enterprise_mode? || raise_only_for_enterprise_mode_error
125
+ user_id || raise_parameter_is_required_error(:user_id)
126
+
127
+ request = Web::Request.new(
128
+ connection,
129
+ :get,
130
+ "#{config.target_api_url}/users/#{user_id}"
131
+ )
132
+ Web::SendRequest.new(request).perform
133
+ end
134
+
135
+ def delete_user(user_id = nil)
136
+ enterprise_mode? || raise_only_for_enterprise_mode_error
137
+ user_id || raise_parameter_is_required_error(:user_id)
138
+
139
+ request = Web::Request.new(
140
+ connection,
141
+ :delete,
142
+ "#{config.target_api_url}/users/#{user_id}"
143
+ )
144
+ Web::SendRequest.new(request).perform
145
+ end
146
+
147
+ def edit_user(user_id = nil, query = {})
148
+ enterprise_mode? || raise_only_for_enterprise_mode_error
149
+ user_id || raise_parameter_is_required_error(:user_id)
150
+
151
+ request = Web::Request.new(
152
+ connection,
153
+ :patch,
154
+ "#{config.target_api_url}/users/#{user_id}",
155
+ { params: query }
156
+ )
157
+ Web::SendRequest.new(request).perform
158
+ end
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module Vendors
6
+ # -- For Enterprise mode only --
7
+
8
+ def list_vendors(query = {})
9
+ enterprise_mode? || raise_only_for_enterprise_mode_error
10
+
11
+ request = Web::Request.new(
12
+ connection,
13
+ :get,
14
+ "#{config.target_api_url}/vendors",
15
+ { params: query }
16
+ )
17
+ Web::SendRequest.new(request).perform
18
+ end
19
+ end
20
+ end
21
+ end