mygengo 1.6 → 1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mygengo-ruby/api_handler.rb +11 -1
- data/lib/mygengo.rb +2 -2
- metadata +3 -3
@@ -109,6 +109,10 @@ module MyGengo
|
|
109
109
|
# <tt>endpoint</tt> - String/URL to post data to.
|
110
110
|
# <tt>params</tt> - Data necessary for request (keys, etc). Generally taken care of by the requesting instance.
|
111
111
|
def send_to_mygengo(endpoint, params = {})
|
112
|
+
|
113
|
+
# Check if this is a put
|
114
|
+
is_put = params.delete(:is_put)
|
115
|
+
|
112
116
|
query = {
|
113
117
|
:api_key => @opts[:public_key],
|
114
118
|
:data => params.to_json.gsub('"', '\"'),
|
@@ -117,7 +121,11 @@ module MyGengo
|
|
117
121
|
|
118
122
|
url = URI.parse("http://#{@api_host}/v#{@opts[:api_version]}/#{endpoint}")
|
119
123
|
http = Net::HTTP.new(url.host, url.port)
|
120
|
-
|
124
|
+
if is_put
|
125
|
+
request = Net::HTTP::Put.new(url.path)
|
126
|
+
else
|
127
|
+
request = Net::HTTP::Post.new(url.path)
|
128
|
+
end
|
121
129
|
|
122
130
|
request.add_field('Accept', 'application/json')
|
123
131
|
request.add_field('User-Agent', @opts[:user_agent])
|
@@ -191,6 +199,7 @@ module MyGengo
|
|
191
199
|
# <tt>id</tt> - The ID of a job to update.
|
192
200
|
# <tt>action</tt> - A hash describing the update to this job. See the examples for further documentation.
|
193
201
|
def updateTranslationJob(params = {})
|
202
|
+
params[:is_put] = true
|
194
203
|
self.send_to_mygengo('translate/job/:id'.gsub(':id', params.delete(:id).to_s), params)
|
195
204
|
end
|
196
205
|
|
@@ -200,6 +209,7 @@ module MyGengo
|
|
200
209
|
# <tt>jobs</tt> - An Array of job objects to update (job objects or ids)
|
201
210
|
# <tt>action</tt> - A String describing the update to this job. "approved", "rejected", etc - see myGengo docs.
|
202
211
|
def updateTranslationJobs(params = {})
|
212
|
+
params[:is_put] = true
|
203
213
|
self.send_to_mygengo('translate/jobs', {:jobs => params[:jobs], :action => params[:action]})
|
204
214
|
end
|
205
215
|
|
data/lib/mygengo.rb
CHANGED
metadata
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
name: mygengo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: "1.
|
5
|
+
version: "1.7"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ryan McGrath <ryan@mygengo.com>
|
9
9
|
- Matthew Romaine
|
10
10
|
- Kim Alhstrom
|
11
|
-
-
|
11
|
+
- Lloyd Chan
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date:
|
16
|
+
date: 2012-01-05 00:00:00 -05:00
|
17
17
|
default_executable:
|
18
18
|
dependencies: []
|
19
19
|
|