ruby-lokalise-api 5.0.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +7 -5
  4. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/base_request.rb +4 -4
  5. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/client.rb +24 -24
  6. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/base.rb +10 -10
  7. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/branch.rb +1 -1
  8. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/contributor.rb +1 -1
  9. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/custom_translation_status.rb +1 -1
  10. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/file.rb +1 -1
  11. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key.rb +2 -2
  12. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key_comment.rb +1 -1
  13. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/order.rb +1 -1
  14. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/payment_card.rb +1 -1
  15. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project.rb +1 -1
  16. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_comment.rb +1 -1
  17. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_language.rb +1 -1
  18. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/queued_process.rb +1 -1
  19. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/screenshot.rb +1 -1
  20. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/segment.rb +1 -1
  21. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/snapshot.rb +1 -1
  22. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/system_language.rb +1 -1
  23. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/task.rb +1 -1
  24. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team.rb +1 -1
  25. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user.rb +1 -1
  26. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user_group.rb +1 -1
  27. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation.rb +1 -1
  28. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation_provider.rb +1 -1
  29. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/webhook.rb +1 -1
  30. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/connection.rb +2 -2
  31. data/lib/ruby_lokalise_api/data/attributes.yml +235 -0
  32. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/error.rb +14 -14
  33. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/json_handler.rb +1 -1
  34. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/auth.rb +2 -2
  35. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/connection.rb +2 -2
  36. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/request.rb +3 -3
  37. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2_client.rb +1 -1
  38. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/request.rb +3 -3
  39. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/base.rb +16 -8
  40. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/branch.rb +1 -1
  41. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/contributor.rb +1 -1
  42. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/custom_translation_status.rb +1 -1
  43. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/file.rb +2 -2
  44. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key.rb +1 -1
  45. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key_comment.rb +1 -1
  46. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/order.rb +1 -1
  47. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/payment_card.rb +1 -1
  48. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project.rb +1 -1
  49. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_comment.rb +1 -1
  50. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_language.rb +1 -1
  51. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/queued_process.rb +1 -1
  52. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/screenshot.rb +1 -1
  53. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/segment.rb +1 -1
  54. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/snapshot.rb +2 -2
  55. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/system_language.rb +1 -1
  56. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/task.rb +1 -1
  57. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team.rb +1 -1
  58. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user.rb +1 -1
  59. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_billing_details.rb +1 -1
  60. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_group.rb +1 -1
  61. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation.rb +1 -1
  62. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation_provider.rb +1 -1
  63. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/webhook.rb +1 -1
  64. data/lib/ruby_lokalise_api/rest/branches.rb +69 -0
  65. data/lib/ruby_lokalise_api/rest/comments.rb +61 -0
  66. data/lib/ruby_lokalise_api/rest/contributors.rb +58 -0
  67. data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +67 -0
  68. data/lib/ruby_lokalise_api/rest/files.rb +49 -0
  69. data/lib/ruby_lokalise_api/rest/keys.rb +79 -0
  70. data/lib/ruby_lokalise_api/rest/languages.rb +67 -0
  71. data/lib/ruby_lokalise_api/rest/orders.rb +37 -0
  72. data/lib/ruby_lokalise_api/rest/payment_cards.rb +43 -0
  73. data/lib/ruby_lokalise_api/rest/projects.rb +62 -0
  74. data/lib/ruby_lokalise_api/rest/queued_processes.rb +28 -0
  75. data/lib/ruby_lokalise_api/rest/screenshots.rb +58 -0
  76. data/lib/ruby_lokalise_api/rest/segments.rb +45 -0
  77. data/lib/ruby_lokalise_api/rest/snapshots.rb +47 -0
  78. data/lib/ruby_lokalise_api/rest/tasks.rb +58 -0
  79. data/lib/ruby_lokalise_api/rest/team_user_billing_details.rb +36 -0
  80. data/lib/ruby_lokalise_api/rest/team_user_groups.rb +109 -0
  81. data/lib/ruby_lokalise_api/rest/team_users.rb +48 -0
  82. data/lib/ruby_lokalise_api/rest/teams.rb +16 -0
  83. data/lib/ruby_lokalise_api/rest/translation_providers.rb +27 -0
  84. data/lib/ruby_lokalise_api/rest/translations.rb +39 -0
  85. data/lib/ruby_lokalise_api/rest/webhooks.rb +69 -0
  86. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/attribute_helpers.rb +7 -7
  87. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/endpoint_helpers.rb +1 -1
  88. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/string_utils.rb +1 -1
  89. data/lib/ruby_lokalise_api/version.rb +5 -0
  90. data/lib/ruby_lokalise_api.rb +50 -0
  91. data/ruby-lokalise-api.gemspec +8 -7
  92. metadata +125 -157
  93. data/lib/ruby-lokalise-api/data/attributes.json +0 -259
  94. data/lib/ruby-lokalise-api/rest/branches.rb +0 -67
  95. data/lib/ruby-lokalise-api/rest/comments.rb +0 -59
  96. data/lib/ruby-lokalise-api/rest/contributors.rb +0 -56
  97. data/lib/ruby-lokalise-api/rest/custom_translation_statuses.rb +0 -65
  98. data/lib/ruby-lokalise-api/rest/files.rb +0 -36
  99. data/lib/ruby-lokalise-api/rest/keys.rb +0 -77
  100. data/lib/ruby-lokalise-api/rest/languages.rb +0 -65
  101. data/lib/ruby-lokalise-api/rest/orders.rb +0 -35
  102. data/lib/ruby-lokalise-api/rest/payment_cards.rb +0 -41
  103. data/lib/ruby-lokalise-api/rest/projects.rb +0 -60
  104. data/lib/ruby-lokalise-api/rest/queued_processes.rb +0 -26
  105. data/lib/ruby-lokalise-api/rest/screenshots.rb +0 -56
  106. data/lib/ruby-lokalise-api/rest/segments.rb +0 -43
  107. data/lib/ruby-lokalise-api/rest/snapshots.rb +0 -45
  108. data/lib/ruby-lokalise-api/rest/tasks.rb +0 -56
  109. data/lib/ruby-lokalise-api/rest/team_user_billing_details.rb +0 -34
  110. data/lib/ruby-lokalise-api/rest/team_user_group.rb +0 -107
  111. data/lib/ruby-lokalise-api/rest/team_users.rb +0 -46
  112. data/lib/ruby-lokalise-api/rest/teams.rb +0 -14
  113. data/lib/ruby-lokalise-api/rest/translation_providers.rb +0 -25
  114. data/lib/ruby-lokalise-api/rest/translations.rb +0 -37
  115. data/lib/ruby-lokalise-api/rest/webhooks.rb +0 -67
  116. data/lib/ruby-lokalise-api/version.rb +0 -5
  117. data/lib/ruby-lokalise-api.rb +0 -111
  118. data/spec/lib/ruby-lokalise-api/connection_spec.rb +0 -68
  119. data/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb +0 -81
  120. data/spec/lib/ruby-lokalise-api/error_spec.rb +0 -41
  121. data/spec/lib/ruby-lokalise-api/oauth2/auth_spec.rb +0 -73
  122. data/spec/lib/ruby-lokalise-api/rest/branches_spec.rb +0 -140
  123. data/spec/lib/ruby-lokalise-api/rest/comments_spec.rb +0 -118
  124. data/spec/lib/ruby-lokalise-api/rest/contributors_spec.rb +0 -132
  125. data/spec/lib/ruby-lokalise-api/rest/custom_translation_statuses_spec.rb +0 -131
  126. data/spec/lib/ruby-lokalise-api/rest/files_spec.rb +0 -66
  127. data/spec/lib/ruby-lokalise-api/rest/keys_spec.rb +0 -199
  128. data/spec/lib/ruby-lokalise-api/rest/languages_spec.rb +0 -134
  129. data/spec/lib/ruby-lokalise-api/rest/orders_spec.rb +0 -113
  130. data/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb +0 -92
  131. data/spec/lib/ruby-lokalise-api/rest/projects_spec.rb +0 -150
  132. data/spec/lib/ruby-lokalise-api/rest/queued_processes_spec.rb +0 -57
  133. data/spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb +0 -127
  134. data/spec/lib/ruby-lokalise-api/rest/segments_spec.rb +0 -106
  135. data/spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb +0 -117
  136. data/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb +0 -145
  137. data/spec/lib/ruby-lokalise-api/rest/team_user_billing_details_spec.rb +0 -48
  138. data/spec/lib/ruby-lokalise-api/rest/team_user_groups_spec.rb +0 -278
  139. data/spec/lib/ruby-lokalise-api/rest/team_users_spec.rb +0 -95
  140. data/spec/lib/ruby-lokalise-api/rest/teams_spec.rb +0 -25
  141. data/spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb +0 -48
  142. data/spec/lib/ruby-lokalise-api/rest/translations_spec.rb +0 -118
  143. data/spec/lib/ruby-lokalise-api/rest/webhooks_spec.rb +0 -126
  144. data/spec/lib/ruby-lokalise-api_spec.rb +0 -47
  145. data/spec/spec_helper.rb +0 -22
  146. data/spec/support/test_client.rb +0 -15
  147. data/spec/support/vcr.rb +0 -15
