zuora_api 1.7.08 → 1.7.09

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 506b37beaa7dbe046f337f7ed10112f2f6a693b1ebcafa37142634d0f8e649a6
4
- data.tar.gz: b2fa2c58af2f031a4f216daa7adad6bff10cd8ab6d1023a224ca44344beff6e8
3
+ metadata.gz: d9ce3ca49ee184deac1fb058c9e43148b4b96bc26126e84c5842a2cbd9669b1a
4
+ data.tar.gz: f731f1e0aa69d80a1745775050e4e98b25b23c86d19e53e7878ea29c24a96422
5
5
  SHA512:
6
- metadata.gz: d1b34d7894d4a9c3211c4ce783278d0f087dba37215821c723b064a5272153c0ab806ffd0575963f99ccf8610fb2a79d8979aae78ad43a948df1fa368da96017
7
- data.tar.gz: f64b564c69ec0a9da2816e1032b78b3c42e22b4fb2bcccdc62d64524871ab0c0f48902c37557249f5c629a34e4299cafd493e80737c9bb9b15c6d7d0c89b1f2f
6
+ metadata.gz: cd9253fbbfdd74a4bf4b32ac9fb5568ab301623a5e817d54906462354e48e717fc145306b59fbb55b4deb8c5f877484ca26cb374ce169c8d333f81724768a688
7
+ data.tar.gz: 025de3eb95d4c04bcdef0db1d47d7b81b6a66f6d725e6acb38abc5a7b746ad97a8a60830a4b98264e273258753196339c99a86e571e9c6c47ed9d5f4d8cf7e5e
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) [![coverage report](https://gitlab.zuora.com/Connect/zuora-gem/badges/master/coverage.svg)](https://gitlab.zuora.com/Connect/zuora-gem/commits/master)
3
+ [![Gem Version](https://badge.fury.io/rb/zuora_api.svg)](https://badge.fury.io/rb/zuora_api) [![coverage report](https://gitlab.0.ecc.auw2.zuora/extension-products/shared-libraries/zuora-gem/badges/master/coverage.svg)](https://gitlab.0.ecc.auw2.zuora/extension-products/shared-libraries/zuora-gem/commits/master)
4
4
 
5
5
  ## Installation
6
6
  Add this line to your application's Gemfile:
@@ -102,6 +102,22 @@ module ZuoraAPI
102
102
  end
103
103
  end
104
104
 
105
+ class ZuoraUnexpectedError < Error
106
+ attr_reader :code, :response
107
+ attr_writer :default_message
108
+
109
+ def initialize(message = nil, response=nil, *args)
110
+ @code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
111
+ @message = message
112
+ @response = response
113
+ @default_message = "An unexpected error occurred"
114
+ end
115
+
116
+ def to_s
117
+ @message || @default_message
118
+ end
119
+ end
120
+
105
121
  class ZuoraAPITemporaryError < Error
106
122
  attr_reader :code, :response
107
123
  attr_writer :default_message
@@ -316,12 +316,11 @@ module ZuoraAPI
316
316
  def update_zconnect_provider
317
317
  region = update_region
318
318
  environment = update_environment
319
- mappings = {"US" => {"Sandbox" => "ZConnectSbx", "KubeSTG" => "ZConnectDev", "KubeDEV" => "ZConnectDev", "KubePROD" => "ZConnectDev", "Services" => "ZConnectQA", "Production" => "ZConnectProd", "Performance" => "ZConnectPT1", "Staging" => "ZConnectQA"},
320
- "NA" => {"Sandbox" => "ZConnectSbxNA", "Services" => "ZConnectQANA", "Production" => "ZConnectProdNA", "Performance" => "ZConnectPT1NA"},
321
- "EU" => {"Sandbox" => "ZConnectSbxEU", "Services" => "ZConnectQAEU", "Production" => "ZConnectProdEU", "Performance" => "ZConnectPT1EU"},
319
+ mappings = {"US" => {"Sandbox" => "ZConnectSbx", "KubeSTG" => "ZConnectDev", "KubeDEV" => "ZConnectDev", "KubePROD" => "ZConnectDev", "Services" => "ZConnectSvcUS", "Production" => "ZConnectProd", "Performance" => "ZConnectPT1", "Staging" => "ZConnectQA"},
320
+ "NA" => {"Sandbox" => "ZConnectSbxNA", "Services" => "ZConnectSvcNA", "Production" => "ZConnectProdNA", "Performance" => "ZConnectPT1NA"},
321
+ "EU" => {"Sandbox" => "ZConnectSbxEU", "Services" => "ZConnectSvcEU", "Production" => "ZConnectProdEU", "Performance" => "ZConnectPT1EU"},
322
322
  "Unknown" => {"Unknown" => "Unknown"}}
323
323
  self.zconnect_provider = mappings[region][environment]
324
- # raise "Can't find ZConnect Provider for #{region} region and #{environment} environment" if self.zconnect_provider.nil?
325
324
  end
326
325
 
327
326
  def aqua_endpoint(url="")
@@ -400,7 +399,7 @@ module ZuoraAPI
400
399
  when 'ZuoraAPI::Basic'
401
400
  self.new_session(auth_type: :basic)
402
401
  else
403
- raise "No Zuora Login Specified"
402
+ self.new_session(auth_type: :basic)
404
403
  end
405
404
  end
406
405
  raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error) if self.status != 'Active'
@@ -413,7 +412,10 @@ module ZuoraAPI
413
412
  end
414
413
  when 'ZuoraAPI::Basic'
415
414
  raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Basic Login, does not support Authentication of Type: #{auth_type}")
415
+ else
416
+ raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Unknown Login, does not support Authentication of Type: #{auth_type}")
416
417
  end
418
+
417
419
  raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error) if self.status != 'Active'
418
420
  return prefix ? "Bearer #{self.bearer_token}" : self.bearer_token.to_s
419
421
  end
@@ -508,8 +510,12 @@ module ZuoraAPI
508
510
  raise ZuoraAPI::Exceptions::ZuoraAPIConnectionTimeout.new("Received #{response.code} from downstream host", response)
509
511
  end
510
512
 
511
- if response.code == 504
513
+ # Check failure response code
514
+ case response.code
515
+ when 504
512
516
  raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received 504 from downstream host", response)
517
+ when 429
518
+ raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("The total number of concurrent requests has exceeded the limit allowed by the system. Please resubmit your request later.", response)
513
519
  end
514
520
 
515
521
  case type
@@ -576,10 +582,6 @@ module ZuoraAPI
576
582
  end
577
583
  end
578
584
  end
579
-
580
- if response.code == 429
581
- raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("The total number of concurrent requests has exceeded the limit allowed by the system. Please resubmit your request later.", response)
582
- end
583
585
 
584
586
  when :JSON
585
587
  body = body.dig("results").present? ? body["results"] : body if body.class == Hash
@@ -589,6 +591,10 @@ module ZuoraAPI
589
591
  codes_array = body.fetch("reasons", []).map {|error| error['code']}.compact
590
592
  codes_array = codes_array.push(body.dig("error", 'code')).compact if body.dig('error').class == Hash
591
593
 
594
+ if body['message'] == 'An unexpected error occurred'
595
+ raise ZuoraAPI::Exceptions::ZuoraUnexpectedError.new(body['message'], response)
596
+ end
597
+
592
598
  if body['message'] == "No bearer token" && response.code == 400
593
599
  raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Authentication type is not supported by this Login", response)
594
600
  end
@@ -684,11 +690,7 @@ module ZuoraAPI
684
690
 
685
691
  #All other errors
686
692
  if ![200,201].include?(response.code)
687
- if response.code == 429
688
- raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("The total number of concurrent requests has exceeded the limit allowed by the system. Please resubmit your request later.", response)
689
- else
690
- raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{response.message}", response)
691
- end
693
+ raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{response.message}", response)
692
694
  end
693
695
  end
694
696
  end
@@ -1,3 +1,3 @@
1
1
  module ZuoraAPI
2
- VERSION = "1.7.08"
2
+ VERSION = "1.7.09"
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.7.08
4
+ version: 1.7.09
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: 2019-09-26 00:00:00.000000000 Z
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler