crowdin-api 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Storages do
4
+ describe 'Default endpoints' do
5
+ describe '#list_storages' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/storages")
8
+ list_storages = @crowdin.list_storages
9
+ expect(list_storages).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_storage' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/storages")
16
+ add_storage = @crowdin.add_storage('README.md')
17
+ expect(add_storage).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_storage' do
22
+ let(:storage_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/storages/#{storage_id}")
26
+ get_storage = @crowdin.get_storage(storage_id)
27
+ expect(get_storage).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_storage' do
32
+ let(:storage_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/storages/#{storage_id}")
36
+ delete_storage = @crowdin.delete_storage(storage_id)
37
+ expect(delete_storage).to eq(200)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::StringComments do
4
+ describe 'Default endpoints' do
5
+ describe '#list_string_comments' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/comments")
8
+ list_string_comments = @crowdin.list_string_comments({}, project_id)
9
+ expect(list_string_comments).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_string_comment' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/comments")
16
+ add_string_comment = @crowdin.add_string_comment({}, project_id)
17
+ expect(add_string_comment).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_string_comment' do
22
+ let(:string_comment_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/comments/#{string_comment_id}")
26
+ get_string_comment = @crowdin.get_string_comment(string_comment_id, project_id)
27
+ expect(get_string_comment).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_string_comment' do
32
+ let(:string_comment_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/comments/#{string_comment_id}")
36
+ delete_string_comment = @crowdin.delete_string_comment(string_comment_id, project_id)
37
+ expect(delete_string_comment).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_string_comment' do
42
+ let(:string_comment_id) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/comments/#{string_comment_id}")
46
+ edit_string_comment = @crowdin.edit_string_comment(string_comment_id, {}, project_id)
47
+ expect(edit_string_comment).to eq(200)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,141 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::StringTranslations do
4
+ describe 'Default endpoints' do
5
+ describe '#list_translation_approvals' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/approvals")
8
+ list_translation_approvals = @crowdin.list_translation_approvals({}, project_id)
9
+ expect(list_translation_approvals).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_approval' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/approvals")
16
+ add_approval = @crowdin.add_approval({}, project_id)
17
+ expect(add_approval).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_approval' do
22
+ let(:approval_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/approvals/#{approval_id}")
26
+ get_approval = @crowdin.get_approval(approval_id, project_id)
27
+ expect(get_approval).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#remove_approval' do
32
+ let(:approval_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/approvals/#{approval_id}")
36
+ remove_approval = @crowdin.remove_approval(approval_id, project_id)
37
+ expect(remove_approval).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#list_language_translations' do
42
+ let(:language_id) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/languages/#{language_id}/translations")
46
+ list_language_translations = @crowdin.list_language_translations(language_id, {}, project_id)
47
+ expect(list_language_translations).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#list_string_translations' do
52
+ it 'when request are valid', :default do
53
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations")
54
+ list_string_translations = @crowdin.list_string_translations({}, project_id)
55
+ expect(list_string_translations).to eq(200)
56
+ end
57
+ end
58
+
59
+ describe '#add_translation' do
60
+ it 'when request are valid', :default do
61
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations")
62
+ add_translation = @crowdin.add_translation({}, project_id)
63
+ expect(add_translation).to eq(200)
64
+ end
65
+ end
66
+
67
+ describe '#delete_string_translations' do
68
+ it 'when request are valid', :default do
69
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations")
70
+ delete_string_translations = @crowdin.delete_string_translations({}, project_id)
71
+ expect(delete_string_translations).to eq(200)
72
+ end
73
+ end
74
+
75
+ describe '#get_translation' do
76
+ let(:translation_id) { 1 }
77
+
78
+ it 'when request are valid', :default do
79
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/#{translation_id}")
80
+ get_translation = @crowdin.get_translation(translation_id, {}, project_id)
81
+ expect(get_translation).to eq(200)
82
+ end
83
+ end
84
+
85
+ describe '#restore_translation' do
86
+ let(:translation_id) { 1 }
87
+
88
+ it 'when request are valid', :default do
89
+ stub_request(:put, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/#{translation_id}")
90
+ restore_translation = @crowdin.restore_translation(translation_id, project_id)
91
+ expect(restore_translation).to eq(200)
92
+ end
93
+ end
94
+
95
+ describe '#delete_translation' do
96
+ let(:translation_id) { 1 }
97
+
98
+ it 'when request are valid', :default do
99
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/#{translation_id}")
100
+ delete_translation = @crowdin.delete_translation(translation_id, project_id)
101
+ expect(delete_translation).to eq(200)
102
+ end
103
+ end
104
+
105
+ describe '#list_translation_votes' do
106
+ it 'when request are valid', :default do
107
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/votes")
108
+ list_translation_votes = @crowdin.list_translation_votes({}, project_id)
109
+ expect(list_translation_votes).to eq(200)
110
+ end
111
+ end
112
+
113
+ describe '#add_vote' do
114
+ it 'when request are valid', :default do
115
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/votes")
116
+ add_vote = @crowdin.add_vote({}, project_id)
117
+ expect(add_vote).to eq(200)
118
+ end
119
+ end
120
+
121
+ describe '#get_vote' do
122
+ let(:vote_id) { 1 }
123
+
124
+ it 'when request are valid', :default do
125
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/votes/#{vote_id}")
126
+ get_vote = @crowdin.get_vote(vote_id, project_id)
127
+ expect(get_vote).to eq(200)
128
+ end
129
+ end
130
+
131
+ describe '#cancel_vote' do
132
+ let(:vote_id) { 1 }
133
+
134
+ it 'when request are valid', :default do
135
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/votes/#{vote_id}")
136
+ cancel_vote = @crowdin.cancel_vote(vote_id, project_id)
137
+ expect(cancel_vote).to eq(200)
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Tasks do
4
+ describe 'Default endpoints' do
5
+ describe '#list_tasks' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks")
8
+ list_tasks = @crowdin.list_tasks({}, project_id)
9
+ expect(list_tasks).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_task' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks")
16
+ add_task = @crowdin.add_task({}, project_id)
17
+ expect(add_task).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#export_task_strings' do
22
+ let(:task_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks/#{task_id}/exports")
26
+ export_task_strings = @crowdin.export_task_strings(task_id, nil, project_id)
27
+ expect(export_task_strings).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#get_task' do
32
+ let(:task_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks/#{task_id}")
36
+ get_task = @crowdin.get_task(task_id, project_id)
37
+ expect(get_task).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#delete_task' do
42
+ let(:task_id) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks/#{task_id}")
46
+ delete_task = @crowdin.delete_task(task_id, project_id)
47
+ expect(delete_task).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#edit_task' do
52
+ let(:task_id) { 1 }
53
+
54
+ it 'when request are valid', :default do
55
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks/#{task_id}")
56
+ edit_task = @crowdin.edit_task(task_id, {}, project_id)
57
+ expect(edit_task).to eq(200)
58
+ end
59
+ end
60
+
61
+ describe '#list_user_tasks' do
62
+ it 'when request are valid', :default do
63
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/user/tasks")
64
+ list_user_tasks = @crowdin.list_user_tasks({})
65
+ expect(list_user_tasks).to eq(200)
66
+ end
67
+ end
68
+
69
+ describe '#edit_task_archived_status' do
70
+ let(:task_id) { 1 }
71
+
72
+ it 'when request are valid', :default do
73
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/user/tasks/#{task_id}")
74
+ edit_task_archived_status = @crowdin.edit_task_archived_status(task_id, {})
75
+ expect(edit_task_archived_status).to eq(200)
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Teams do
4
+ describe 'Enterprise endpoints' do
5
+ describe '#add_team_to_project' do
6
+ it 'when request are valid', :enterprise do
7
+ stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/projects/#{project_id}/teams")
8
+ add_team_to_project = @crowdin.add_team_to_project({}, project_id)
9
+ expect(add_team_to_project).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#list_teams' do
14
+ it 'when request are valid', :enterprise do
15
+ stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/teams")
16
+ list_teams = @crowdin.list_teams({})
17
+ expect(list_teams).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#add_team' do
22
+ it 'when request are valid', :enterprise do
23
+ stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/teams")
24
+ add_team = @crowdin.add_team({})
25
+ expect(add_team).to eq(200)
26
+ end
27
+ end
28
+
29
+ describe '#get_team' do
30
+ let(:team_id) { 1 }
31
+
32
+ it 'when request are valid', :enterprise do
33
+ stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}")
34
+ get_team = @crowdin.get_team(team_id, {})
35
+ expect(get_team).to eq(200)
36
+ end
37
+ end
38
+
39
+ describe '#delete_team' do
40
+ let(:team_id) { 1 }
41
+
42
+ it 'when request are valid', :enterprise do
43
+ stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}")
44
+ delete_team = @crowdin.delete_team(team_id)
45
+ expect(delete_team).to eq(200)
46
+ end
47
+ end
48
+
49
+ describe '#edit_team' do
50
+ let(:team_id) { 1 }
51
+
52
+ it 'when request are valid', :enterprise do
53
+ stub_request(:patch, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}")
54
+ edit_team = @crowdin.edit_team(team_id, {})
55
+ expect(edit_team).to eq(200)
56
+ end
57
+ end
58
+
59
+ describe '#team_members_list' do
60
+ let(:team_id) { 1 }
61
+
62
+ it 'when request are valid', :enterprise do
63
+ stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}/members")
64
+ team_members_list = @crowdin.team_members_list(team_id, {})
65
+ expect(team_members_list).to eq(200)
66
+ end
67
+ end
68
+
69
+ describe '#add_team_members' do
70
+ let(:team_id) { 1 }
71
+
72
+ it 'when request are valid', :enterprise do
73
+ stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}/members")
74
+ add_team_members = @crowdin.add_team_members(team_id, {})
75
+ expect(add_team_members).to eq(200)
76
+ end
77
+ end
78
+
79
+ describe '#delete_all_team_members' do
80
+ let(:team_id) { 1 }
81
+
82
+ it 'when request are valid', :enterprise do
83
+ stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}/members")
84
+ delete_all_team_members = @crowdin.delete_all_team_members(team_id)
85
+ expect(delete_all_team_members).to eq(200)
86
+ end
87
+ end
88
+
89
+ describe '#delete_team_member' do
90
+ let(:team_id) { 1 }
91
+ let(:member_id) { 1 }
92
+
93
+ it 'when request are valid', :enterprise do
94
+ stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}/members/#{member_id}")
95
+ delete_team_member = @crowdin.delete_team_member(team_id, member_id)
96
+ expect(delete_team_member).to eq(200)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::TranslationMemory do
4
+ describe 'Default endpoints' do
5
+ describe '#list_tms' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms")
8
+ list_tms = @crowdin.list_tms
9
+ expect(list_tms).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_tm' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/tms")
16
+ add_tm = @crowdin.add_tm
17
+ expect(add_tm).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_tm' do
22
+ let(:tm_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}")
26
+ get_tm = @crowdin.get_tm(tm_id)
27
+ expect(get_tm).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_tm' do
32
+ let(:tm_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}")
36
+ delete_tm = @crowdin.delete_tm(tm_id)
37
+ expect(delete_tm).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_tm' do
42
+ let(:tm_id) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}")
46
+ edit_tm = @crowdin.edit_tm(tm_id)
47
+ expect(edit_tm).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#clear_tm' do
52
+ let(:tm_id) { 1 }
53
+
54
+ it 'when request are valid', :default do
55
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/segments")
56
+ clear_tm = @crowdin.clear_tm(tm_id)
57
+ expect(clear_tm).to eq(200)
58
+ end
59
+ end
60
+
61
+ describe '#export_tm' do
62
+ let(:tm_id) { 1 }
63
+
64
+ it 'when request are valid', :default do
65
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/exports")
66
+ export_tm = @crowdin.export_tm(tm_id)
67
+ expect(export_tm).to eq(200)
68
+ end
69
+ end
70
+
71
+ describe '#check_tm_export_status' do
72
+ let(:tm_id) { 1 }
73
+ let(:export_id) { 1 }
74
+
75
+ it 'when request are valid', :default do
76
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/exports/#{export_id}")
77
+ check_tm_export_status = @crowdin.check_tm_export_status(tm_id, export_id)
78
+ expect(check_tm_export_status).to eq(200)
79
+ end
80
+ end
81
+
82
+ describe '#download_tm' do
83
+ let(:tm_id) { 1 }
84
+ let(:export_id) { 1 }
85
+
86
+ it 'when request are valid', :default do
87
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/exports/#{export_id}/download")
88
+ download_tm = @crowdin.download_tm(tm_id, export_id)
89
+ expect(download_tm).to eq(200)
90
+ end
91
+ end
92
+
93
+ describe '#import_tm' do
94
+ let(:tm_id) { 1 }
95
+
96
+ it 'when request are valid', :default do
97
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/imports")
98
+ import_tm = @crowdin.import_tm(tm_id)
99
+ expect(import_tm).to eq(200)
100
+ end
101
+ end
102
+
103
+ describe '#check_tm_import_status' do
104
+ let(:tm_id) { 1 }
105
+ let(:import_id) { 1 }
106
+
107
+ it 'when request are valid', :default do
108
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/imports/#{import_id}")
109
+ check_tm_import_status = @crowdin.check_tm_import_status(tm_id, import_id)
110
+ expect(check_tm_import_status).to eq(200)
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::TranslationStatus do
4
+ describe 'Default endpoints' do
5
+ describe '#get_branch_progress' do
6
+ let(:branch_id) { 1 }
7
+
8
+ it 'when request are valid', :default do
9
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/branches/#{branch_id}/languages/progress")
10
+ get_branch_progress = @crowdin.get_branch_progress(branch_id, {}, project_id)
11
+ expect(get_branch_progress).to eq(200)
12
+ end
13
+ end
14
+
15
+ describe '#get_directory_progress' do
16
+ let(:directory_id) { 1 }
17
+
18
+ it 'when request are valid', :default do
19
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories/#{directory_id}/languages/progress")
20
+ get_directory_progress = @crowdin.get_directory_progress(directory_id, {}, project_id)
21
+ expect(get_directory_progress).to eq(200)
22
+ end
23
+ end
24
+
25
+ describe '#get_file_progress' do
26
+ let(:file_id) { 1 }
27
+
28
+ it 'when request are valid', :default do
29
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}/languages/progress")
30
+ get_file_progress = @crowdin.get_file_progress(file_id, {}, project_id)
31
+ expect(get_file_progress).to eq(200)
32
+ end
33
+ end
34
+
35
+ describe '#get_language_progress' do
36
+ let(:language_id) { 1 }
37
+
38
+ it 'when request are valid', :default do
39
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/languages/#{language_id}/progress")
40
+ get_language_progress = @crowdin.get_language_progress(language_id, {}, project_id)
41
+ expect(get_language_progress).to eq(200)
42
+ end
43
+ end
44
+
45
+ describe '#get_project_progress' do
46
+ it 'when request are valid', :default do
47
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/languages/progress")
48
+ get_project_progress = @crowdin.get_project_progress({}, project_id)
49
+ expect(get_project_progress).to eq(200)
50
+ end
51
+ end
52
+
53
+ describe '#get_qa_progress' do
54
+ it 'when request are valid', :default do
55
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/qa-checks")
56
+ get_qa_progress = @crowdin.get_qa_progress({}, project_id)
57
+ expect(get_qa_progress).to eq(200)
58
+ end
59
+ end
60
+ end
61
+ end