cielo24 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e334329bde7311af931b6b69fd8bb2fbf3f9642c
4
+ data.tar.gz: e321a51097a5d236d07ebb6f134203a495aeddef
5
+ SHA512:
6
+ metadata.gz: 3b653d28dc45ee1c37eeac09c6b3559c2cfaceda39864eadbde955b6ac73e821c7e4972e0071b61a8a1bf73060c2ef7abadde8e42e502f1788ec4b0aca8680e4
7
+ data.tar.gz: 58f5b34fe7b3f74015dc2bededd03c6b59bfa87e069256bfaf272b871b50f9548609cc158b81c1f075988fb7f9176d92243f0fe5ff4b4d56e3fa2935e437a9e0
@@ -58,7 +58,7 @@ module Cielo24
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 @@ module Cielo24
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 @@ module Cielo24
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 @@ module Cielo24
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 @@ module Cielo24
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 @@ module Cielo24
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,9 +195,9 @@ module Cielo24
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
 
@@ -205,13 +205,12 @@ module Cielo24
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 @@ module Cielo24
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 @@ module Cielo24
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 @@ module Cielo24
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
@@ -1,3 +1,3 @@
1
1
  module Cielo24
2
- VERSION = '0.0.15'
3
- end
2
+ VERSION = '0.0.16'
3
+ end
@@ -5,11 +5,13 @@ module Cielo24
5
5
  require 'httpclient'
6
6
  require 'timeout'
7
7
  require 'logger'
8
+ require 'tzinfo'
8
9
  include JSON
9
10
 
10
11
  BASIC_TIMEOUT = 60 # seconds (1 minute)
11
12
  DOWNLOAD_TIMEOUT = 300 # seconds (5 minutes)
12
13
  UPLOAD_TIMEOUT = 60*60*24*7 # seconds (1 week)
14
+ SERVER_TZ = 'America/Los_Angeles'
13
15
  LOGGER = Logger.new(STDOUT)
14
16
 
15
17
  def self.get_json(uri, method, timeout, query=nil, headers=nil, body=nil)
@@ -42,6 +44,15 @@ module Cielo24
42
44
  raise TimeoutError.new('The HTTP session has timed out.')
43
45
  end
44
46
  end
47
+
48
+ def self.to_utc(s)
49
+ return s if s.empty?
50
+ tz = TZInfo::Timezone.get(SERVER_TZ)
51
+ local = DateTime.iso8601(s)
52
+ utc = tz.local_to_utc local
53
+ format = '%Y-%m-%dT%H:%M:%S.%L%z' # iso8601 with milliseconds
54
+ utc.strftime(format)
55
+ end
45
56
  end
46
57
 
47
58
  class WebError < StandardError
metadata CHANGED
@@ -1,80 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cielo24
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
5
- prerelease:
4
+ version: 0.0.16
6
5
  platform: ruby
7
6
  authors:
8
7
  - cielo24
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-08-03 00:00:00.000000000 Z
11
+ date: 2015-12-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.10.6
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.10.6
30
27
  - !ruby/object:Gem::Dependency
31
- name: rake
28
+ name: httpclient
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: 10.4.2
38
- type: :development
33
+ version: 2.6.0.1
34
+ type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: 10.4.2
40
+ version: 2.6.0.1
46
41
  - !ruby/object:Gem::Dependency
47
- name: httpclient
42
+ name: hashie
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: 2.6.0.1
47
+ version: 3.4.2
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: 2.6.0.1
54
+ version: 3.4.2
62
55
  - !ruby/object:Gem::Dependency
63
- name: hashie
56
+ name: tzinfo
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
- version: 3.4.2
61
+ version: 1.2.2
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
- version: 3.4.2
68
+ version: 1.2.2
78
69
  description: This gem allows you to interact with the cielo24 public REST API.
79
70
  email:
80
71
  - support@cielo24.com
@@ -82,34 +73,33 @@ executables: []
82
73
  extensions: []
83
74
  extra_rdoc_files: []
84
75
  files:
76
+ - lib/cielo24.rb
77
+ - lib/cielo24/actions.rb
78
+ - lib/cielo24/enums.rb
85
79
  - lib/cielo24/options.rb
86
- - lib/cielo24/web_utils.rb
87
80
  - lib/cielo24/version.rb
88
- - lib/cielo24/enums.rb
89
- - lib/cielo24/actions.rb
90
- - lib/cielo24.rb
81
+ - lib/cielo24/web_utils.rb
91
82
  homepage: http://cielo24.com
92
83
  licenses: []
84
+ metadata: {}
93
85
  post_install_message:
94
86
  rdoc_options: []
95
87
  require_paths:
96
88
  - lib
97
89
  required_ruby_version: !ruby/object:Gem::Requirement
98
- none: false
99
90
  requirements:
100
- - - ! '>='
91
+ - - ">="
101
92
  - !ruby/object:Gem::Version
102
93
  version: '0'
103
94
  required_rubygems_version: !ruby/object:Gem::Requirement
104
- none: false
105
95
  requirements:
106
- - - ! '>='
96
+ - - ">="
107
97
  - !ruby/object:Gem::Version
108
98
  version: '0'
109
99
  requirements: []
110
100
  rubyforge_project:
111
- rubygems_version: 1.8.23
101
+ rubygems_version: 2.4.6
112
102
  signing_key:
113
- specification_version: 3
103
+ specification_version: 4
114
104
  summary: Cielo24 API gem.
115
105
  test_files: []