voys_api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/voys_api/client.rb +13 -4
- data/lib/voys_api/version.rb +1 -1
- metadata +2 -2
data/lib/voys_api/client.rb
CHANGED
@@ -28,8 +28,8 @@ class VoysApi::Client
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Options:
|
31
|
-
# period_from: '2013-01-01'
|
32
|
-
# period_to: '2013-01-18'
|
31
|
+
# period_from: '2013-01-01' (you can also pass a Time object)
|
32
|
+
# period_to: '2013-01-18' (you can also pass a Time object)
|
33
33
|
# inboundoutbound: 0
|
34
34
|
# totals: 0
|
35
35
|
# aggregation: 0
|
@@ -40,13 +40,22 @@ class VoysApi::Client
|
|
40
40
|
# Empty options returns everything.
|
41
41
|
def raw_export(options = {})
|
42
42
|
login if not logged_in?
|
43
|
+
|
44
|
+
# convert options
|
45
|
+
options[:period_from] = options[:period_from].strftime("%Y-%m-%d") if options[:period_from].is_a?(Time)
|
46
|
+
options[:period_to] = options[:period_to].strftime("%Y-%m-%d") if options[:period_to].is_a?(Time)
|
47
|
+
|
43
48
|
result = agent.post('/cdr/export', options)
|
44
49
|
result.body
|
45
50
|
end
|
46
51
|
|
52
|
+
# NOTE:
|
53
|
+
# Date and time values are in +0200 timezone but set to UTC
|
54
|
+
# To fix use row[:date].change(:offset => "+0200")
|
47
55
|
def export(options = {}, csv_options = {})
|
48
|
-
|
49
|
-
|
56
|
+
|
57
|
+
csv_options = {col_sep: ';', converters: [:date_time], headers: :first_row, header_converters: :symbol}.merge(csv_options)
|
58
|
+
export = CSV.parse(raw_export(options), csv_options)
|
50
59
|
return export
|
51
60
|
rescue CSV::MalformedCSVError => exception
|
52
61
|
raise exception, "#{exception.message}\nCSV:\n#{raw_export}"
|
data/lib/voys_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: voys_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|