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 +4 -4
- data/README.md +1 -1
- data/lib/zuora_api/exceptions.rb +16 -0
- data/lib/zuora_api/login.rb +17 -15
- data/lib/zuora_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9ce3ca49ee184deac1fb058c9e43148b4b96bc26126e84c5842a2cbd9669b1a
|
4
|
+
data.tar.gz: f731f1e0aa69d80a1745775050e4e98b25b23c86d19e53e7878ea29c24a96422
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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:
|
data/lib/zuora_api/exceptions.rb
CHANGED
@@ -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
|
data/lib/zuora_api/login.rb
CHANGED
@@ -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" => "
|
320
|
-
"NA" => {"Sandbox" => "ZConnectSbxNA", "Services" => "
|
321
|
-
"EU" => {"Sandbox" => "ZConnectSbxEU", "Services" => "
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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.7.
|
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-
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|