crowdin-api 1.1.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test-and-lint.yml +1 -1
  3. data/.gitignore +2 -2
  4. data/.rubocop_todo.yml +114 -42
  5. data/README.md +26 -13
  6. data/bin/crowdin-console +5 -5
  7. data/crowdin-api.gemspec +1 -2
  8. data/lib/crowdin-api/api_resources/dictionaries.rb +32 -0
  9. data/lib/crowdin-api/api_resources/distributions.rb +92 -0
  10. data/lib/crowdin-api/api_resources/glossaries.rb +199 -0
  11. data/lib/crowdin-api/api_resources/labels.rb +98 -0
  12. data/lib/crowdin-api/api_resources/languages.rb +61 -0
  13. data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
  14. data/lib/crowdin-api/api_resources/projects.rb +124 -0
  15. data/lib/crowdin-api/api_resources/reports.rb +120 -0
  16. data/lib/crowdin-api/api_resources/screenshots.rb +172 -0
  17. data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -130
  18. data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
  19. data/lib/crowdin-api/api_resources/storages.rb +54 -0
  20. data/lib/crowdin-api/api_resources/string_comments.rb +68 -0
  21. data/lib/crowdin-api/api_resources/string_translations.rb +193 -0
  22. data/lib/crowdin-api/api_resources/tasks.rb +102 -0
  23. data/lib/crowdin-api/api_resources/teams.rb +135 -0
  24. data/lib/crowdin-api/api_resources/translation_memory.rb +131 -0
  25. data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
  26. data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -59
  27. data/lib/crowdin-api/api_resources/users.rb +161 -0
  28. data/lib/crowdin-api/api_resources/vendors.rb +21 -0
  29. data/lib/crowdin-api/api_resources/webhooks.rb +68 -0
  30. data/lib/crowdin-api/api_resources/workflows.rb +59 -0
  31. data/lib/crowdin-api/client/client.rb +72 -50
  32. data/lib/crowdin-api/client/configuration.rb +16 -12
  33. data/lib/crowdin-api/client/version.rb +1 -1
  34. data/lib/crowdin-api/core/errors.rb +2 -1
  35. data/lib/crowdin-api/core/{api_errors_raiser.rb → errors_raisers.rb} +21 -11
  36. data/lib/crowdin-api/core/request.rb +53 -88
  37. data/lib/crowdin-api/core/send_request.rb +67 -0
  38. data/lib/crowdin-api.rb +20 -11
  39. data/spec/api_resources/dictionaries_spec.rb +23 -0
  40. data/spec/api_resources/distributions_spec.rb +71 -0
  41. data/spec/api_resources/glossaries_spec.rb +167 -0
  42. data/spec/api_resources/labels_spec.rb +71 -0
  43. data/spec/api_resources/languages_spec.rb +51 -0
  44. data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
  45. data/spec/api_resources/projects_spec.rb +215 -0
  46. data/spec/api_resources/reports_spec.rb +95 -0
  47. data/spec/api_resources/screenshots_spec.rb +134 -0
  48. data/spec/api_resources/source_files_spec.rb +13 -0
  49. data/spec/api_resources/source_strings_spec.rb +51 -0
  50. data/spec/api_resources/storages_spec.rb +13 -0
  51. data/spec/api_resources/string_comments_spec.rb +13 -0
  52. data/spec/api_resources/string_translations_spec.rb +13 -0
  53. data/spec/api_resources/tasks_spec.rb +79 -0
  54. data/spec/api_resources/teams_spec.rb +13 -0
  55. data/spec/api_resources/translation_memory_spec.rb +13 -0
  56. data/spec/api_resources/translation_status_spec.rb +15 -0
  57. data/spec/api_resources/translations_spec.rb +107 -0
  58. data/spec/api_resources/users_spec.rb +117 -0
  59. data/spec/api_resources/vendors_spec.rb +13 -0
  60. data/spec/api_resources/webhooks_spec.rb +51 -0
  61. data/spec/api_resources/workflows_spec.rb +41 -0
  62. data/spec/spec_helper.rb +20 -2
  63. data/spec/unit/client_spec.rb +85 -0
  64. metadata +65 -28
  65. data/bin/setup +0 -6
  66. data/lib/crowdin-api/api-resources/languages.rb +0 -81
  67. data/lib/crowdin-api/api-resources/projects.rb +0 -134
  68. data/lib/crowdin-api/api-resources/storages.rb +0 -102
  69. data/lib/crowdin-api/api-resources/workflows.rb +0 -59
  70. data/spec/core/config-instance_spec.rb +0 -72
  71. data/spec/crowdin-api_spec.rb +0 -7
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module StringComments
6
+ def list_string_comments(query = {}, project_id = config.project_id)
7
+ project_id || raise_project_id_is_required_error
8
+
9
+ request = Web::Request.new(
10
+ connection,
11
+ :get,
12
+ "#{config.target_api_url}/projects/#{project_id}/comments",
13
+ { params: query }
14
+ )
15
+ Web::SendRequest.new(request).perform
16
+ end
17
+
18
+ def add_string_comment(query = {}, project_id = config.project_id)
19
+ project_id || raise_project_id_is_required_error
20
+
21
+ request = Web::Request.new(
22
+ connection,
23
+ :post,
24
+ "#{config.target_api_url}/projects/#{project_id}/comments",
25
+ { params: query }
26
+ )
27
+ Web::SendRequest.new(request).perform
28
+ end
29
+
30
+ def get_string_comment(string_comment_id = nil, project_id = config.project_id)
31
+ string_comment_id || raise_parameter_is_required_error(:string_comment_id)
32
+ project_id || raise_project_id_is_required_error
33
+
34
+ request = Web::Request.new(
35
+ connection,
36
+ :get,
37
+ "#{config.target_api_url}/projects/#{project_id}/comments/#{string_comment_id}"
38
+ )
39
+ Web::SendRequest.new(request).perform
40
+ end
41
+
42
+ def delete_string_comment(string_comment_id = nil, project_id = config.project_id)
43
+ string_comment_id || raise_parameter_is_required_error(:string_comment_id)
44
+ project_id || raise_project_id_is_required_error
45
+
46
+ request = Web::Request.new(
47
+ connection,
48
+ :delete,
49
+ "#{config.target_api_url}/projects/#{project_id}/comments/#{string_comment_id}"
50
+ )
51
+ Web::SendRequest.new(request).perform
52
+ end
53
+
54
+ def edit_string_comment(string_comment_id = nil, query = {}, project_id = config.project_id)
55
+ string_comment_id || raise_parameter_is_required_error(:string_comment_id)
56
+ project_id || raise_project_id_is_required_error
57
+
58
+ request = Web::Request.new(
59
+ connection,
60
+ :patch,
61
+ "#{config.target_api_url}/projects/#{project_id}/comments/#{string_comment_id}",
62
+ { params: query }
63
+ )
64
+ Web::SendRequest.new(request).perform
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,193 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module StringTranslations
6
+ def list_translation_approvals(query = {}, project_id = config.project_id)
7
+ project_id || raise_project_id_is_required_error
8
+
9
+ request = Web::Request.new(
10
+ connection,
11
+ :get,
12
+ "#{config.target_api_url}/projects/#{project_id}/approvals",
13
+ { params: query }
14
+ )
15
+ Web::SendRequest.new(request).perform
16
+ end
17
+
18
+ def add_approval(query = {}, project_id = config.project_id)
19
+ project_id || raise_project_id_is_required_error
20
+
21
+ request = Web::Request.new(
22
+ connection,
23
+ :post,
24
+ "#{config.target_api_url}/projects/#{project_id}/approvals",
25
+ { params: query }
26
+ )
27
+ Web::SendRequest.new(request).perform
28
+ end
29
+
30
+ def get_approval(approval_id = nil, project_id = config.project_id)
31
+ approval_id || raise_parameter_is_required_error(:approval_id)
32
+ project_id || raise_project_id_is_required_error
33
+
34
+ request = Web::Request.new(
35
+ connection,
36
+ :get,
37
+ "#{config.target_api_url}/projects/#{project_id}/approvals/#{approval_id}"
38
+ )
39
+ Web::SendRequest.new(request).perform
40
+ end
41
+
42
+ def remove_approval(approval_id = nil, project_id = config.project_id)
43
+ approval_id || raise_parameter_is_required_error(:approval_id)
44
+ project_id || raise_project_id_is_required_error
45
+
46
+ request = Web::Request.new(
47
+ connection,
48
+ :delete,
49
+ "#{config.target_api_url}/projects/#{project_id}/approvals/#{approval_id}"
50
+ )
51
+ Web::SendRequest.new(request).perform
52
+ end
53
+
54
+ def list_language_translations(language_id = nil, query = {}, project_id = config.project_id)
55
+ language_id || raise_parameter_is_required_error(:language_id)
56
+ project_id || raise_project_id_is_required_error
57
+
58
+ request = Web::Request.new(
59
+ connection,
60
+ :get,
61
+ "#{config.target_api_url}/projects/#{project_id}/languages/#{language_id}/translations",
62
+ { params: query }
63
+ )
64
+ Web::SendRequest.new(request).perform
65
+ end
66
+
67
+ def list_string_translations(query = {}, project_id = config.project_id)
68
+ project_id || raise_project_id_is_required_error
69
+
70
+ request = Web::Request.new(
71
+ connection,
72
+ :get,
73
+ "#{config.target_api_url}/projects/#{project_id}/translations",
74
+ { params: query }
75
+ )
76
+ Web::SendRequest.new(request).perform
77
+ end
78
+
79
+ def add_translation(query = {}, project_id = config.project_id)
80
+ project_id || raise_project_id_is_required_error
81
+
82
+ request = Web::Request.new(
83
+ connection,
84
+ :post,
85
+ "#{config.target_api_url}/projects/#{project_id}/translations",
86
+ { params: query }
87
+ )
88
+ Web::SendRequest.new(request).perform
89
+ end
90
+
91
+ def delete_string_translations(query = {}, project_id = config.project_id)
92
+ project_id || raise_project_id_is_required_error
93
+
94
+ response = ::RestClient::Request.execute(
95
+ {
96
+ method: :delete,
97
+ url: config.base_url + config.target_api_url + "/projects/#{project_id}/translations",
98
+ payload: query.to_json
99
+ }.merge(@options)
100
+ )
101
+
102
+ response.body.empty? ? response.code : JSON.parse(response.body)
103
+ rescue StandardError => e
104
+ e.message
105
+ end
106
+
107
+ def get_translation(translation_id = nil, query = {}, project_id = config.project_id)
108
+ translation_id || raise_parameter_is_required_error(:translation_id)
109
+ project_id || raise_project_id_is_required_error
110
+
111
+ request = Web::Request.new(
112
+ connection,
113
+ :get,
114
+ "#{config.target_api_url}/projects/#{project_id}/translations/#{translation_id}",
115
+ { params: query }
116
+ )
117
+ Web::SendRequest.new(request).perform
118
+ end
119
+
120
+ def restore_translation(translation_id = nil, project_id = config.project_id)
121
+ translation_id || raise_parameter_is_required_error(:translation_id)
122
+ project_id || raise_project_id_is_required_error
123
+
124
+ request = Web::Request.new(
125
+ connection,
126
+ :put,
127
+ "#{config.target_api_url}/projects/#{project_id}/translations/#{translation_id}"
128
+ )
129
+ Web::SendRequest.new(request).perform
130
+ end
131
+
132
+ def delete_translation(translation_id = nil, project_id = config.project_id)
133
+ translation_id || raise_parameter_is_required_error(:translation_id)
134
+ project_id || raise_project_id_is_required_error
135
+
136
+ request = Web::Request.new(
137
+ connection,
138
+ :delete,
139
+ "#{config.target_api_url}/projects/#{project_id}/translations/#{translation_id}"
140
+ )
141
+ Web::SendRequest.new(request).perform
142
+ end
143
+
144
+ def list_translation_votes(query = {}, project_id = config.project_id)
145
+ project_id || raise_project_id_is_required_error
146
+
147
+ request = Web::Request.new(
148
+ connection,
149
+ :get,
150
+ "#{config.target_api_url}/projects/#{project_id}/votes",
151
+ { params: query }
152
+ )
153
+ Web::SendRequest.new(request).perform
154
+ end
155
+
156
+ def add_vote(query = {}, project_id = config.project_id)
157
+ project_id || raise_project_id_is_required_error
158
+
159
+ request = Web::Request.new(
160
+ connection,
161
+ :post,
162
+ "#{config.target_api_url}/projects/#{project_id}/votes",
163
+ { params: query }
164
+ )
165
+ Web::SendRequest.new(request).perform
166
+ end
167
+
168
+ def get_vote(vote_id = nil, project_id = config.project_id)
169
+ vote_id || raise_parameter_is_required_error(:vote_id)
170
+ project_id || raise_project_id_is_required_error
171
+
172
+ request = Web::Request.new(
173
+ connection,
174
+ :get,
175
+ "#{config.target_api_url}/projects/#{project_id}/votes/#{vote_id}"
176
+ )
177
+ Web::SendRequest.new(request).perform
178
+ end
179
+
180
+ def edit_screenshot(vote_id = nil, project_id = config.project_id)
181
+ vote_id || raise_parameter_is_required_error(:vote_id)
182
+ project_id || raise_project_id_is_required_error
183
+
184
+ request = Web::Request.new(
185
+ connection,
186
+ :delete,
187
+ "#{config.target_api_url}/projects/#{project_id}/votes/#{vote_id}"
188
+ )
189
+ Web::SendRequest.new(request).perform
190
+ end
191
+ end
192
+ end
193
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module Tasks
6
+ def list_tasks(query = {}, project_id = config.project_id)
7
+ project_id || raise_project_id_is_required_error
8
+
9
+ request = Web::Request.new(
10
+ connection,
11
+ :get,
12
+ "#{config.target_api_url}/projects/#{project_id}/tasks",
13
+ { params: query }
14
+ )
15
+ Web::SendRequest.new(request).perform
16
+ end
17
+
18
+ def add_task(query = {}, project_id = config.project_id)
19
+ project_id || raise_project_id_is_required_error
20
+
21
+ request = Web::Request.new(
22
+ connection,
23
+ :post,
24
+ "#{config.target_api_url}/projects/#{project_id}/tasks",
25
+ { params: query }
26
+ )
27
+ Web::SendRequest.new(request).perform
28
+ end
29
+
30
+ def export_task_strings(task_id = nil, destination = nil, project_id = config.project_id)
31
+ task_id || raise_parameter_is_required_error(:task_id)
32
+ project_id || raise_project_id_is_required_error
33
+
34
+ request = Web::Request.new(
35
+ connection,
36
+ :post,
37
+ "#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}/exports"
38
+ )
39
+ Web::SendRequest.new(request, destination).perform
40
+ end
41
+
42
+ def get_task(task_id = nil, project_id = config.project_id)
43
+ task_id || raise_parameter_is_required_error(:task_id)
44
+ project_id || raise_project_id_is_required_error
45
+
46
+ request = Web::Request.new(
47
+ connection,
48
+ :get,
49
+ "#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}"
50
+ )
51
+ Web::SendRequest.new(request).perform
52
+ end
53
+
54
+ def delete_task(task_id = nil, project_id = config.project_id)
55
+ task_id || raise_parameter_is_required_error(:task_id)
56
+ project_id || raise_project_id_is_required_error
57
+
58
+ request = Web::Request.new(
59
+ connection,
60
+ :delete,
61
+ "#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}"
62
+ )
63
+ Web::SendRequest.new(request).perform
64
+ end
65
+
66
+ def edit_task(task_id = nil, query = {}, project_id = config.project_id)
67
+ task_id || raise_parameter_is_required_error(:task_id)
68
+ project_id || raise_project_id_is_required_error
69
+
70
+ request = Web::Request.new(
71
+ connection,
72
+ :patch,
73
+ "#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}",
74
+ { params: query }
75
+ )
76
+ Web::SendRequest.new(request).perform
77
+ end
78
+
79
+ def list_user_tasks(query = {})
80
+ request = Web::Request.new(
81
+ connection,
82
+ :get,
83
+ "#{config.target_api_url}/user/tasks",
84
+ { params: query }
85
+ )
86
+ Web::SendRequest.new(request).perform
87
+ end
88
+
89
+ def edit_task_archived_status(task_id = nil, query = {})
90
+ task_id || raise_parameter_is_required_error(:task_id)
91
+
92
+ request = Web::Request.new(
93
+ connection,
94
+ :patch,
95
+ "#{config.target_api_url}/user/tasks/#{task_id}",
96
+ { params: query }
97
+ )
98
+ Web::SendRequest.new(request).perform
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,135 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module Teams
6
+ # -- For Enterprise mode only --
7
+
8
+ def add_team_to_project(query = {}, project_id = config.project_id)
9
+ enterprise_mode? || raise_only_for_enterprise_mode_error
10
+ project_id || raise_project_id_is_required_error
11
+
12
+ request = Web::Request.new(
13
+ connection,
14
+ :post,
15
+ "#{config.target_api_url}/projects/#{project_id}/teams",
16
+ { params: query }
17
+ )
18
+ Web::SendRequest.new(request).perform
19
+ end
20
+
21
+ def list_teams(query = {})
22
+ enterprise_mode? || raise_only_for_enterprise_mode_error
23
+
24
+ request = Web::Request.new(
25
+ connection,
26
+ :get,
27
+ "#{config.target_api_url}/teams",
28
+ { params: query }
29
+ )
30
+ Web::SendRequest.new(request).perform
31
+ end
32
+
33
+ def add_team(query = {})
34
+ enterprise_mode? || raise_only_for_enterprise_mode_error
35
+
36
+ request = Web::Request.new(
37
+ connection,
38
+ :post,
39
+ "#{config.target_api_url}/teams",
40
+ { params: query }
41
+ )
42
+ Web::SendRequest.new(request).perform
43
+ end
44
+
45
+ def get_team(team_id = nil, query = {})
46
+ enterprise_mode? || raise_only_for_enterprise_mode_error
47
+ team_id || raise_parameter_is_required_error(:team_id)
48
+
49
+ request = Web::Request.new(
50
+ connection,
51
+ :get,
52
+ "#{config.target_api_url}/teams/#{team_id}",
53
+ { params: query }
54
+ )
55
+ Web::SendRequest.new(request).perform
56
+ end
57
+
58
+ def delete_team(team_id = nil)
59
+ enterprise_mode? || raise_only_for_enterprise_mode_error
60
+ team_id || raise_parameter_is_required_error(:team_id)
61
+
62
+ request = Web::Request.new(
63
+ connection,
64
+ :delete,
65
+ "#{config.target_api_url}/teams/#{team_id}"
66
+ )
67
+ Web::SendRequest.new(request).perform
68
+ end
69
+
70
+ def edit_team(team_id = nil, query = {})
71
+ enterprise_mode? || raise_only_for_enterprise_mode_error
72
+ team_id || raise_parameter_is_required_error(:team_id)
73
+
74
+ request = Web::Request.new(
75
+ connection,
76
+ :patch,
77
+ "#{config.target_api_url}/teams/#{team_id}",
78
+ { params: query }
79
+ )
80
+ Web::SendRequest.new(request).perform
81
+ end
82
+
83
+ def team_members_list(team_id = nil, query = {})
84
+ enterprise_mode? || raise_only_for_enterprise_mode_error
85
+ team_id || raise_parameter_is_required_error(:team_id)
86
+
87
+ request = Web::Request.new(
88
+ connection,
89
+ :get,
90
+ "#{config.target_api_url}/teams/#{team_id}/members",
91
+ { params: query }
92
+ )
93
+ Web::SendRequest.new(request).perform
94
+ end
95
+
96
+ def add_team_members(team_id = nil, query = {})
97
+ enterprise_mode? || raise_only_for_enterprise_mode_error
98
+ team_id || raise_parameter_is_required_error(:team_id)
99
+
100
+ request = Web::Request.new(
101
+ connection,
102
+ :post,
103
+ "#{config.target_api_url}/teams/#{team_id}/members",
104
+ { params: query }
105
+ )
106
+ Web::SendRequest.new(request).perform
107
+ end
108
+
109
+ def delete_all_team_members(team_id = nil)
110
+ enterprise_mode? || raise_only_for_enterprise_mode_error
111
+ team_id || raise_parameter_is_required_error(:team_id)
112
+
113
+ request = Web::Request.new(
114
+ connection,
115
+ :delete,
116
+ "#{config.target_api_url}/teams/#{team_id}/members"
117
+ )
118
+ Web::SendRequest.new(request).perform
119
+ end
120
+
121
+ def delete_team_member(team_id = nil, member_id = nil)
122
+ enterprise_mode? || raise_only_for_enterprise_mode_error
123
+ team_id || raise_parameter_is_required_error(:team_id)
124
+ member_id || raise_parameter_is_required_error(:member_id)
125
+
126
+ request = Web::Request.new(
127
+ connection,
128
+ :delete,
129
+ "#{config.target_api_url}/teams/#{team_id}/members/#{member_id}"
130
+ )
131
+ Web::SendRequest.new(request).perform
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,131 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module TranslationMemory
6
+ def list_tms(query = {})
7
+ request = Web::Request.new(
8
+ connection,
9
+ :get,
10
+ "#{config.target_api_url}/tms",
11
+ { params: query }
12
+ )
13
+ Web::SendRequest.new(request).perform
14
+ end
15
+
16
+ def add_tm(query = {})
17
+ request = Web::Request.new(
18
+ connection,
19
+ :post,
20
+ "#{config.target_api_url}/tms",
21
+ { params: query }
22
+ )
23
+ Web::SendRequest.new(request).perform
24
+ end
25
+
26
+ def get_tm(tm_id = nil)
27
+ tm_id || raise_parameter_is_required_error(:tm_id)
28
+
29
+ request = Web::Request.new(
30
+ connection,
31
+ :get,
32
+ "#{config.target_api_url}/tms/#{tm_id}"
33
+ )
34
+ Web::SendRequest.new(request).perform
35
+ end
36
+
37
+ def delete_tm(tm_id = nil)
38
+ tm_id || raise_parameter_is_required_error(:tm_id)
39
+
40
+ request = Web::Request.new(
41
+ connection,
42
+ :delete,
43
+ "#{config.target_api_url}/tms/#{tm_id}"
44
+ )
45
+ Web::SendRequest.new(request).perform
46
+ end
47
+
48
+ def edit_tm(tm_id = nil, query = {})
49
+ tm_id || raise_parameter_is_required_error(:tm_id)
50
+
51
+ request = Web::Request.new(
52
+ connection,
53
+ :patch,
54
+ "#{config.target_api_url}/tms/#{tm_id}",
55
+ { params: query }
56
+ )
57
+ Web::SendRequest.new(request).perform
58
+ end
59
+
60
+ def clear_tm(tm_id = nil)
61
+ tm_id || raise_parameter_is_required_error(:tm_id)
62
+
63
+ request = Web::Request.new(
64
+ connection,
65
+ :delete,
66
+ "#{config.target_api_url}/tms/#{tm_id}/segments"
67
+ )
68
+ Web::SendRequest.new(request).perform
69
+ end
70
+
71
+ def export_tm(tm_id = nil)
72
+ tm_id || raise_parameter_is_required_error(:tm_id)
73
+
74
+ request = Web::Request.new(
75
+ connection,
76
+ :post,
77
+ "#{config.target_api_url}/tms/#{tm_id}/exports"
78
+ )
79
+ Web::SendRequest.new(request).perform
80
+ end
81
+
82
+ def check_tm_export_status(tm_id = nil, export_id = nil)
83
+ tm_id || raise_parameter_is_required_error(:tm_id)
84
+ export_id || raise_parameter_is_required_error(:export_id)
85
+
86
+ request = Web::Request.new(
87
+ connection,
88
+ :get,
89
+ "#{config.target_api_url}/tms/#{tm_id}/exports/#{export_id}"
90
+ )
91
+ Web::SendRequest.new(request).perform
92
+ end
93
+
94
+ def download_tm(tm_id = nil, export_id = nil, destination = nil)
95
+ tm_id || raise_parameter_is_required_error(:tm_id)
96
+ export_id || raise_parameter_is_required_error(:export_id)
97
+
98
+ request = Web::Request.new(
99
+ connection,
100
+ :get,
101
+ "#{config.target_api_url}/tms/#{tm_id}/exports/#{export_id}/download"
102
+ )
103
+ Web::SendRequest.new(request, destination).perform
104
+ end
105
+
106
+ def import_tm(tm_id = nil, query = {})
107
+ tm_id || raise_parameter_is_required_error(:tm_id)
108
+
109
+ request = Web::Request.new(
110
+ connection,
111
+ :post,
112
+ "#{config.target_api_url}/tms/#{tm_id}/imports",
113
+ { params: query }
114
+ )
115
+ Web::SendRequest.new(request).perform
116
+ end
117
+
118
+ def check_tm_import_status(tm_id = nil, import_id = nil)
119
+ tm_id || raise_parameter_is_required_error(:tm_id)
120
+ import_id || raise_parameter_is_required_error(:import_id)
121
+
122
+ request = Web::Request.new(
123
+ connection,
124
+ :get,
125
+ "#{config.target_api_url}/tms/#{tm_id}/imports/#{import_id}"
126
+ )
127
+ Web::SendRequest.new(request).perform
128
+ end
129
+ end
130
+ end
131
+ end