cielo24 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cielo24.rb +11 -11
- data/lib/cielo24/actions.rb +5 -5
- data/lib/cielo24/options.rb +13 -1
- data/lib/cielo24/version.rb +2 -2
- data/lib/cielo24/web_utils.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9107d0e793b84ed3a486338337eeb04714376905
|
4
|
+
data.tar.gz: 9794c0732b072a63811fddd86a3581b095991081
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27669efdf2a205b83418245bebfa953f1d8f894c8b0ffa500e715316c5984da976df91f7e4914fa555981cadead49efb3f5acd57de0f105a59aa99088a00fcc5
|
7
|
+
data.tar.gz: ed250abdfb41c16841a2dde46885a6269d4c1fffbe33d924d5799958fb1a21aea0cace56992749c66b1a6ea1a355e2b6fb8aab4cdb1a932fb8a68e09f87b935f
|
data/lib/cielo24.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'cielo24/version'
|
2
|
-
require 'cielo24/actions'
|
3
|
-
require 'cielo24/enums'
|
4
|
-
require 'cielo24/options'
|
5
|
-
require 'cielo24/web_utils'
|
6
|
-
|
7
|
-
require 'hashie'
|
8
|
-
require 'httpclient'
|
9
|
-
|
10
|
-
module Cielo24
|
11
|
-
end
|
1
|
+
require 'cielo24/version'
|
2
|
+
require 'cielo24/actions'
|
3
|
+
require 'cielo24/enums'
|
4
|
+
require 'cielo24/options'
|
5
|
+
require 'cielo24/web_utils'
|
6
|
+
|
7
|
+
require 'hashie'
|
8
|
+
require 'httpclient'
|
9
|
+
|
10
|
+
module Cielo24
|
11
|
+
end
|
data/lib/cielo24/actions.rb
CHANGED
@@ -32,7 +32,7 @@ module Cielo24
|
|
32
32
|
GET_ELEMENT_LIST_PATH = "/api/job/get_elementlist"
|
33
33
|
GET_LIST_OF_ELEMENT_LISTS_PATH = "/api/job/list_elementlists"
|
34
34
|
|
35
|
-
def initialize(base_url="https://
|
35
|
+
def initialize(base_url="https://api.cielo24.com")
|
36
36
|
@base_url = base_url
|
37
37
|
end
|
38
38
|
|
@@ -42,7 +42,7 @@ module Cielo24
|
|
42
42
|
assert_argument(username, "Username")
|
43
43
|
# Password or API Secure Key must be supplied but not both
|
44
44
|
raise ArgumentError.new("Only password or API secure must be supplied for login.") if (!password.nil? and !api_securekey.nil?)
|
45
|
-
raise ArgumentError.new("Password or API
|
45
|
+
raise ArgumentError.new("Password or API Secure Key must be supplied for login.") if (password.nil? and api_securekey.nil?)
|
46
46
|
|
47
47
|
query_hash = init_version_dict
|
48
48
|
headers = Hash.new
|
@@ -188,7 +188,7 @@ module Cielo24
|
|
188
188
|
query_hash[:callback_uri] = URI.escape(callback_uri) if !(callback_uri.nil?)
|
189
189
|
query_hash[:turnaround_hours] = turnaround_hours if !(turnaround_hours.nil?)
|
190
190
|
query_hash[:target_language] = target_language if !(target_language.nil?)
|
191
|
-
query_hash.merge(options.get_hash) if !(options.nil?)
|
191
|
+
query_hash.merge!(options.get_hash) if !(options.nil?)
|
192
192
|
|
193
193
|
json = WebUtils.get_json(@base_url + PERFORM_TRANSCRIPTION, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
|
194
194
|
return json["TaskId"]
|
@@ -196,7 +196,7 @@ module Cielo24
|
|
196
196
|
|
197
197
|
def get_transcript(api_token, job_id, transcript_options = nil)
|
198
198
|
query_hash = init_job_req_dict(api_token, job_id)
|
199
|
-
query_hash.merge(transcript_options.get_hash) if !(transcript_options.nil?)
|
199
|
+
query_hash.merge!(transcript_options.get_hash) if !(transcript_options.nil?)
|
200
200
|
|
201
201
|
# Return raw transcript text
|
202
202
|
return WebUtils.http_request(@base_url + GET_TRANSCRIPTION_PATH, 'GET', WebUtils::DOWNLOAD_TIMEOUT, query_hash)
|
@@ -205,7 +205,7 @@ module Cielo24
|
|
205
205
|
def get_caption(api_token, job_id, caption_format, caption_options = nil)
|
206
206
|
query_hash = init_job_req_dict(api_token, job_id)
|
207
207
|
query_hash[:caption_format] = caption_format
|
208
|
-
query_hash.merge(caption_options.get_hash) if !(caption_options.nil?)
|
208
|
+
query_hash.merge!(caption_options.get_hash) if !(caption_options.nil?)
|
209
209
|
|
210
210
|
response = WebUtils.http_request(@base_url + GET_CAPTION_PATH, 'GET', WebUtils::DOWNLOAD_TIMEOUT, query_hash)
|
211
211
|
if(!caption_options.nil? and caption_options[:build_url]) # If build_url is true
|
data/lib/cielo24/options.rb
CHANGED
@@ -22,8 +22,20 @@ module Cielo24
|
|
22
22
|
return array.join("&")
|
23
23
|
end
|
24
24
|
|
25
|
-
def populate_from_key_value_pair
|
25
|
+
def populate_from_key_value_pair(key, value)
|
26
|
+
# Iterate over instance variables
|
27
|
+
self.instance_variables.each{ |var|
|
28
|
+
if var.to_s.delete("@") == key
|
29
|
+
self.instance_variable_set(var, value)
|
30
|
+
break
|
31
|
+
end
|
32
|
+
}
|
33
|
+
end
|
26
34
|
|
35
|
+
def populate_from_hash(hash)
|
36
|
+
hash.each do |key, value|
|
37
|
+
populate_from_key_value_pair(key, value)
|
38
|
+
end
|
27
39
|
end
|
28
40
|
end
|
29
41
|
|
data/lib/cielo24/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Cielo24
|
2
|
-
VERSION = "0.0.
|
1
|
+
module Cielo24
|
2
|
+
VERSION = "0.0.6"
|
3
3
|
end
|
data/lib/cielo24/web_utils.rb
CHANGED
@@ -8,6 +8,11 @@ module Cielo24
|
|
8
8
|
VERIFY_MODE = nil
|
9
9
|
BASIC_TIMEOUT = 60
|
10
10
|
DOWNLOAD_TIMEOUT = 300
|
11
|
+
@@LAST_URL = "none" # For logging purposes
|
12
|
+
|
13
|
+
def self.LAST_URL
|
14
|
+
return @@LAST_URL
|
15
|
+
end
|
11
16
|
|
12
17
|
def self.get_json(uri, method, timeout, query=nil, headers=nil, body=nil)
|
13
18
|
response = http_request(uri, method, timeout, query, headers, body)
|
@@ -20,6 +25,7 @@ module Cielo24
|
|
20
25
|
# TODO: timeout
|
21
26
|
|
22
27
|
response = http_client.request(method, uri, query, body, headers, nil)
|
28
|
+
@@LAST_URL = uri + "?" + URI.encode_www_form(query)
|
23
29
|
|
24
30
|
# Handle web errors
|
25
31
|
if response.status_code == 200 or response.status_code == 204
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cielo24
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeny Chistyakov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|