zuora_api 0.2.6.2 → 0.2.6.3
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/zuora_api/login.rb +48 -8
- 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: b951408f08d47564162bc87dfdce7f2d7cabc6db
|
4
|
+
data.tar.gz: 0d049bf21fdbc43a867b882250b6f3efe5d8abc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a1b2c9d318bf82f4fc7609d0fbeaf3232c6873b8c877cbcad068e97bfba96d8b50ed8c0da0c81e270af39b318e848da6e358c84809c743813a749ad15cb4fd4
|
7
|
+
data.tar.gz: 2d2e576bf7ce6c43bb71bb51316aa0230bd994a8f76348548025027dd6416707de077646c3e231748002fa6c91590e062e6d23237235d13e62791e10a2a82d13
|
data/Gemfile.lock
CHANGED
data/lib/zuora_api/login.rb
CHANGED
@@ -254,7 +254,7 @@ module ZuoraAPI
|
|
254
254
|
return des_hash
|
255
255
|
end
|
256
256
|
|
257
|
-
def rest_call(method: :get, body: {},headers: {}, url: rest_endpoint("catalog/products?pageSize=4") , **keyword_args)
|
257
|
+
def rest_call(method: :get, body: {},headers: {}, url: rest_endpoint("catalog/products?pageSize=4") , debug:true, **keyword_args)
|
258
258
|
tries ||= 2
|
259
259
|
raise "Method not supported, supported methods include: :get, :post, :put, :delete, :patch, :head, :options" if ![:get, :post, :put, :delete, :patch, :head, :options].include?(method)
|
260
260
|
response = HTTParty::Request.new("Net::HTTP::#{method.to_s.capitalize}".constantize, url, body: body, headers: {'Content-Type' => "application/json; charset=utf-8", "Authorization" => "ZSession #{self.get_session}"}.merge(headers)).perform
|
@@ -264,17 +264,21 @@ module ZuoraAPI
|
|
264
264
|
Rails.logger.debug('Connect') {"Response JSON: #{output_json}"}
|
265
265
|
raise "#{output_json["reasons"][0]["code"]}::#{output_json["reasons"][0]["message"]}" if !output_json["success"] || response.code != 200
|
266
266
|
rescue => ex
|
267
|
-
if
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
267
|
+
if debug
|
268
|
+
if !(tries -= 1).zero
|
269
|
+
case ex.to_s.split("::")[0]
|
270
|
+
when "90000011"
|
271
|
+
Rails.logger.debug {"Session Invalid"}
|
272
|
+
self.new_session
|
273
|
+
retry
|
274
|
+
else
|
275
|
+
raise ex
|
276
|
+
end
|
273
277
|
else
|
274
278
|
raise ex
|
275
279
|
end
|
276
280
|
else
|
277
|
-
|
281
|
+
return output_json
|
278
282
|
end
|
279
283
|
else
|
280
284
|
return output_json
|
@@ -294,6 +298,39 @@ module ZuoraAPI
|
|
294
298
|
return self
|
295
299
|
end
|
296
300
|
|
301
|
+
def get_file(file_name: 'example.csv', url: nil, basic: {:username => nil, :password => nil}, headers: {})
|
302
|
+
tries ||= 2
|
303
|
+
temp_file = nil
|
304
|
+
|
305
|
+
uri = URI(url)
|
306
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
307
|
+
request = Net::HTTP::Get.new(uri)
|
308
|
+
headers.each do |k,v|
|
309
|
+
request["#{k}"] = v
|
310
|
+
end
|
311
|
+
request.basic_auth(basic[:username], basic[:password]) if (!basic[:username].blank? && !basic[:password].blank?)
|
312
|
+
http.request request do |response|
|
313
|
+
Tempfile.open([file_name.rpartition('.').first, ".#{file_name.rpartition('.').last}"], "#{Rails.root}/tmp") do |tmp_file|
|
314
|
+
temp_file ||= tmp_file
|
315
|
+
tmp_file.binmode if (response.to_hash["content-type"].include?("application/zip") || response.to_hash["content-type"] == "application/zip")
|
316
|
+
response.read_body do |chunk|
|
317
|
+
tmp_file.write chunk
|
318
|
+
end
|
319
|
+
end if response.is_a?(Net::HTTPSuccess)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
rescue => ex
|
324
|
+
if !(tries -= 1).zero?
|
325
|
+
sleep 3
|
326
|
+
retry
|
327
|
+
else
|
328
|
+
raise ex
|
329
|
+
end
|
330
|
+
else
|
331
|
+
return temp_file
|
332
|
+
end
|
333
|
+
|
297
334
|
def getDataSourceExport(query)
|
298
335
|
Rails.logger.info('Export') {"Build export"}
|
299
336
|
Rails.logger.info('Export query') {"#{query}"}
|
@@ -345,6 +382,9 @@ module ZuoraAPI
|
|
345
382
|
return 'Export Creation Unsuccessful : ' + output_xml.xpath('//ns1:Message', 'ns1' =>'http://api.zuora.com/').text if result == "Failed"
|
346
383
|
end
|
347
384
|
file_id = output_xml.xpath('//ns2:FileId', 'ns2' =>'http://object.api.zuora.com/').text
|
385
|
+
Rails.logger.info('Export') {'=====> Export finished'}
|
386
|
+
#return get_file(:file_name => "data_export#{Time.now}.csv" ,:url => "#{self.fileURL}#{file_id}?file-id=#{file_id}", headers: {"Authorization" => "ZSession " + self.current_session})
|
387
|
+
|
348
388
|
response_query = HTTParty.get(self.fileURL + file_id, body: request.to_xml, headers: {"Authorization" => "ZSession " + self.current_session}, query: {"file-id" => file_id})
|
349
389
|
Rails.logger.info('Export') {'=====> Export finished'}
|
350
390
|
list = Array.new
|
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.3
|
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
|
+
date: 2016-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|