mygengo 1.10 → 1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -65,7 +65,7 @@ module MyGengo
65
65
  def get_from_mygengo(endpoint, params = {})
66
66
  # Do this small check here...
67
67
  is_delete = params.delete(:is_delete)
68
- is_get_preview = params.delete(:get_preview_image)
68
+ is_download_file = params.delete(:is_download)
69
69
 
70
70
  # The first part of the object we're going to encode and use in our request to myGengo. The signing process
71
71
  # is a little annoying at the moment, so bear with us...
@@ -89,11 +89,14 @@ module MyGengo
89
89
  req = Net::HTTP::Get.new(uri, headers)
90
90
  end
91
91
 
92
- resp = Net::HTTP.start(@api_host, 80) do |http|
93
- http.request(req)
94
- end
92
+ http = Net::HTTP.start(@api_host, 80)
93
+ if @debug
94
+ http.set_debug_output($stdout)
95
+ end
96
+ http.read_timeout = 5*60
97
+ resp = http.request(req)
95
98
 
96
- if is_get_preview.nil?
99
+ if is_download_file.nil?
97
100
  json = JSON.parse(resp.body)
98
101
  if json['opstat'] != 'ok'
99
102
  raise MyGengo::Exception.new(json['opstat'], json['err']['code'].to_i, json['err']['msg'])
@@ -128,6 +131,7 @@ module MyGengo
128
131
 
129
132
  url = URI.parse("http://#{@api_host}/v#{@opts[:api_version]}/#{endpoint}")
130
133
  http = Net::HTTP.new(url.host, url.port)
134
+ http.read_timeout = 5*60
131
135
  if is_put
132
136
  request = Net::HTTP::Put.new(url.path)
133
137
  else
@@ -185,6 +189,7 @@ module MyGengo
185
189
  url = URI.parse("http://#{@api_host}/v#{@opts[:api_version]}/#{endpoint}")
186
190
 
187
191
  http = Net::HTTP.new(url.host, url.port)
192
+ http.read_timeout = 5*60
188
193
 
189
194
  call_timestamp = Time.now.gmtime.to_i.to_s
190
195
 
@@ -366,7 +371,7 @@ module MyGengo
366
371
  # Options:
367
372
  # <tt>id</tt> - The ID of the job you want a preview image of.
368
373
  def getTranslationJobPreviewImage(params = {})
369
- params[:get_preview_image] = true
374
+ params[:is_download] = true
370
375
  self.get_from_mygengo('translate/job/:id/preview'.gsub(':id', params.delete(:id).to_s), params)
371
376
  end
372
377
 
@@ -405,6 +410,22 @@ module MyGengo
405
410
  def getServiceLanguages(params = {})
406
411
  self.get_from_mygengo('translate/service/languages', params)
407
412
  end
413
+
414
+ # Gets list of glossaries that belongs to the authenticated user
415
+ def getGlossaryList(params = {})
416
+ self.get_from_mygengo('translate/glossary', params)
417
+ end
418
+
419
+ # Gets one glossary that belongs to the authenticated user
420
+ def getGlossary(params = {})
421
+ self.get_from_mygengo('translate/glossary/:id'.gsub(':id', params.delete(:id).to_s), params)
422
+ end
423
+
424
+ # Downloads one glossary that belongs to the authenticated user
425
+ def getGlossaryFile(params = {})
426
+ params[:is_download] = true
427
+ self.get_from_mygengo('translate/glossary/download/:id'.gsub(':id', params.delete(:id).to_s), params)
428
+ end
408
429
  end
409
430
 
410
431
  end
@@ -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.10'
14
+ VERSION = '1.12'
15
15
  end
16
16
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mygengo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.10'
4
+ version: '1.12'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
+ - Lloyd Chan
8
9
  - Ryan McGrath
9
10
  - Matthew Romaine
10
11
  - Kim Alhstrom
11
- - Lloyd Chan
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-07-18 00:00:00.000000000 Z
15
+ date: 2012-08-21 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: json