@@ -58,7 +58,7 @@ def login(username, password=nil, api_securekey=nil, use_headers=false)
58
58
end
59
59
60
60
response = WebUtils . get_json ( @base_url + LOGIN_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash , headers )
61
- return response [ 'ApiToken' ]
61
+ response [ 'ApiToken' ]
62
62
end
63
63
64
64
def logout ( api_token )
@@ -83,7 +83,7 @@ def generate_api_key(api_token, username, force_new=false)
83
83
query_hash [ :account_id ] = username
84
84
query_hash [ :force_new ] = force_new
85
85
response = WebUtils . get_json ( @base_url + GENERATE_API_KEY_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
86
- return response [ 'ApiKey' ]
86
+ response [ 'ApiKey' ]
87
87
end
88
88
89
89
def remove_api_key ( api_token , api_securekey )
@@ -108,7 +108,7 @@ def create_job(api_token, job_name=nil, language=Language::ENGLISH, external_id=
108
108
109
109
response = WebUtils . get_json ( @base_url + CREATE_JOB_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
110
110
# Return a hash with JobId and TaskId
111
- return Mash . new ( response )
111
+ Mash . new ( response )
112
112
end
113
113
114
114
def authorize_job ( api_token , job_id )
@@ -120,20 +120,20 @@ def authorize_job(api_token, job_id)
120
120
def delete_job ( api_token , job_id )
121
121
query_hash = init_job_req_dict ( api_token , job_id )
122
122
response = WebUtils . get_json ( @base_url + DELETE_JOB_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
123
- return response [ 'TaskId' ]
123
+ response [ 'TaskId' ]
124
124
end
125
125
126
126
def get_job_info ( api_token , job_id )
127
127
query_hash = init_job_req_dict ( api_token , job_id )
128
128
response = WebUtils . get_json ( @base_url + GET_JOB_INFO_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
129
- return Mash . new ( response )
129
+ fix_job_info_offsets Mash . new ( response )
130
130
end
131
131
132
132
def get_job_list ( api_token , options = nil )
133
133
query_hash = init_access_req_dict ( api_token )
134
134
query_hash . merge! ( options . get_hash ) unless options . nil?
135
135
response = WebUtils . get_json ( @base_url + GET_JOB_LIST_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
136
- return Mash . new ( response )
136
+ fix_job_list_offsets Mash . new ( response )
137
137
end
138
138
139
139
def add_media_to_job_file ( api_token , job_id , media_file )
@@ -142,21 +142,21 @@ def add_media_to_job_file(api_token, job_id, media_file)
142
142
file_size = File . size ( media_file . path )
143
143
response = WebUtils . get_json ( @base_url + ADD_MEDIA_TO_JOB_PATH , 'POST' , nil , query_hash ,
144
144
{ 'Content-Type' => 'video/mp4' , 'Content-Length' => file_size } , media_file )
145
- return response [ 'TaskId' ]
145
+ response [ 'TaskId' ]
146
146
end
147
147
148
148
def add_media_to_job_url ( api_token , job_id , media_url )
149
- return send_media_url ( api_token , job_id , media_url , ADD_MEDIA_TO_JOB_PATH )
149
+ send_media_url ( api_token , job_id , media_url , ADD_MEDIA_TO_JOB_PATH )
150
150
end
151
151
152
152
def add_media_to_job_embedded ( api_token , job_id , media_url )
153
- return send_media_url ( api_token , job_id , media_url , ADD_EMBEDDED_MEDIA_TO_JOB_PATH )
153
+ send_media_url ( api_token , job_id , media_url , ADD_EMBEDDED_MEDIA_TO_JOB_PATH )
154
154
end
155
155
156
156
def get_media ( api_token , job_id )
157
157
query_hash = init_job_req_dict ( api_token , job_id )
158
158
response = WebUtils . get_json ( @base_url + GET_MEDIA_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
159
- return response [ 'MediaUrl' ]
159
+ response [ 'MediaUrl' ]
160
160
end
161
161
162
162
def perform_transcription ( api_token ,
@@ -177,14 +177,14 @@ def perform_transcription(api_token,
177
177
query_hash [ :options ] = options . get_hash . to_json unless options . nil?
178
178
179
179
response = WebUtils . get_json ( @base_url + PERFORM_TRANSCRIPTION , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
180
- return response [ 'TaskId' ]
180
+ response [ 'TaskId' ]
181
181
end
182
182
183
183
def get_transcript ( api_token , job_id , transcript_options = nil )
184
184
query_hash = init_job_req_dict ( api_token , job_id )
185
185
query_hash . merge! ( transcript_options . get_hash ) unless transcript_options . nil?
186
186
# Returns raw transcript text
187
- return WebUtils . http_request ( @base_url + GET_TRANSCRIPT_PATH , 'GET' , WebUtils ::DOWNLOAD_TIMEOUT , query_hash )
187
+ WebUtils . http_request ( @base_url + GET_TRANSCRIPT_PATH , 'GET' , WebUtils ::DOWNLOAD_TIMEOUT , query_hash )
188
188
end
189
189
190
190
def get_caption ( api_token , job_id , caption_format , caption_options = nil )
@@ -195,23 +195,22 @@ def get_caption(api_token, job_id, caption_format, caption_options=nil)
195
195
196
196
response = WebUtils . http_request ( @base_url + GET_CAPTION_PATH , 'GET' , WebUtils ::DOWNLOAD_TIMEOUT , query_hash )
197
197
if not caption_options . nil? and caption_options . build_url # If build_url is true
198
- return JSON . parse ( response ) [ 'CaptionUrl' ]
198
+ JSON . parse ( response ) [ 'CaptionUrl' ]
199
199
else
200
- return response # Else return raw caption text
200
+ response # Else return raw caption text
201
201
end
202
202
end
203
203
204
204
def get_element_list ( api_token , job_id , elementlist_version = nil )
205
205
query_hash = init_job_req_dict ( api_token , job_id )
206
206
query_hash [ :elementlist_version ] = elementlist_version unless elementlist_version . nil?
207
207
response = WebUtils . get_json ( @base_url + GET_ELEMENT_LIST_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
208
- return Mash . new ( response )
208
+ Mash . new ( response )
209
209
end
210
210
211
211
def get_list_of_element_lists ( api_token , job_id )
212
212
query_hash = init_job_req_dict ( api_token , job_id )
213
- response = WebUtils . get_json ( @base_url + GET_LIST_OF_ELEMENT_LISTS_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
214
- return response
213
+ WebUtils . get_json ( @base_url + GET_LIST_OF_ELEMENT_LISTS_PATH , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
215
214
end
216
215
217
216
##############################
@@ -224,7 +223,7 @@ def send_media_url(api_token, job_id, media_url, path)
224
223
query_hash = init_job_req_dict ( api_token , job_id )
225
224
query_hash [ :media_url ] = media_url
226
225
response = WebUtils . get_json ( @base_url + path , 'GET' , WebUtils ::BASIC_TIMEOUT , query_hash )
227
- return response [ 'TaskId' ]
226
+ response [ 'TaskId' ]
228
227
end
229
228
230
229
def init_job_req_dict ( api_token , job_id )
@@ -237,7 +236,7 @@ def init_access_req_dict(api_token)
237
236
init_version_dict . merge ( { api_token : api_token } )
238
237
end
239
238
240
- def init_version_dict ( )
239
+ def init_version_dict
241
240
{ v : API_VERSION }
242
241
end
243
242
@@ -246,5 +245,31 @@ def assert_argument(arg, arg_name)
246
245
raise ArgumentError . new ( 'Invalid argument - ' + arg_name )
247
246
end
248
247
end
248
+
249
+ def fix_job_info_offsets ( job_info )
250
+ top_keys = %w( CreationDate StartDate DueDate CompletedDate ReturnDate AuthorizationDate )
251
+ task_keys = %w( TaskRequestTime )
252
+ job_info = fix_offsets ( job_info , top_keys )
253
+ job_info . Tasks = job_info . Tasks . map do |task_item |
254
+ fix_offsets ( task_item , task_keys )
255
+ end
256
+ job_info
257
+ end
258
+
259
+ def fix_job_list_offsets ( job_list )
260
+ keys = %w( CreationDate CreationTime StartDate StartTime DueDate CompletedDate
261
+ ReturnDate CompletedTime AuthorizationDate )
262
+ job_list . ActiveJobs = job_list . ActiveJobs . map do |job_item |
263
+ fix_offsets ( job_item , keys )
264
+ end
265
+ job_list
266
+ end
267
+
268
+ def fix_offsets ( hash , keys )
269
+ keys . each do |key |
270
+ hash [ key ] = WebUtils . to_utc ( hash [ key ] )
271
+ end
272
+ hash
273
+ end
249
274
end
250
275
end
0 commit comments