16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/happyscribe.rb', line 16
def create(url,title="",language="fr-FR")
endpoint = "#{@base}/transcriptions"
uri = URI.parse(endpoint)
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request["Authorization"] = @auth
request.body = JSON.dump({
"transcription" => {
"name" => (title=="" ? SecureRandom.alphanumeric : title ),
"language" => language,
"tmp_url" => url
}
})
req_options = {
use_ssl: uri.scheme == "https",
}
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
return JSON.parse response.body
end
|