Class: Linkshare::CustomReports
- Inherits:
-
Object
- Object
- Linkshare::CustomReports
- Defined in:
- lib/linkshare/custom_reports.rb
Instance Method Summary collapse
- #fetchReports(reportname, bdate, edate, network, tz = "America%2FNew_York", date_type = 'transaction', include_summary = "N") ⇒ Object
- #getReports ⇒ Object
- #initilize ⇒ Object
Instance Method Details
#fetchReports(reportname, bdate, edate, network, tz = "America%2FNew_York", date_type = 'transaction', include_summary = "N") ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/linkshare/custom_reports.rb', line 15 def fetchReports(reportname, bdate, edate, network, tz="America%2FNew_York", date_type='transaction', include_summary="N") token = Linkshare.custom_report_token url = Linkshare::API_URIS[:custom_reports]+'/'+reportname+'/filters?start_date='+bdate+'&end_date='+edate+'&include_summary='+include_summary+'&network='+network.to_s+'&tz='+tz+'&date_type='+date_type+'&token='+token @reportsRows = [] filename = "linkshare_custom_report_#{reportname}_#{bdate}_#{edate}" path = "#{Rails.root.join('tmp')}/#{filename}.csv" file = Tempfile.new(["#{filename}", '.csv']) file.binmode file << open(url).read file.close pp '----- content of file ---123123' CSV.open(path, 'w', headers: :first_row, col_sep: ',', :row_sep => :auto, encoding: 'utf-8') do |csv| pp csv # CSV.open(file.path, 'r:bom|utf-8', headers: :first_row, col_sep: ',', quote_char: "\"", row_sep: "\r\n").each_with_index do |line, index| # pp line # @reportsRows.push(line) # end end pp '----- end content of file ---' @reportsRows end |
#getReports ⇒ Object
12 13 14 |
# File 'lib/linkshare/custom_reports.rb', line 12 def getReports @reportsRows end |
#initilize ⇒ Object
5 6 7 8 9 |
# File 'lib/linkshare/custom_reports.rb', line 5 def initilize() @reportsCSV = '' @reportsRows = [] @cols = [] end |