zuora_api 0.2.6.5 → 0.2.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/zuora_api/login.rb +19 -37
- data/lib/zuora_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1053ff11c1376a088bd917846d947ad723474283
|
4
|
+
data.tar.gz: e8362876fe1320b101392870e2343670243b98f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab9da8db92b5687dc45646530ec128b0061cd16814d3125a9305c3b7ad5fa905932fa23fa27977a2971bf7fb0994d2a64b52b11e28f2b40dac2c611417286608
|
7
|
+
data.tar.gz: d7fdb8d1e2bf9eb71f3dc6d30ea99b63e99db1670e5e641cf77c0bf34dbecfa940af9dddfee11d9439c65ea279f856394d44b48b4322e3f8b7c5656961a10717
|
data/Gemfile.lock
CHANGED
data/lib/zuora_api/login.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "httparty"
|
2
|
+
require "zip"
|
2
3
|
require "nokogiri"
|
3
4
|
module ZuoraAPI
|
4
5
|
class Login
|
@@ -316,7 +317,7 @@ module ZuoraAPI
|
|
316
317
|
temp_file ||= tmp_file
|
317
318
|
tmp_file.binmode if (response.to_hash["content-type"].include?("application/zip") || response.to_hash["content-type"] == "application/zip")
|
318
319
|
response.read_body do |chunk|
|
319
|
-
tmp_file.write chunk
|
320
|
+
tmp_file.write chunk.force_encoding("UTF-8")
|
320
321
|
end
|
321
322
|
end if response.is_a?(Net::HTTPSuccess)
|
322
323
|
end
|
@@ -333,7 +334,7 @@ module ZuoraAPI
|
|
333
334
|
return temp_file
|
334
335
|
end
|
335
336
|
|
336
|
-
def getDataSourceExport(query)
|
337
|
+
def getDataSourceExport(query, extract: true)
|
337
338
|
Rails.logger.info('Export') {"Build export"}
|
338
339
|
Rails.logger.info('Export query') {"#{query}"}
|
339
340
|
request = Nokogiri::XML::Builder.new do |xml|
|
@@ -385,44 +386,25 @@ module ZuoraAPI
|
|
385
386
|
end
|
386
387
|
file_id = output_xml.xpath('//ns2:FileId', 'ns2' =>'http://object.api.zuora.com/').text
|
387
388
|
Rails.logger.info('Export') {'=====> Export finished'}
|
388
|
-
|
389
|
+
zip_file = get_file(:file_name => "#{file_id}.zip" ,:url => "#{self.fileURL}#{file_id}?file-id=#{file_id}", headers: {"Authorization" => "ZSession " + self.current_session})
|
390
|
+
if extract
|
391
|
+
location = extract_zip(zip_file.path, "#{file_id}")
|
392
|
+
File.delete(zip_file.path)
|
393
|
+
return location
|
394
|
+
else
|
395
|
+
return zip_file.path
|
396
|
+
end
|
397
|
+
end
|
389
398
|
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
ar.fopen(0) do |zf|
|
397
|
-
open(zf.name, 'wb') do |f|
|
398
|
-
CSV.parse(zf.read) do |row|
|
399
|
-
j=0
|
400
|
-
values = Hash.new
|
401
|
-
storename = ''
|
402
|
-
row.each do |col|
|
403
|
-
if i == 0
|
404
|
-
headers[j] = col
|
405
|
-
else
|
406
|
-
#Is this needed - can just store all dates as string
|
407
|
-
if headers[j].include? 'CreatedDate'
|
408
|
-
values[headers[j]] = Date.strptime(row[j], self.dateFormat)
|
409
|
-
elsif row[j].nil?
|
410
|
-
values[headers[j]] = ''
|
411
|
-
else
|
412
|
-
values[headers[j]] = row[j]
|
413
|
-
end
|
414
|
-
end
|
415
|
-
j += 1
|
416
|
-
end
|
417
|
-
if i!=0
|
418
|
-
list[i-1] = values
|
419
|
-
end
|
420
|
-
i += 1
|
421
|
-
end
|
422
|
-
end
|
399
|
+
def extract_zip(file,filename)
|
400
|
+
FileUtils.mkdir_p("#{Rails.root}/tmp/#{filename}")
|
401
|
+
::Zip::File.open(file) do |zip_file|
|
402
|
+
zip_file.each do |f|
|
403
|
+
fpath = File.join("#{Rails.root}/tmp/#{filename}", f.name)
|
404
|
+
zip_file.extract(f, fpath) unless File.exist?(fpath)
|
423
405
|
end
|
424
406
|
end
|
425
|
-
return
|
407
|
+
return "#{Rails.root}/tmp/#{filename}"
|
426
408
|
end
|
427
409
|
|
428
410
|
def query(query)
|
data/lib/zuora_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.6.
|
4
|
+
version: 0.2.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zuora Strategic Solutions Group
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|