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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 977aadb4acfad8e681ee65cbb3db4c9e76452937
4
- data.tar.gz: 2b20f81f5bc12bc26df1400ce5006d5c5c60c093
3
+ metadata.gz: 11f4bee338118875cf516ba7524cec1dc5ff58a1
4
+ data.tar.gz: 6481f2c77413e352feb88d609407434798974e8d
5
5
  SHA512:
6
- metadata.gz: f2e55e273071f6e9b69fe44f4533d7e578762a1a74b05d806cde46f3fb449e164a250a42d41a187b7c36ea65e685522e6627b1ce12c0e924624708796a9e964c
7
- data.tar.gz: 3484ab7d7c4e53c589c7b5222cc958f41872536f2dc5faeb3dc79cbda604b355e7b68a75e152ab1b05345ede1885120d75e5ee0abb32605755d34d63dac1b2de
6
+ metadata.gz: abbbbf6d83952c8d14d1912d3970ffb17f87d5e41de0086f1b65455c472346300dbf1615c85ee9bf918a41862119f90063d784b41b2024c0de28a79040d177d5
7
+ data.tar.gz: bdf76a459f1317d6f76e9013f07417d78612f44b4378fb9b3892adec9cf8efc3f6ed5d481bba0826e91c38c0c6606f1aed9bd037fbc1ef722d6cb8a13f96f4fb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zuora_api (1.3.9995)
4
+ zuora_api (1.3.9996)
5
5
  httparty
6
6
  nokogiri (~> 1.6.8)
7
7
  railties (>= 4.1.0, < 5.1)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Zuora Gem
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/zuora_api.svg)](https://badge.fury.io/rb/zuora_api)
3
+ [![Gem Version](https://badge.fury.io/rb/zuora_api.svg)](https://badge.fury.io/rb/zuora_api) [![coverage report](https://gitlab.zuora.com/Connect/zuora-gem/badges/master/coverage.svg)](https://gitlab.zuora.com/Connect/zuora-gem/commits/master)
4
4
 
5
5
  ## Installation
6
6
  Add this line to your application's Gemfile:
@@ -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, **keyword_args)
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 => 120)
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, **keyword_args)
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: 120).perform
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 = 120 #Seconds
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")
@@ -1,3 +1,3 @@
1
1
  module ZuoraAPI
2
- VERSION = "1.3.9995"
2
+ VERSION = "1.3.9996"
3
3
  end
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.9995
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-26 00:00:00.000000000 Z
11
+ date: 2017-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler