smartring 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smartling/jobs.rb +29 -17
- data/test/smartling/jobs_test.rb +34 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6999093e00fa486300723c24a340ce43bec412b7bb91d91b7f5af7bb4aa06995
|
4
|
+
data.tar.gz: 9e6e7c7d56d639139c773c3268daae1d40bfb498d723c6b190b9deb8a7d3c6be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3680b23b17bd8975b3c8d0d2c61450218d4ddbf79f3040522743749ce7cf75b9185fbdd443bd55dbf73a5a60755b47da958f0d44de1f82f5e18b8f98abd2b5
|
7
|
+
data.tar.gz: 9a7ded57503d98447ae3119717660d59950841719902f2d9d266862270255e2047bf961a0586eedb3f96a1759230fbacedadb17a26c9e3ba0a9752bdc819a880
|
data/lib/smartling/jobs.rb
CHANGED
@@ -33,8 +33,9 @@ module Smartling
|
|
33
33
|
body[:referenceNumber] = reference_number unless reference_number.nil?
|
34
34
|
body[:callbackUrl] = callback_url unless callback_url.nil?
|
35
35
|
body[:callbackMethod] = callback_method unless callback_method.nil?
|
36
|
-
|
37
|
-
post(path,
|
36
|
+
headers = { 'Content-Type' => 'application/json' }
|
37
|
+
return post(path, headers: headers) if body.empty?
|
38
|
+
post(path, body: body.to_json, headers: headers)
|
38
39
|
end
|
39
40
|
|
40
41
|
def job(project_id: @project_id, translation_job_uid:)
|
@@ -54,8 +55,9 @@ module Smartling
|
|
54
55
|
body[:referenceNumber] = reference_number unless reference_number.nil?
|
55
56
|
body[:callbackUrl] = callback_url unless callback_url.nil?
|
56
57
|
body[:callbackMethod] = callback_method unless callback_method.nil?
|
57
|
-
|
58
|
-
put(path,
|
58
|
+
headers = { 'Content-Type' => 'application/json' }
|
59
|
+
return put(path, headers: headers) if body.empty?
|
60
|
+
put(path, body: body.to_json, headers: headers)
|
59
61
|
end
|
60
62
|
|
61
63
|
def search_jobs(project_id: @project_id, translation_job_uids: nil,
|
@@ -67,8 +69,9 @@ module Smartling
|
|
67
69
|
end
|
68
70
|
body[:hashcodes] = hashcodes unless hashcodes.nil?
|
69
71
|
body[:fileUris] = file_uris unless file_uris.nil?
|
70
|
-
|
71
|
-
post(path,
|
72
|
+
headers = { 'Content-Type' => 'application/json' }
|
73
|
+
return post(path, headers: headers) if body.empty?
|
74
|
+
post(path, body: body.to_json, headers: headers)
|
72
75
|
end
|
73
76
|
|
74
77
|
def job_files(project_id: @project_id, translation_job_uid:, offset: nil,
|
@@ -101,14 +104,16 @@ module Smartling
|
|
101
104
|
body = {}
|
102
105
|
body[:fileUri] = file_uri
|
103
106
|
body[:targetLocaleIds] = target_locale_ids unless target_locale_ids.nil?
|
104
|
-
|
107
|
+
headers = { 'Content-Type' => 'application/json' }
|
108
|
+
post(path, body: body.to_json, headers: headers)
|
105
109
|
end
|
106
110
|
|
107
111
|
def remove_file_from_job(project_id: @project_id, translation_job_uid:, file_uri:)
|
108
112
|
path = "/jobs-api/v3/projects/#{project_id}/jobs/#{translation_job_uid}"
|
109
113
|
path = path + '/file/remove'
|
110
114
|
body = { fileUri: file_uri }
|
111
|
-
|
115
|
+
headers = { 'Content-Type' => 'application/json' }
|
116
|
+
post(path, body: body.to_json, headers: headers)
|
112
117
|
end
|
113
118
|
|
114
119
|
def add_strings_to_job(project_id: @project_id, translation_job_uid:,
|
@@ -120,7 +125,8 @@ module Smartling
|
|
120
125
|
body[:hashcodes] = hashcodes
|
121
126
|
body[:targetLocaleIds] = target_locale_ids unless target_locale_ids.nil?
|
122
127
|
body[:moveEnabled] = move_enabled unless move_enabled.nil?
|
123
|
-
|
128
|
+
headers = { 'Content-Type' => 'application/json' }
|
129
|
+
post(path, body: body.to_json, headers: headers)
|
124
130
|
end
|
125
131
|
|
126
132
|
def remove_strings_from_job(project_id: @project_id, translation_job_uid:,
|
@@ -130,7 +136,9 @@ module Smartling
|
|
130
136
|
body = {}
|
131
137
|
body[:hashcodes] = hashcodes
|
132
138
|
body[:localeIds] = locale_ids unless locale_ids.nil?
|
133
|
-
|
139
|
+
headers = { 'Content-Type' => 'application/json' }
|
140
|
+
return post(path, headers: headers) if body.empty?
|
141
|
+
post(path, body: body.to_json, headers: headers)
|
134
142
|
end
|
135
143
|
|
136
144
|
def add_locale_to_job(project_id: @project_id, translation_job_uid:,
|
@@ -139,8 +147,9 @@ module Smartling
|
|
139
147
|
path = path + "/locales/#{locale_id}"
|
140
148
|
body = {}
|
141
149
|
body[:syncContent] = sync_content unless sync_content.nil?
|
142
|
-
|
143
|
-
post(path,
|
150
|
+
headers = { 'Content-Type' => 'application/json' }
|
151
|
+
return post(path, headers: headers) if body.nil?
|
152
|
+
post(path, body: body.to_json, headers: headers)
|
144
153
|
end
|
145
154
|
|
146
155
|
def remove_locale_from_job(project_id: @project_id, translation_job_uid:,
|
@@ -153,7 +162,8 @@ module Smartling
|
|
153
162
|
def close_job(project_id: @project_id, translation_job_uid:)
|
154
163
|
path = "/jobs-api/v3/projects/#{project_id}/jobs/#{translation_job_uid}"
|
155
164
|
path = path + '/close'
|
156
|
-
|
165
|
+
headers = { 'Content-Type' => 'application/json' }
|
166
|
+
post(path, headers: headers)
|
157
167
|
end
|
158
168
|
|
159
169
|
def cancel_job(project_id: @project_id, translation_job_uid:, reason: nil)
|
@@ -161,17 +171,19 @@ module Smartling
|
|
161
171
|
path = path + '/cancel'
|
162
172
|
body = {}
|
163
173
|
body[:reason] = reason unless reason.nil?
|
164
|
-
|
165
|
-
post(path,
|
174
|
+
headers = { 'Content-Type' => 'application/json' }
|
175
|
+
return post(path, headers: headers) if body.nil?
|
176
|
+
post(path, body: body.to_json, headers: headers)
|
166
177
|
end
|
167
178
|
|
168
179
|
def authorize_job(project_id: @project_id, translation_job_uid:,
|
169
180
|
locale_workflows: nil)
|
170
181
|
path = "/jobs-api/v3/projects/#{project_id}/jobs/#{translation_job_uid}"
|
171
182
|
path = path + '/authorize'
|
183
|
+
headers = { 'Content-Type' => 'application/json' }
|
172
184
|
case locale_workflows
|
173
185
|
when nil
|
174
|
-
return post(path)
|
186
|
+
return post(path, headers: headers)
|
175
187
|
when Array
|
176
188
|
body = {}
|
177
189
|
body[:localeWorkflows] = locale_workflows.map do |lw|
|
@@ -179,7 +191,7 @@ module Smartling
|
|
179
191
|
workflow = lw[:workflow_uid] || lw.fetch('workflow_uid')
|
180
192
|
{ targetLocaleId: locale, workflowUid: workflow }
|
181
193
|
end
|
182
|
-
post(path, body: body)
|
194
|
+
post(path, body: body.to_json, headers: headers)
|
183
195
|
else
|
184
196
|
raise ArgumentError, 'locale_workflows should be an array'
|
185
197
|
end
|
data/test/smartling/jobs_test.rb
CHANGED
@@ -36,15 +36,18 @@ describe Smartling::Jobs do
|
|
36
36
|
|
37
37
|
describe 'create_job' do
|
38
38
|
it 'POSTs the right path and body' do
|
39
|
-
smartling.expect(:post, nil) do |path
|
39
|
+
smartling.expect(:post, nil) do |path, headers:|
|
40
40
|
assert_match %r{jobs-api/v3/projects/1/jobs}, path
|
41
|
+
assert_equal 'application/json', headers['Content-Type']
|
41
42
|
end
|
42
43
|
smartling.create_job(project_id: 1)
|
43
44
|
end
|
44
45
|
|
45
46
|
it 'builds the correct body' do
|
46
|
-
smartling.expect(:post, nil) do |path, body:|
|
47
|
+
smartling.expect(:post, nil) do |path, body:, headers:|
|
47
48
|
assert_match %r{jobs-api/v3/projects/1/jobs}, path
|
49
|
+
assert_equal 'application/json', headers['Content-Type']
|
50
|
+
body = HipsterHash[JSON.parse(body)]
|
48
51
|
assert_equal 'foo', body[:jobName]
|
49
52
|
assert_equal Time.parse('2000-01-01').iso8601, body[:dueDate]
|
50
53
|
assert_equal %w(de), body[:targetLocaleIds]
|
@@ -70,8 +73,10 @@ describe Smartling::Jobs do
|
|
70
73
|
|
71
74
|
describe 'update_job' do
|
72
75
|
it 'PUTs the right data to the right endpoint' do
|
73
|
-
smartling.expect(:put, nil) do |path, body:|
|
76
|
+
smartling.expect(:put, nil) do |path, body:, headers:|
|
74
77
|
assert_match %r{jobs-api/v3/projects/1/jobs/x}, path
|
78
|
+
assert_equal 'application/json', headers['Content-Type']
|
79
|
+
body = HipsterHash[JSON.parse(body)]
|
75
80
|
assert_equal 'D', body[:description]
|
76
81
|
assert_equal Time.parse('2001-01-01').iso8601, body[:dueDate]
|
77
82
|
assert_equal '123', body[:referenceNumber]
|
@@ -88,8 +93,10 @@ describe Smartling::Jobs do
|
|
88
93
|
|
89
94
|
describe 'search_jobs' do
|
90
95
|
it 'POSTs the right body to the right endpoint' do
|
91
|
-
smartling.expect(:post, nil) do |path, body:|
|
96
|
+
smartling.expect(:post, nil) do |path, body:, headers:|
|
92
97
|
assert_match %r{jobs-api/v3/projects/1/jobs/search}, path
|
98
|
+
assert_equal 'application/json', headers['Content-Type']
|
99
|
+
body = HipsterHash[JSON.parse(body)]
|
93
100
|
assert_equal %w(a b), body[:hashcodes]
|
94
101
|
assert_equal %w(x y), body[:fileUris]
|
95
102
|
assert_equal %w(1 2), body[:translationJobUids]
|
@@ -134,8 +141,10 @@ describe Smartling::Jobs do
|
|
134
141
|
|
135
142
|
describe 'add_strings_to_job' do
|
136
143
|
it 'POSTs the right body to the right endpoint' do
|
137
|
-
smartling.expect(:post, nil) do |path, body:|
|
144
|
+
smartling.expect(:post, nil) do |path, body:, headers:|
|
138
145
|
assert_match %r{jobs-api/v3/projects/1/jobs/x/strings/add}, path
|
146
|
+
assert_equal 'application/json', headers['Content-Type']
|
147
|
+
body = HipsterHash[JSON.parse(body)]
|
139
148
|
assert_equal true, body[:moveEnabled]
|
140
149
|
assert_equal %w(x y), body[:hashcodes]
|
141
150
|
assert_equal %w(de), body[:targetLocaleIds]
|
@@ -148,8 +157,10 @@ describe Smartling::Jobs do
|
|
148
157
|
|
149
158
|
describe 'remove_strings_from_job' do
|
150
159
|
it 'POSTs the right body to the right endpoint' do
|
151
|
-
smartling.expect(:post, nil) do |path, body:|
|
160
|
+
smartling.expect(:post, nil) do |path, body:, headers:|
|
152
161
|
assert_match %r{jobs-api/v3/projects/1/jobs/x/strings/remove}, path
|
162
|
+
assert_equal 'application/json', headers['Content-Type']
|
163
|
+
body = HipsterHash[JSON.parse(body)]
|
153
164
|
assert_equal %w(x y), body[:hashcodes]
|
154
165
|
assert_equal %w(de), body[:localeIds]
|
155
166
|
end
|
@@ -162,8 +173,10 @@ describe Smartling::Jobs do
|
|
162
173
|
|
163
174
|
describe 'add_file_to_job' do
|
164
175
|
it 'POSTs the right body to the right endpoint' do
|
165
|
-
smartling.expect(:post, nil) do |path, body:|
|
176
|
+
smartling.expect(:post, nil) do |path, body:, headers:|
|
166
177
|
assert_match %r{jobs-api/v3/projects/1/jobs/x/file/add}, path
|
178
|
+
assert_equal 'application/json', headers['Content-Type']
|
179
|
+
body = HipsterHash[JSON.parse(body)]
|
167
180
|
assert_equal 'z', body[:fileUri]
|
168
181
|
assert_equal %w(de), body[:targetLocaleIds]
|
169
182
|
end
|
@@ -174,8 +187,10 @@ describe Smartling::Jobs do
|
|
174
187
|
|
175
188
|
describe 'remove_file_from_job' do
|
176
189
|
it 'POSTs the right body to the right endpoint' do
|
177
|
-
smartling.expect(:post, nil) do |path, body:|
|
190
|
+
smartling.expect(:post, nil) do |path, body:, headers:|
|
178
191
|
assert_match %r{jobs-api/v3/projects/1/jobs/x/file/remove}, path
|
192
|
+
assert_equal 'application/json', headers['Content-Type']
|
193
|
+
body = HipsterHash[JSON.parse(body)]
|
179
194
|
assert_equal 'z', body[:fileUri]
|
180
195
|
end
|
181
196
|
smartling.remove_file_from_job(project_id: 1, translation_job_uid: 'x',
|
@@ -185,8 +200,10 @@ describe Smartling::Jobs do
|
|
185
200
|
|
186
201
|
describe 'add_locale_to_job' do
|
187
202
|
it 'POSTs the right body to the right endpoint' do
|
188
|
-
smartling.expect(:post, nil) do |path, body:|
|
203
|
+
smartling.expect(:post, nil) do |path, body:, headers:|
|
189
204
|
assert_match %r{jobs-api/v3/projects/1/jobs/x/locales/de-AT}, path
|
205
|
+
assert_equal 'application/json', headers['Content-Type']
|
206
|
+
body = HipsterHash[JSON.parse(body)]
|
190
207
|
assert_equal true, body[:syncContent]
|
191
208
|
end
|
192
209
|
smartling.add_locale_to_job(project_id: 1, translation_job_uid: 'x',
|
@@ -207,7 +224,7 @@ describe Smartling::Jobs do
|
|
207
224
|
|
208
225
|
describe 'close_job' do
|
209
226
|
it 'POSTs to the right endpoint' do
|
210
|
-
smartling.expect(:post, nil) do |path
|
227
|
+
smartling.expect(:post, nil) do |path, headers:|
|
211
228
|
assert_match %r{jobs-api/v3/projects/1/jobs/x/close}, path
|
212
229
|
end
|
213
230
|
smartling.close_job(project_id: 1, translation_job_uid: 'x')
|
@@ -216,8 +233,10 @@ describe Smartling::Jobs do
|
|
216
233
|
|
217
234
|
describe 'cancel_job' do
|
218
235
|
it 'POSTs the right body to the right endpoint' do
|
219
|
-
smartling.expect(:post, nil) do |path, body:|
|
236
|
+
smartling.expect(:post, nil) do |path, body:, headers:|
|
220
237
|
assert_match %r{jobs-api/v3/projects/1/jobs/x/cancel}, path
|
238
|
+
assert_equal 'application/json', headers['Content-Type']
|
239
|
+
body = HipsterHash[JSON.parse(body)]
|
221
240
|
assert_equal 'Laziness', body[:reason]
|
222
241
|
end
|
223
242
|
smartling.cancel_job(project_id: 1, translation_job_uid: 'x',
|
@@ -227,8 +246,10 @@ describe Smartling::Jobs do
|
|
227
246
|
|
228
247
|
describe 'authorize_job' do
|
229
248
|
it 'POSTs the right body to the right endpoint' do
|
230
|
-
smartling.expect(:post, nil) do |path, body:|
|
249
|
+
smartling.expect(:post, nil) do |path, body:, headers:|
|
231
250
|
assert_match %r{jobs-api/v3/projects/1/jobs/x/authorize}, path
|
251
|
+
assert_equal 'application/json', headers['Content-Type']
|
252
|
+
body = HipsterHash[JSON.parse(body)]
|
232
253
|
workflow = body[:localeWorkflows].first
|
233
254
|
assert_equal 'a', body[:localeWorkflows][0][:targetLocaleId]
|
234
255
|
assert_equal 'b', body[:localeWorkflows][0][:workflowUid]
|
@@ -244,7 +265,7 @@ describe Smartling::Jobs do
|
|
244
265
|
end
|
245
266
|
|
246
267
|
it 'does not require workflows' do
|
247
|
-
smartling.expect(:post, nil) do |path
|
268
|
+
smartling.expect(:post, nil) do |path, headers:|
|
248
269
|
assert_match %r{jobs-api/v3/projects/1/jobs/x/authorize}, path
|
249
270
|
end
|
250
271
|
smartling.authorize_job(project_id: 1, translation_job_uid: 'x')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JJ Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|