@@ -1,145 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:key_id) { 15_571_976 }
6
- let(:task_id) { 4387 }
7
-
8
- describe '#tasks' do
9
- it 'returns all tasks' do
10
- tasks = VCR.use_cassette('all_tasks') do
11
- test_client.tasks project_id
12
- end.collection
13
-
14
- expect(tasks.count).to eq(3)
15
- end
16
-
17
- it 'supports pagination' do
18
- tasks = VCR.use_cassette('all_tasks_pagination') do
19
- test_client.tasks project_id, limit: 2, page: 2
20
- end
21
-
22
- expect(tasks.collection.count).to eq(1)
23
- expect(tasks.total_results).to eq(3)
24
- expect(tasks.total_pages).to eq(2)
25
- expect(tasks.results_per_page).to eq(2)
26
- expect(tasks.current_page).to eq(2)
27
- end
28
- end
29
-
30
- specify '#task' do
31
- task = VCR.use_cassette('task') do
32
- test_client.task project_id, '11925'
33
- end
34
-
35
- expect(task.task_id).to eq(11_925)
36
- expect(task.title).to eq('node updated')
37
- expect(task.description).to eq('')
38
- expect(task.status).to eq('completed')
39
- expect(task.progress).to eq(0)
40
- expect(task.due_date).to eq(nil)
41
- expect(task.due_date_timestamp).to eq(nil)
42
- expect(task.keys_count).to eq(16)
43
- expect(task.words_count).to eq(275)
44
- expect(task.created_at).to eq('2019-05-13 16:15:26 (Etc/UTC)')
45
- expect(task.created_at_timestamp).to eq(1_557_764_126)
46
- expect(task.created_by).to eq(20_181)
47
- expect(task.created_by_email).to eq('bodrovis@protonmail.com')
48
- expect(task.can_be_parent).to eq(false)
49
- expect(task.task_type).to eq('review')
50
- expect(task.parent_task_id).to eq(nil)
51
- expect(task.closing_tags).to eq([])
52
- expect(task.languages.first['language_iso']).to eq('sq')
53
- expect(task.auto_close_languages).to eq(true)
54
- expect(task.auto_close_task).to eq(true)
55
- expect(task.auto_close_items).to eq(true)
56
- expect(task.completed_by).to eq(20_181)
57
- expect(task.completed_by_email).to eq('bodrovis@protonmail.com')
58
- expect(task.completed_at).to eq('2019-10-01 11:09:12 (Etc/UTC)')
59
- expect(task.completed_at_timestamp).to eq(1_569_928_152)
60
- expect(task.do_lock_translations).to eq(false)
61
- expect(task.custom_translation_status_ids).to eq([])
62
- end
63
-
64
- specify '#reload_data' do
65
- task = VCR.use_cassette('task') do
66
- test_client.task project_id, '11925'
67
- end
68
-
69
- reloaded_task = VCR.use_cassette('task') do
70
- task.reload_data
71
- end
72
-
73
- expect(reloaded_task.task_id).to eq(task.task_id)
74
- end
75
-
76
- specify '#create_task' do
77
- task = VCR.use_cassette('create_task') do
78
- test_client.create_task project_id, title: 'another rspec key',
79
- keys: [key_id],
80
- languages: [
81
- {
82
- language_iso: 'ru',
83
- users: ['20181']
84
- }
85
- ]
86
- end
87
-
88
- expect(task.title).to eq('another rspec key')
89
- expect(task.languages.first['language_iso']).to eq('ru')
90
- end
91
-
92
- specify '#update_task' do
93
- task = VCR.use_cassette('update_task') do
94
- test_client.update_task project_id, task_id, description: 'desc here', auto_close_task: true
95
- end
96
-
97
- expect(task.task_id).to eq(task_id)
98
- expect(task.description).to eq('desc here')
99
- expect(task.auto_close_task).to eq(true)
100
- end
101
-
102
- specify '#destroy_task' do
103
- response = VCR.use_cassette('delete_task') do
104
- test_client.destroy_task project_id, task_id
105
- end
106
- expect(response['project_id']).to eq(project_id)
107
- expect(response['task_deleted']).to eq(true)
108
- end
109
-
110
- context 'when task methods are chained' do
111
- it 'supports update and destroy' do
112
- task = VCR.use_cassette('create_another_task') do
113
- test_client.create_task project_id, title: 'chained',
114
- keys: [key_id],
115
- languages: [
116
- {
117
- language_iso: 'ru',
118
- users: ['20181']
119
- }
120
- ]
121
- end
122
-
123
- expect(task.client.token).to eq(test_client.token)
124
- expect(task.title).to eq('chained')
125
-
126
- path = task.path
127
-
128
- updated_task = VCR.use_cassette('update_task_chained') do
129
- task.update title: 'updated!'
130
- end
131
-
132
- expect(updated_task.client.token).to eq(test_client.token)
133
- expect(updated_task.title).to eq('updated!')
134
- expect(updated_task.task_id).to eq(task.task_id)
135
- expect(updated_task.path).to eq(path)
136
-
137
- delete_response = VCR.use_cassette('delete_task_chained') do
138
- updated_task.destroy
139
- end
140
-
141
- expect(delete_response['project_id']).to eq(project_id)
142
- expect(delete_response['task_deleted']).to eq(true)
143
- end
144
- end
145
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:team_id) { 176_692 }
5
- let(:team_id2) { 273_879 }
6
-
7
- specify '#team_user_billing_details' do
8
- details = VCR.use_cassette('team_user_billing_details') do
9
- test_client.team_user_billing_details team_id
10
- end
11
-
12
- expect(details.billing_email).to eq('hello@example.com')
13
- expect(details.country_code).to eq('LV')
14
- expect(details.zip).to eq('LV-6543')
15
- expect(details.state_code).to eq('')
16
- expect(details.address1).to eq('Sample line 1')
17
- expect(details.address2).to eq('Sample line 2')
18
- expect(details.city).to eq('Riga')
19
- expect(details.phone).to eq('+371123456')
20
- expect(details.company).to eq('Self-employed')
21
- expect(details.vatnumber).to eq('123')
22
- end
23
-
24
- specify '#create_team_user_billing_details' do
25
- details = VCR.use_cassette('create_team_user_billing_details') do
26
- test_client.create_team_user_billing_details team_id2, billing_email: 'ruby@example.com',
27
- country_code: 'LV',
28
- zip: 'LV-1111'
29
- end
30
-
31
- expect(details.billing_email).to eq('ruby@example.com')
32
- expect(details.country_code).to eq('LV')
33
- expect(details.address1).to eq('')
34
- end
35
-
36
- specify '#update_team_user_billing_details' do
37
- details = VCR.use_cassette('update_team_user_billing_details') do
38
- test_client.update_team_user_billing_details team_id2, billing_email: 'ruby_rspec@example.com',
39
- country_code: 'LV',
40
- zip: 'LV-1111',
41
- address1: 'Addr line 1'
42
- end
43
-
44
- expect(details.billing_email).to eq('ruby_rspec@example.com')
45
- expect(details.country_code).to eq('LV')
46
- expect(details.address1).to eq('Addr line 1')
47
- end
48
- end
@@ -1,278 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:team_id) { 176_692 }
5
- let(:group_id) { 515 }
6
- let(:second_group_id) { 690 }
7
- let(:third_group_id) { 689 }
8
- let(:project_id) { '605317925c13e4ecb36a79.94825279' }
9
- let(:another_project_id) { '446952185c01a12b4d0b45.76217122' }
10
- let(:user_id) { 35_554 }
11
-
12
- describe '#team_user_groups' do
13
- it 'returns all team_user_groups' do
14
- team_user_groups = VCR.use_cassette('team_user_groups') do
15
- test_client.team_user_groups team_id
16
- end
17
-
18
- expect(team_user_groups.collection.count).to eq(2)
19
- expect(team_user_groups.team_id).to eq(team_id)
20
- end
21
-
22
- it 'supports pagination' do
23
- team_users = VCR.use_cassette('team_user_groups_pagination') do
24
- test_client.team_user_groups team_id, limit: 1, page: 2
25
- end
26
-
27
- expect(team_users.collection.count).to eq(1)
28
- expect(team_users.total_results).to eq(2)
29
- expect(team_users.total_pages).to eq(2)
30
- expect(team_users.results_per_page).to eq(1)
31
- expect(team_users.current_page).to eq(2)
32
- end
33
- end
34
-
35
- specify '#team_user_group' do
36
- group = VCR.use_cassette('team_user_group') do
37
- test_client.team_user_group team_id, group_id
38
- end
39
-
40
- expect(group.group_id).to eq(group_id)
41
- expect(group.name).to eq('Demo')
42
- expect(group.permissions['is_admin']).to eq(true)
43
- expect(group.created_at).to eq('2019-03-19 19:53:04 (Etc/UTC)')
44
- expect(group.created_at_timestamp).to eq(1_553_025_184)
45
- expect(group.team_id).to eq(team_id)
46
- expect(group.projects.first).to eq('803826145ba90b42d5d860.46800099')
47
- expect(group.members[1]).to eq(25_753)
48
-
49
- reloaded_group = VCR.use_cassette('team_user_group') do
50
- group.reload_data
51
- end
52
- expect(reloaded_group.group_id).to eq(group.group_id)
53
- end
54
-
55
- specify '#create_team_user_group' do
56
- group = VCR.use_cassette('create_team_user_group') do
57
- test_client.create_team_user_group team_id, name: 'RSpec group',
58
- is_reviewer: false,
59
- is_admin: false,
60
- languages: {
61
- reference: [],
62
- contributable: [640]
63
- }
64
- end
65
-
66
- expect(group.name).to eq('RSpec group')
67
- expect(group.team_id).to eq(team_id)
68
-
69
- reloaded_group = VCR.use_cassette('created_team_user_group') do
70
- group.reload_data
71
- end
72
- expect(reloaded_group.group_id).to eq(group.group_id)
73
- end
74
-
75
- specify '#update_team_user_group' do
76
- group = VCR.use_cassette('update_team_user_group') do
77
- test_client.update_team_user_group team_id, second_group_id,
78
- name: 'updated rspec', is_admin: true,
79
- is_reviewer: true
80
- end
81
-
82
- expect(group.name).to eq('updated rspec')
83
- expect(group.team_id).to eq(team_id)
84
- expect(group.permissions['is_admin']).to eq(true)
85
- expect(group.permissions['is_reviewer']).to eq(true)
86
- end
87
-
88
- specify '#destroy_team_user_group' do
89
- response = VCR.use_cassette('destroy_team_user_group') do
90
- test_client.destroy_team_user_group team_id, second_group_id
91
- end
92
- expect(response['team_id']).to eq(team_id)
93
- expect(response['group_deleted']).to eq(true)
94
- end
95
-
96
- specify '#add_projects_to_group' do
97
- group = VCR.use_cassette('add_projects_to_group') do
98
- test_client.add_projects_to_group team_id, third_group_id, project_id
99
- end
100
-
101
- expect(group.team_id).to eq(team_id)
102
- expect(group.group_id).to eq(third_group_id)
103
- expect(group.projects).to include(project_id)
104
-
105
- reloaded_group = VCR.use_cassette('another_team_user_group') do
106
- group.reload_data
107
- end
108
- expect(reloaded_group.group_id).to eq(group.group_id)
109
-
110
- group = VCR.use_cassette('add_projects_to_group') do
111
- group.add_projects projects: [project_id]
112
- end
113
- expect(group.group_id).to eq(third_group_id)
114
- end
115
-
116
- specify '#remove_projects_from_group' do
117
- group = VCR.use_cassette('remove_projects_from_group') do
118
- test_client.remove_projects_from_group team_id, third_group_id, another_project_id
119
- end
120
-
121
- expect(group.group_id).to eq(third_group_id)
122
- expect(group.team_id).to eq(team_id)
123
- expect(group.projects).to be_empty
124
-
125
- reloaded_group = VCR.use_cassette('another_team_user_group') do
126
- group.reload_data
127
- end
128
- expect(reloaded_group.group_id).to eq(group.group_id)
129
-
130
- group = VCR.use_cassette('remove_projects_from_group') do
131
- group.remove_projects projects: [project_id]
132
- end
133
- expect(group.group_id).to eq(third_group_id)
134
- end
135
-
136
- specify '#add_users_to_group' do
137
- group = VCR.use_cassette('add_users_to_group') do
138
- test_client.add_users_to_group team_id, third_group_id, user_id
139
- end
140
-
141
- expect(group.team_id).to eq(team_id)
142
- expect(group.group_id).to eq(third_group_id)
143
- expect(group.members).to include(user_id)
144
-
145
- reloaded_group = VCR.use_cassette('another_team_user_group') do
146
- group.reload_data
147
- end
148
- expect(reloaded_group.group_id).to eq(group.group_id)
149
-
150
- group = VCR.use_cassette('add_users_to_group') do
151
- group.add_users users: [user_id]
152
- end
153
- end
154
-
155
- specify '#remove_users_from_group' do
156
- group = VCR.use_cassette('remove_users_from_group') do
157
- test_client.remove_users_from_group team_id, third_group_id, user_id
158
- end
159
-
160
- expect(group.group_id).to eq(third_group_id)
161
- expect(group.team_id).to eq(team_id)
162
- expect(group.members).to be_empty
163
-
164
- reloaded_group = VCR.use_cassette('another_team_user_group') do
165
- group.reload_data
166
- end
167
- expect(reloaded_group.group_id).to eq(group.group_id)
168
-
169
- group = VCR.use_cassette('remove_users_from_group') do
170
- group.remove_users users: [user_id]
171
- end
172
- end
173
-
174
- context 'when team user group methods are chained' do
175
- it 'supports update and destroy' do
176
- group = VCR.use_cassette('another_team_user_group') do
177
- test_client.team_user_group team_id, third_group_id
178
- end
179
-
180
- expect(group.group_id).to eq(third_group_id)
181
-
182
- group = VCR.use_cassette('update_another_team_user_group') do
183
- group.update name: 'another group updated', is_admin: true, is_reviewer: true
184
- end
185
-
186
- expect(group.group_id).to eq(third_group_id)
187
- expect(group.permissions['is_admin']).to eq(true)
188
- expect(group.name).to eq('another group updated')
189
-
190
- response = VCR.use_cassette('destroy_another_team_user_group') do
191
- group.destroy
192
- end
193
-
194
- expect(response['team_id']).to eq(team_id)
195
- expect(response['group_deleted']).to eq(true)
196
- end
197
-
198
- it 'supports project management' do
199
- group = VCR.use_cassette('team_user_group') do
200
- test_client.team_user_group team_id, group_id
201
- end
202
-
203
- group = VCR.use_cassette('add_project_to_group_chained') do
204
- group.add_projects(projects: [another_project_id])
205
- end
206
-
207
- expect(group.team_id).to eq(team_id)
208
- expect(group.group_id).to eq(group_id)
209
- expect(group.projects).to include(another_project_id)
210
-
211
- group = VCR.use_cassette('add_project_to_group_chained') do
212
- group.add_projects(projects: [another_project_id])
213
- end
214
-
215
- reloaded_group = VCR.use_cassette('team_user_group') do
216
- group.reload_data
217
- end
218
- expect(reloaded_group.group_id).to eq(group.group_id)
219
-
220
- group = VCR.use_cassette('remove_project_from_group_chained') do
221
- group.remove_projects(projects: [another_project_id])
222
- end
223
-
224
- expect(group.team_id).to eq(team_id)
225
- expect(group.group_id).to eq(group_id)
226
- expect(group.projects).not_to include(another_project_id)
227
-
228
- group = VCR.use_cassette('remove_project_from_group_chained') do
229
- group.remove_projects(projects: [another_project_id])
230
- end
231
-
232
- reloaded_group = VCR.use_cassette('team_user_group') do
233
- group.reload_data
234
- end
235
- expect(reloaded_group.group_id).to eq(group.group_id)
236
- end
237
-
238
- it 'supports users management' do
239
- group = VCR.use_cassette('team_user_group') do
240
- test_client.team_user_group team_id, group_id
241
- end
242
-
243
- group = VCR.use_cassette('add_user_to_group_chained') do
244
- group.add_users(users: [user_id])
245
- end
246
-
247
- expect(group.team_id).to eq(team_id)
248
- expect(group.group_id).to eq(group_id)
249
- expect(group.members).to include(user_id)
250
-
251
- group = VCR.use_cassette('add_user_to_group_chained') do
252
- group.add_users(users: [user_id])
253
- end
254
-
255
- reloaded_group = VCR.use_cassette('team_user_group') do
256
- group.reload_data
257
- end
258
- expect(reloaded_group.group_id).to eq(group.group_id)
259
-
260
- group = VCR.use_cassette('remove_user_from_group_chained') do
261
- group.remove_users(users: [user_id])
262
- end
263
-
264
- expect(group.team_id).to eq(team_id)
265
- expect(group.group_id).to eq(group_id)
266
- expect(group.members).not_to include(user_id)
267
-
268
- group = VCR.use_cassette('remove_user_from_group_chained') do
269
- group.remove_users(users: [user_id])
270
- end
271
-
272
- reloaded_group = VCR.use_cassette('team_user_group') do
273
- group.reload_data
274
- end
275
- expect(reloaded_group.group_id).to eq(group.group_id)
276
- end
277
- end
278
- end
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:team_id) { 176_692 }
5
- let(:team_user_id) { 25_953 }
6
- let(:another_user_id) { 26_265 }
7
-
8
- describe '#team_users' do
9
- it 'returns all team_users' do
10
- team_users = VCR.use_cassette('team_users') do
11
- test_client.team_users team_id
12
- end
13
-
14
- expect(team_users.collection.count).to eq(4)
15
- expect(team_users.team_id).to eq(team_id)
16
- end
17
-
18
- it 'supports pagination' do
19
- team_users = VCR.use_cassette('all_team_users_pagination') do
20
- test_client.team_users team_id, limit: 1, page: 3
21
- end
22
-
23
- expect(team_users.collection.count).to eq(1)
24
- expect(team_users.total_results).to eq(4)
25
- expect(team_users.total_pages).to eq(4)
26
- expect(team_users.results_per_page).to eq(1)
27
- expect(team_users.current_page).to eq(3)
28
- end
29
- end
30
-
31
- specify '#team_user' do
32
- team_user = VCR.use_cassette('team_user') do
33
- test_client.team_user team_id, '20181'
34
- end
35
-
36
- expect(team_user.team_id).to eq(team_id)
37
- expect(team_user.user_id).to eq(20_181)
38
- expect(team_user.email).to eq('bodrovis@protonmail.com')
39
- expect(team_user.fullname).to eq('Ilya B')
40
- expect(team_user.created_at).to eq('2018-08-21 15:35:25 (Etc/UTC)')
41
- expect(team_user.created_at_timestamp).to eq(1_534_865_725)
42
- expect(team_user.role).to eq('owner')
43
- end
44
-
45
- specify '#reload_data' do
46
- team_user = VCR.use_cassette('team_user') do
47
- test_client.team_user team_id, '20181'
48
- end
49
-
50
- reloaded_team_user = VCR.use_cassette('team_user') do
51
- team_user.reload_data
52
- end
53
-
54
- expect(reloaded_team_user.user_id).to eq(team_user.user_id)
55
- end
56
-
57
- specify '#update_team_user' do
58
- team_user = VCR.use_cassette('update_team_user') do
59
- test_client.update_team_user team_id, team_user_id, role: 'admin'
60
- end
61
-
62
- expect(team_user.user_id).to eq(team_user_id)
63
- expect(team_user.role).to eq('admin')
64
- end
65
-
66
- specify '#destroy_team_user' do
67
- response = VCR.use_cassette('delete_team_user') do
68
- test_client.destroy_team_user team_id, team_user_id
69
- end
70
- expect(response['team_id']).to eq(team_id)
71
- expect(response['team_user_deleted']).to eq(true)
72
- end
73
-
74
- context 'when team user methods are chained' do
75
- it 'supports update and destroy' do
76
- team_user = VCR.use_cassette('another_team_user') do
77
- test_client.team_user team_id, another_user_id
78
- end
79
-
80
- updated_team_user = VCR.use_cassette('update_team_user_chained') do
81
- team_user.update role: 'admin'
82
- end
83
-
84
- expect(updated_team_user.client.token).to eq(test_client.token)
85
- expect(updated_team_user.role).to eq('admin')
86
-
87
- delete_response = VCR.use_cassette('delete_team_user_chained') do
88
- updated_team_user.destroy
89
- end
90
-
91
- expect(delete_response['team_id']).to eq(team_id)
92
- expect(delete_response['team_user_deleted']).to eq(true)
93
- end
94
- end
95
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- specify '#teams' do
5
- teams = VCR.use_cassette('teams') do
6
- test_client.teams page: 2, limit: 1
7
- end
8
-
9
- team = teams.collection.first
10
-
11
- expect(teams.collection.length).to eq(1)
12
- expect(teams.total_results).to eq(2)
13
- expect(teams.total_pages).to eq(2)
14
- expect(teams.results_per_page).to eq(1)
15
- expect(teams.current_page).to eq(2)
16
-
17
- expect(team.team_id).to eq(176_692)
18
- expect(team.name).to eq('Ilya\'s Team')
19
- expect(team.created_at).to eq('2018-08-21 15:35:25 (Etc/UTC)')
20
- expect(team.created_at_timestamp).to eq(1_534_865_725)
21
- expect(team.plan).to eq('Trial')
22
- expect(team.quota_usage['users']).to eq(9)
23
- expect(team.quota_allowed['keys']).to eq(999_999_999)
24
- end
25
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:team_id) { 176_692 }
5
-
6
- describe '#translation_providers' do
7
- it 'returns all providers' do
8
- providers = VCR.use_cassette('all_translation_providers') do
9
- test_client.translation_providers team_id
10
- end.collection
11
-
12
- expect(providers.count).to eq(2)
13
- expect(providers.first.slug).to eq('gengo')
14
- end
15
-
16
- it 'supports pagination' do
17
- providers = VCR.use_cassette('all_translation_providers_pagination') do
18
- test_client.translation_providers team_id, limit: 1, page: 2
19
- end
20
-
21
- expect(providers.collection.count).to eq(1)
22
- expect(providers.total_results).to eq(2)
23
- expect(providers.total_pages).to eq(2)
24
- expect(providers.results_per_page).to eq(1)
25
- expect(providers.current_page).to eq(2)
26
- end
27
- end
28
-
29
- specify '#translation_provider' do
30
- provider = VCR.use_cassette('translation_provider') do
31
- test_client.translation_provider team_id, 1
32
- end
33
-
34
- expect(provider.provider_id).to eq(1)
35
- expect(provider.name).to eq('Gengo')
36
- expect(provider.slug).to eq('gengo')
37
- expect(provider.price_pair_min).to eq('0.00')
38
- expect(provider.website_url).to eq('https://gengo.com')
39
- expect(provider.description.start_with?('At')).to eq(true)
40
- expect(provider.tiers.first['title']).to eq('Native speaker')
41
- expect(provider.pairs.first['price_per_word']).to eq('0.05')
42
-
43
- reloaded_provider = VCR.use_cassette('translation_provider') do
44
- provider.reload_data
45
- end
46
- expect(reloaded_provider.provider_id).to eq(provider.provider_id)
47
- end
48
- end