zuora_api 1.3.9995 → 1.3.9996
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/README.md +1 -1
- data/lib/zuora_api/login.rb +26 -10
- 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: 11f4bee338118875cf516ba7524cec1dc5ff58a1
|
4
|
+
data.tar.gz: 6481f2c77413e352feb88d609407434798974e8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abbbbf6d83952c8d14d1912d3970ffb17f87d5e41de0086f1b65455c472346300dbf1615c85ee9bf918a41862119f90063d784b41b2024c0de28a79040d177d5
|
7
|
+
data.tar.gz: bdf76a459f1317d6f76e9013f07417d78612f44b4378fb9b3892adec9cf8efc3f6ed5d481bba0826e91c38c0c6606f1aed9bd037fbc1ef722d6cb8a13f96f4fb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Zuora Gem
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/zuora_api)
|
3
|
+
[](https://badge.fury.io/rb/zuora_api) [](https://gitlab.zuora.com/Connect/zuora-gem/commits/master)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
Add this line to your application's Gemfile:
|
data/lib/zuora_api/login.rb
CHANGED
@@ -179,9 +179,9 @@ module ZuoraAPI
|
|
179
179
|
self.status = 'Active'
|
180
180
|
end
|
181
181
|
return self.status
|
182
|
-
rescue Net::OpenTimeout
|
182
|
+
rescue Net::ReadTimeout, Net::OpenTimeout => ex
|
183
183
|
if !(tries -= 1).zero?
|
184
|
-
Rails.logger.debug {"Timed out will retry after 5 seconds"}
|
184
|
+
Rails.logger.debug {"#{ex.class} Timed out will retry after 5 seconds"}
|
185
185
|
sleep(5)
|
186
186
|
retry
|
187
187
|
else
|
@@ -198,7 +198,7 @@ module ZuoraAPI
|
|
198
198
|
return self.current_session
|
199
199
|
end
|
200
200
|
|
201
|
-
def soap_call(ns1: 'ns1', ns2: 'ns2', batch_size: nil, single_transaction: false, debug: true, errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError, ZuoraAPI::Exceptions::ZuoraAPIError, ZuoraAPI::Exceptions::ZuoraAPIRequestLimit, ZuoraAPI::Exceptions::ZuoraAPILockCompetition], z_session: true,
|
201
|
+
def soap_call(ns1: 'ns1', ns2: 'ns2', batch_size: nil, single_transaction: false, debug: true, errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError, ZuoraAPI::Exceptions::ZuoraAPIError, ZuoraAPI::Exceptions::ZuoraAPIRequestLimit, ZuoraAPI::Exceptions::ZuoraAPILockCompetition], z_session: true, timeout_retry: false, timeout: 120,**keyword_args)
|
202
202
|
tries ||= 2
|
203
203
|
xml = Nokogiri::XML::Builder.new do |xml|
|
204
204
|
xml['SOAP-ENV'].Envelope('xmlns:SOAP-ENV' => "http://schemas.xmlsoap.org/soap/envelope/",
|
@@ -230,7 +230,7 @@ module ZuoraAPI
|
|
230
230
|
input_xml = Nokogiri::XML(xml.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip)
|
231
231
|
input_xml.xpath('//ns1:session', 'ns1' =>'http://api.zuora.com/').children.remove
|
232
232
|
Rails.logger.debug('Connect') {"Request SOAP XML: #{input_xml.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip}"} if debug
|
233
|
-
response = HTTParty.post(self.url,:body => xml.doc.to_xml, :headers => {'Content-Type' => "text/xml; charset=utf-8"}, :timeout =>
|
233
|
+
response = HTTParty.post(self.url,:body => xml.doc.to_xml, :headers => {'Content-Type' => "text/xml; charset=utf-8"}, :timeout => timeout)
|
234
234
|
output_xml = Nokogiri::XML(response.body)
|
235
235
|
Rails.logger.debug('Connect') {"Response SOAP XML: #{output_xml.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip}"} if debug
|
236
236
|
|
@@ -254,6 +254,12 @@ module ZuoraAPI
|
|
254
254
|
else
|
255
255
|
return [output_xml, input_xml]
|
256
256
|
end
|
257
|
+
rescue Net::ReadTimeout, Net::OpenTimeout => ex
|
258
|
+
if !(tries -= 1).zero? && timeout_retry
|
259
|
+
retry
|
260
|
+
else
|
261
|
+
raise ex
|
262
|
+
end
|
257
263
|
rescue => ex
|
258
264
|
raise ex
|
259
265
|
else
|
@@ -405,11 +411,11 @@ module ZuoraAPI
|
|
405
411
|
return des_hash
|
406
412
|
end
|
407
413
|
|
408
|
-
def rest_call(method: :get, body: {},headers: {}, url: rest_endpoint("catalog/products?pageSize=4"), debug: true, errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError, ZuoraAPI::Exceptions::ZuoraAPIError, ZuoraAPI::Exceptions::ZuoraAPIRequestLimit, ZuoraAPI::Exceptions::ZuoraAPILockCompetition], z_session: true,
|
414
|
+
def rest_call(method: :get, body: {},headers: {}, url: rest_endpoint("catalog/products?pageSize=4"), debug: true, errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError, ZuoraAPI::Exceptions::ZuoraAPIError, ZuoraAPI::Exceptions::ZuoraAPIRequestLimit, ZuoraAPI::Exceptions::ZuoraAPILockCompetition], z_session: true, timeout_retry: false, timeout: 120, **keyword_args)
|
409
415
|
tries ||= 2
|
410
416
|
headers["entityId"] = self.entity_id if !self.entity_id.blank?
|
411
417
|
raise "Method not supported, supported methods include: :get, :post, :put, :delete, :patch, :head, :options" if ![:get, :post, :put, :delete, :patch, :head, :options].include?(method)
|
412
|
-
response = HTTParty::Request.new("Net::HTTP::#{method.to_s.capitalize}".constantize, url, body: body, headers: {'Content-Type' => "application/json; charset=utf-8"}.merge(z_session ? {"Authorization" => "ZSession #{self.get_session}"} : {}).merge(headers), timeout:
|
418
|
+
response = HTTParty::Request.new("Net::HTTP::#{method.to_s.capitalize}".constantize, url, body: body, headers: {'Content-Type' => "application/json; charset=utf-8"}.merge(z_session ? {"Authorization" => "ZSession #{self.get_session}"} : {}).merge(headers), timeout: timeout).perform
|
413
419
|
|
414
420
|
Rails.logger.debug('Connect') {"Response Code: #{response.code}" } if debug
|
415
421
|
begin
|
@@ -439,6 +445,12 @@ module ZuoraAPI
|
|
439
445
|
else
|
440
446
|
return [output_json, response]
|
441
447
|
end
|
448
|
+
rescue Net::ReadTimeout, Net::OpenTimeout => ex
|
449
|
+
if !(tries -= 1).zero? && timeout_retry
|
450
|
+
retry
|
451
|
+
else
|
452
|
+
raise ex
|
453
|
+
end
|
442
454
|
rescue => ex
|
443
455
|
raise ex
|
444
456
|
else
|
@@ -464,7 +476,7 @@ module ZuoraAPI
|
|
464
476
|
while !response["nextPage"].blank?
|
465
477
|
url = self.rest_endpoint(response["nextPage"].split('/v1/').last)
|
466
478
|
Rails.logger.debug("Fetch Catalog URL #{url}")
|
467
|
-
output_json, response = self.rest_call(:debug => false, :url => url, :errors => [ZuoraAPI::Exceptions::ZuoraAPISessionError])
|
479
|
+
output_json, response = self.rest_call(:debug => false, :url => url, :errors => [ZuoraAPI::Exceptions::ZuoraAPISessionError], :timeout_retry => true )
|
468
480
|
if !output_json['success'] =~ (/(true|t|yes|y|1)$/i) || output_json['success'].class != TrueClass
|
469
481
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("Error Getting Catalog: #{output_json}")
|
470
482
|
end
|
@@ -491,7 +503,7 @@ module ZuoraAPI
|
|
491
503
|
return products, catalog_map
|
492
504
|
end
|
493
505
|
|
494
|
-
def get_file(url: nil, headers: {}, count: 3, z_session: true, tempfile: true, file_path: Rails.root.join('tmp'), **execute_params)
|
506
|
+
def get_file(url: nil, headers: {}, count: 3, z_session: true, tempfile: true, file_path: Rails.root.join('tmp'), timeout_retries: 2, timeout: 120, **execute_params)
|
495
507
|
raise "file_path must be of class Pathname" if file_path.class != Pathname
|
496
508
|
|
497
509
|
#Make sure directory exists
|
@@ -502,7 +514,7 @@ module ZuoraAPI
|
|
502
514
|
uri = URI.parse(url)
|
503
515
|
|
504
516
|
http = Net::HTTP.new(uri.host, uri.port)
|
505
|
-
http.read_timeout =
|
517
|
+
http.read_timeout = timeout #Seconds
|
506
518
|
http.use_ssl = true if uri.scheme.downcase == 'https'
|
507
519
|
headers = headers.merge({"Authorization" => "ZSession #{self.get_session}"}) if z_session
|
508
520
|
|
@@ -518,7 +530,11 @@ module ZuoraAPI
|
|
518
530
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error) if count <= 0
|
519
531
|
Rails.logger.fatal("Unauthorized: Retry")
|
520
532
|
self.new_session
|
521
|
-
return get_file(:url => url, :headers => headers, :count => count - 1, :z_session => z_session, :tempfile => tempfile, :file_path => file_path)
|
533
|
+
return get_file(:url => url, :headers => headers, :count => count - 1, :z_session => z_session, :tempfile => tempfile, :file_path => file_path, :timeout_retries => timeout_retries, :timeout => timeout)
|
534
|
+
|
535
|
+
when Net::ReadTimeout, Net::OpenTimeout
|
536
|
+
Rails.logger.fatal("Timeout: Retry")
|
537
|
+
return get_file(:url => url, :headers => headers, :count => count, :z_session => z_session, :tempfile => tempfile, :file_path => file_path, :timeout_retries => timeout_retries - 1, :timeout => timeout)
|
522
538
|
|
523
539
|
when Net::HTTPClientError
|
524
540
|
Rails.logger.debug("Login: #{self.username} Export")
|
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: 1.3.
|
4
|
+
version: 1.3.9996
|
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: 2017-09-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|