mygengo 1.4 → 1.5

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.
@@ -61,7 +61,10 @@ module MyGengo
61
61
  # <tt>endpoint</tt> - String/URL to request data from.
62
62
  # <tt>params</tt> - Data necessary for request (keys, etc). Generally taken care of by the requesting instance.
63
63
  def get_from_mygengo(endpoint, params = {})
64
- # The first part of the object we're going to encode and use in our request to myGengo. The signing process
64
+ # Do this small check here...
65
+ is_delete = params.delete(:is_delete)
66
+
67
+ # The first part of the object we're going to encode and use in our request to myGengo. The signing process
65
68
  # is a little annoying at the moment, so bear with us...
66
69
  query = {
67
70
  :api_key => @opts[:public_key],
@@ -71,11 +74,20 @@ module MyGengo
71
74
  endpoint << "?api_sig=" + signature_of(query[:ts])
72
75
  endpoint << '&' + query.map { |k, v| "#{k}=#{urlencode(v)}" }.join('&')
73
76
 
77
+ uri = "/v#{@opts[:api_version]}/" + endpoint
78
+ headers = {
79
+ 'Accept' => 'application/json',
80
+ 'User-Agent' => @opts[:user_agent]
81
+ }
82
+
83
+ if is_delete
84
+ req = Net::HTTP::Delete.new(uri, headers)
85
+ else
86
+ req = Net::HTTP::Get.new(uri, headers)
87
+ end
88
+
74
89
  resp = Net::HTTP.start(@api_host, 80) do |http|
75
- http.request(Net::HTTP::Get.new("/v#{@opts[:api_version]}/" + endpoint, {
76
- 'Accept' => 'application/json',
77
- 'User-Agent' => @opts[:user_agent]
78
- }))
90
+ http.request(req)
79
91
  end
80
92
 
81
93
  json = JSON.parse(resp.body)
@@ -179,7 +191,7 @@ module MyGengo
179
191
  # <tt>id</tt> - The ID of a job to update.
180
192
  # <tt>action</tt> - A hash describing the update to this job. See the examples for further documentation.
181
193
  def updateTranslationJob(params = {})
182
- self.send_to_mygengo('translate/job/:id'.gsub(':id', params.delete(:id)), params)
194
+ self.send_to_mygengo('translate/job/:id'.gsub(':id', params.delete(:id).to_s), params)
183
195
  end
184
196
 
185
197
  # Updates a group of already submitted jobs.
@@ -196,7 +208,7 @@ module MyGengo
196
208
  # <tt>id</tt> - The ID of a job to check.
197
209
  # <tt>pre_mt</tt> - Optional, get a machine translation if the human translation is not done.
198
210
  def getTranslationJob(params = {})
199
- self.get_from_mygengo('translate/job/:id'.gsub(':id', params.delete(:id)), params)
211
+ self.get_from_mygengo('translate/job/:id'.gsub(':id', params.delete(:id).to_s), params)
200
212
  end
201
213
 
202
214
  # Pulls down a list of recently submitted jobs, allows some filters.
@@ -216,7 +228,7 @@ module MyGengo
216
228
  #
217
229
  # <tt>id</tt> - Required, the ID of a job that you want the batch/group of.
218
230
  def getTranslationJobBatch(params = {})
219
- self.get_from_mygengo('translate/jobs/group/:group_id'.gsub(':group_id', params.delete(:group_id)), params)
231
+ self.get_from_mygengo('translate/jobs/group/:group_id'.gsub(':group_id', params.delete(:group_id).to_s), params)
220
232
  end
221
233
 
222
234
  # Mirrors the bulk Translation call, but just returns an estimated cost.
@@ -230,7 +242,7 @@ module MyGengo
230
242
  # <tt>id</tt> - The ID of the job you're commenting on.
231
243
  # <tt>comment</tt> - The comment to put on the job.
232
244
  def postTranslationJobComment(params = {})
233
- self.send_to_mygengo('translate/job/:id/comment'.gsub(':id', params.delete(:id)), params)
245
+ self.send_to_mygengo('translate/job/:id/comment'.gsub(':id', params.delete(:id).to_s), params)
234
246
  end
235
247
 
236
248
  # Get all comments (the history) from a given job.
@@ -238,7 +250,7 @@ module MyGengo
238
250
  # Options:
239
251
  # <tt>id</tt> - The ID of the job to get comments for.
240
252
  def getTranslationJobComments(params = {})
241
- self.get_from_mygengo('translate/job/:id/comments'.gsub(':id', params.delete(:id)), params)
253
+ self.get_from_mygengo('translate/job/:id/comments'.gsub(':id', params.delete(:id).to_s), params)
242
254
  end
243
255
 
244
256
  # Returns the feedback you've submitted for a given job.
@@ -246,7 +258,7 @@ module MyGengo
246
258
  # Options:
247
259
  # <tt>id</tt> - The ID of the translation job you're retrieving comments from.
248
260
  def getTranslationJobFeedback(params = {})
249
- self.get_from_mygengo('translate/job/:id/feedback'.gsub(':id', params.delete(:id)), params)
261
+ self.get_from_mygengo('translate/job/:id/feedback'.gsub(':id', params.delete(:id).to_s), params)
250
262
  end
251
263
 
252
264
  # Gets a list of the revision resources for a job. Revisions are created each time a translator updates the text.
@@ -254,7 +266,7 @@ module MyGengo
254
266
  # Options:
255
267
  # <tt>id</tt> - The ID of the translation job you're getting revisions from.
256
268
  def getTranslationJobRevisions(params = {})
257
- self.get_from_mygengo('translate/job/:id/revisions'.gsub(':id', params.delete(:id)), params)
269
+ self.get_from_mygengo('translate/job/:id/revisions'.gsub(':id', params.delete(:id).to_s), params)
258
270
  end
259
271
 
260
272
  # Get a specific revision to a job.
@@ -263,7 +275,7 @@ module MyGengo
263
275
  # <tt>id</tt> - The ID of the translation job you're getting revisions from.
264
276
  # <tt>rev_id</tt> - The ID of the revision you're looking up.
265
277
  def getTranslationJobRevision(params = {})
266
- self.get_from_mygengo('translate/job/:id/revisions/:revision_id'.gsub(':id', params.delete(:id)).gsub(':rev_id', params.delete(:rev_id)), params)
278
+ self.get_from_mygengo('translate/job/:id/revisions/:revision_id'.gsub(':id', params.delete(:id).to_s).gsub(':revision_id', params.delete(:rev_id).to_s), params)
267
279
  end
268
280
 
269
281
  # Returns a preview image for a job.
@@ -271,7 +283,7 @@ module MyGengo
271
283
  # Options:
272
284
  # <tt>id</tt> - The ID of the job you want a preview image of.
273
285
  def getTranslationJobPreviewImage(params = {})
274
- self.get_from_mygengo('translate/job/:id/preview'.gsub(':id', params.delete(:id)), params)
286
+ self.get_from_mygengo('translate/job/:id/preview'.gsub(':id', params.delete(:id).to_s), params)
275
287
  end
276
288
 
277
289
  # Deletes a job.
@@ -279,7 +291,8 @@ module MyGengo
279
291
  # Options:
280
292
  # <tt>id</tt> - The ID of the job you want to delete.
281
293
  def deleteTranslationJob(params = {})
282
- self.send_to_mygengo('translate/job/:id'.gsub(':id', params.delete(:id)), params)
294
+ params[:is_delete] = true
295
+ self.get_from_mygengo('translate/job/:id'.gsub(':id', params.delete(:id).to_s), params)
283
296
  end
284
297
 
285
298
  # Deletes multiple jobs.
@@ -292,7 +305,8 @@ module MyGengo
292
305
  params.delete(:ids)
293
306
  end
294
307
 
295
- self.send_to_mygengo('translate/jobs', params)
308
+ params[:is_delete] = true
309
+ self.get_from_mygengo('translate/jobs', params)
296
310
  end
297
311
 
298
312
  # Gets information about currently supported language pairs.
@@ -300,7 +314,7 @@ module MyGengo
300
314
  # Options:
301
315
  # <tt>lc_src</tt> - Optional language code to filter on.
302
316
  def getServiceLanguagePairs(params = {})
303
- self.get_from_mygengo('translate/service/language_pairs', params)
317
+ self.get_from_mygengo('translate/service/language_pairs', params)
304
318
  end
305
319
 
306
320
  # Pulls down currently supported languages.
@@ -11,6 +11,6 @@ module MyGengo
11
11
  SANDBOX_API_HOST = 'api.sandbox.mygengo.com'
12
12
 
13
13
  # Pretty self explanatory.
14
- VERSION = '1.4'
14
+ VERSION = '1.5'
15
15
  end
16
16
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mygengo
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "1.4"
5
+ version: "1.5"
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan McGrath <ryan@mygengo.com>
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2011-08-17 00:00:00 +09:00
15
+ date: 2011-08-17 00:00:00 -04:00
16
16
  default_executable:
17
17
  dependencies: []
18
18