voys_api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
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
- voys_client.headers # => ["Foreign Code", "Client", "Account / Phone number", "Date", "Inbound / Outbound", "Amount", "Duration", "Source", "Destination", "Destination code"]
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
 
@@ -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
- export = CSV.parse(raw_export, col_sep: ';', converters: [:date_time]) #, headers: :first_row)
48
- @headers = export.shift # Remove header row
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
 
@@ -1,3 +1,3 @@
1
1
  module VoysApi
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: