voys_api 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +18 -2
- data/lib/voys_api/client.rb +3 -8
- data/lib/voys_api/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -21,8 +21,24 @@ Or install it yourself as:
|
|
21
21
|
voys_client = VoysApi::Client.new('username', 'password')
|
22
22
|
voys_client.raw_export # => "\"Foreign Code\";\"Client\";\"Account...
|
23
23
|
|
24
|
-
voys_client.export
|
25
|
-
|
24
|
+
result = voys_client.export
|
25
|
+
result.first.headers # => [:foreign_code, :client, :account__phone_number, :date, :inbound__outbound, :amount, :duration, :source, :destination, :destination_code]
|
26
|
+
result.first[:client] # => "Client name"
|
27
|
+
|
28
|
+
You can pass the following options to raw_export and export:
|
29
|
+
|
30
|
+
# period_from: '2013-01-01'
|
31
|
+
# period_to: '2013-01-18'
|
32
|
+
# inboundoutbound: 0
|
33
|
+
# totals: 0
|
34
|
+
# aggregation: 0
|
35
|
+
# search_query: nil
|
36
|
+
# reset_filter: false
|
37
|
+
# page_number: nil
|
38
|
+
|
39
|
+
For example:
|
40
|
+
|
41
|
+
result = voys_client.export(search_query: 'kaas')
|
26
42
|
|
27
43
|
## Contributing
|
28
44
|
|
data/lib/voys_api/client.rb
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
require 'csv'
|
2
2
|
require 'mechanize'
|
3
3
|
# VoysApi exports voys.nl call list..
|
4
|
-
#
|
5
|
-
# voys_client = VoysApi::Client.new('username', 'password')
|
6
|
-
# voys_client.export # => "\"Foreign Code\";\"Client\";\"Account...
|
7
4
|
class VoysApi::Client
|
8
5
|
|
9
|
-
attr_reader :headers
|
10
|
-
|
11
6
|
def initialize(username, password)
|
12
7
|
@username = username
|
13
8
|
@password = password
|
@@ -43,9 +38,9 @@ class VoysApi::Client
|
|
43
38
|
result.body
|
44
39
|
end
|
45
40
|
|
46
|
-
def export(options = {})
|
47
|
-
|
48
|
-
|
41
|
+
def export(options = {}, csv_options = {})
|
42
|
+
csv_options = {col_sep: ';', converters: [:date_time], headers: :first_row, header_converters: :symbol}.merge(options)
|
43
|
+
export = CSV.parse(raw_export, csv_options)
|
49
44
|
return export
|
50
45
|
end
|
51
46
|
|
data/lib/voys_api/version.rb
CHANGED