zuora_api 1.7.24 → 1.7.25
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/.gitignore +1 -0
- data/lib/zuora_api/exceptions.rb +25 -9
- data/lib/zuora_api/login.rb +81 -60
- data/lib/zuora_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a1994319f46f6759b6749f7f6f40909c4a485029a3500ddd673f7937e2aae16
|
4
|
+
data.tar.gz: a04062860cd33c0c3e7e3fe2fc5dc0c44a5fe3d61807d747935da571e9713d96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25cd0027b6ae0ab062d709e4352e7cf9e36ecdb0dc91e4a759a33bdb753aa5ee9826d6bc640d35bd320a017f09900fdea995a491bed05fa0dfd959ca36cbbca3
|
7
|
+
data.tar.gz: fcbd9b0b32c118e91084f4b279f9451dfd702d6f4410234d995801b3100a7dd23be067460794e4c87f729ee56043a6ca02943ee8c9606d6cb61cada83b68da4e
|
data/.gitignore
CHANGED
data/lib/zuora_api/exceptions.rb
CHANGED
@@ -7,7 +7,7 @@ module ZuoraAPI
|
|
7
7
|
attr_reader :code, :response
|
8
8
|
attr_writer :default_message
|
9
9
|
|
10
|
-
def initialize(message = nil,response=nil)
|
10
|
+
def initialize(message = nil,response=nil, errors = [], successes = [])
|
11
11
|
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
12
12
|
@message = message
|
13
13
|
@response = response
|
@@ -77,7 +77,7 @@ module ZuoraAPI
|
|
77
77
|
attr_reader :code, :response
|
78
78
|
attr_writer :default_message
|
79
79
|
|
80
|
-
def initialize(message = nil,response=nil,
|
80
|
+
def initialize(message = nil,response=nil, errors = [], successes = [], *args)
|
81
81
|
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
82
82
|
@message = message
|
83
83
|
@response = response
|
@@ -89,11 +89,27 @@ module ZuoraAPI
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
class ZuoraAPIUnkownError < Error
|
93
|
+
attr_reader :code, :response
|
94
|
+
attr_writer :default_message
|
95
|
+
|
96
|
+
def initialize(message = nil,response=nil, errors = [], successes = [], *args)
|
97
|
+
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
98
|
+
@message = message
|
99
|
+
@response = response
|
100
|
+
@default_message = "An unkown error occured. Workflow is not responsible. Please contact Support."
|
101
|
+
end
|
102
|
+
|
103
|
+
def to_s
|
104
|
+
@message || @default_message
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
92
108
|
class ZuoraAPILockCompetition < Error
|
93
109
|
attr_reader :code, :response
|
94
110
|
attr_writer :default_message
|
95
111
|
|
96
|
-
def initialize(message = nil,response=nil,
|
112
|
+
def initialize(message = nil,response=nil, errors = [], successes = [], *args)
|
97
113
|
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
98
114
|
@message = message
|
99
115
|
@response = response
|
@@ -109,7 +125,7 @@ module ZuoraAPI
|
|
109
125
|
attr_reader :code, :response
|
110
126
|
attr_writer :default_message
|
111
127
|
|
112
|
-
def initialize(message = nil,response=nil,
|
128
|
+
def initialize(message = nil,response=nil, errors = [], successes = [], *args)
|
113
129
|
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
114
130
|
@message = message
|
115
131
|
@response = response
|
@@ -125,7 +141,7 @@ module ZuoraAPI
|
|
125
141
|
attr_reader :code, :response
|
126
142
|
attr_writer :default_message
|
127
143
|
|
128
|
-
def initialize(message = nil, response=nil, *args)
|
144
|
+
def initialize(message = nil, response=nil, errors = [], successes = [], *args)
|
129
145
|
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
130
146
|
@message = message
|
131
147
|
@response = response
|
@@ -141,7 +157,7 @@ module ZuoraAPI
|
|
141
157
|
attr_reader :code, :response
|
142
158
|
attr_writer :default_message
|
143
159
|
|
144
|
-
def initialize(message = nil,response=nil, *args)
|
160
|
+
def initialize(message = nil,response=nil, errors = [], successes = [], *args)
|
145
161
|
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
146
162
|
@message = message
|
147
163
|
@response = response
|
@@ -157,7 +173,7 @@ module ZuoraAPI
|
|
157
173
|
attr_reader :code, :response
|
158
174
|
attr_writer :default_message
|
159
175
|
|
160
|
-
def initialize(message = nil,response=nil,
|
176
|
+
def initialize(message = nil,response=nil, errors = [], successes = [], *args)
|
161
177
|
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
162
178
|
@message = message
|
163
179
|
@response = response
|
@@ -173,7 +189,7 @@ module ZuoraAPI
|
|
173
189
|
attr_reader :code, :response
|
174
190
|
attr_writer :default_message
|
175
191
|
|
176
|
-
def initialize(message = nil,response=nil,
|
192
|
+
def initialize(message = nil,response=nil, errors = [], successes = [], *args)
|
177
193
|
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
178
194
|
@message = message
|
179
195
|
@response = response
|
@@ -189,7 +205,7 @@ module ZuoraAPI
|
|
189
205
|
attr_reader :code, :response
|
190
206
|
attr_writer :default_message
|
191
207
|
|
192
|
-
def initialize(message = nil,response=nil,
|
208
|
+
def initialize(message = nil,response=nil, errors = [], successes = [], *args)
|
193
209
|
@code = response.present? && response.class.to_s == "HTTParty::Response" ? response.code : nil
|
194
210
|
@message = message
|
195
211
|
@response = response
|
data/lib/zuora_api/login.rb
CHANGED
@@ -32,7 +32,8 @@ module ZuoraAPI
|
|
32
32
|
ZuoraAPI::Exceptions::ZuoraAPITemporaryError,
|
33
33
|
ZuoraAPI::Exceptions::ZuoraDataIntegrity,
|
34
34
|
ZuoraAPI::Exceptions::ZuoraAPIInternalServerError,
|
35
|
-
ZuoraAPI::Exceptions::ZuoraUnexpectedError
|
35
|
+
ZuoraAPI::Exceptions::ZuoraUnexpectedError,
|
36
|
+
ZuoraAPI::Exceptions::ZuoraAPIUnkownError
|
36
37
|
].freeze
|
37
38
|
|
38
39
|
attr_accessor :region, :url, :wsdl_number, :current_session, :bearer_token, :oauth_session_expires_at, :environment, :status, :errors, :current_error, :user_info, :tenant_id, :tenant_name, :entity_id, :timeout_sleep, :hostname, :zconnect_provider
|
@@ -531,73 +532,24 @@ module ZuoraAPI
|
|
531
532
|
|
532
533
|
case type
|
533
534
|
when :SOAP
|
534
|
-
error
|
535
|
-
message = body.xpath('//fns:FaultMessage', 'fns' =>'http://fault.api.zuora.com/').text
|
536
|
-
|
537
|
-
if error.blank? || message.blank?
|
538
|
-
error = body.xpath('//faultcode').text
|
539
|
-
message = body.xpath('//faultstring').text
|
540
|
-
end
|
541
|
-
|
542
|
-
if error.blank? || message.blank?
|
543
|
-
error = body.xpath('//ns1:Code', 'ns1' =>'http://api.zuora.com/').text
|
544
|
-
message = body.xpath('//ns1:Message', 'ns1' =>'http://api.zuora.com/').text
|
545
|
-
end
|
546
|
-
|
547
|
-
#Update/Create/Delete Calls with multiple requests and responses
|
548
|
-
if body.xpath('//ns1:result', 'ns1' =>'http://api.zuora.com/').size > 0 && body.xpath('//ns1:Errors', 'ns1' =>'http://api.zuora.com/').size > 0
|
549
|
-
error = []
|
550
|
-
success = []
|
551
|
-
body.xpath('//ns1:result', 'ns1' =>'http://api.zuora.com/').each_with_index do |call, object_index|
|
552
|
-
if call.xpath('./ns1:Success', 'ns1' =>'http://api.zuora.com/').text == 'false' && call.xpath('./ns1:Errors', 'ns1' =>'http://api.zuora.com/').size > 0
|
553
|
-
message = "#{call.xpath('./*/ns1:Code', 'ns1' =>'http://api.zuora.com/').text}::#{call.xpath('./*/ns1:Message', 'ns1' =>'http://api.zuora.com/').text}"
|
554
|
-
error.push(message)
|
555
|
-
else
|
556
|
-
success.push(call.xpath('./ns1:Id', 'ns1' =>'http://api.zuora.com/').text)
|
557
|
-
end
|
558
|
-
end
|
559
|
-
end
|
535
|
+
error, success, message = get_soap_error_and_message(body)
|
560
536
|
|
561
537
|
#By default response if not passed in for SOAP as all SOAP is 200
|
562
538
|
if error.present?
|
563
539
|
if error.class == String
|
564
|
-
|
565
|
-
when "INVALID_SESSION"
|
566
|
-
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{error}::#{message}", response)
|
567
|
-
when "REQUEST_EXCEEDED_LIMIT"
|
568
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{error}::#{message}", response)
|
569
|
-
when "LOCK_COMPETITION"
|
570
|
-
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{error}::#{message}", response)
|
571
|
-
when "BATCH_FAIL_ERROR"
|
572
|
-
if message.include?("optimistic locking failed")
|
573
|
-
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{error}::#{message}", response)
|
574
|
-
else
|
575
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{error}::#{message}", response)
|
576
|
-
end
|
577
|
-
when "TEMPORARY_ERROR"
|
578
|
-
raise ZuoraAPI::Exceptions::ZuoraAPITemporaryError.new("#{error}::#{message}", response)
|
579
|
-
when "INVALID_VALUE"
|
580
|
-
if message.include?("data integrity violation")
|
581
|
-
raise ZuoraAPI::Exceptions::ZuoraDataIntegrity.new("Data Integrity Violation", response)
|
582
|
-
else
|
583
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{error}::#{message}", response)
|
584
|
-
end
|
585
|
-
else
|
586
|
-
if response.code == 500
|
587
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new('Zuora API Internal Server Error', response)
|
588
|
-
else
|
589
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{error}::#{message}", response) if error.present?
|
590
|
-
end
|
591
|
-
end
|
540
|
+
raise_errors_helper(error, message, response)
|
592
541
|
elsif error.class == Array
|
542
|
+
|
593
543
|
if error[0].include?("LOCK_COMPETITION") && error.count == 1
|
594
544
|
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new(error.group_by {|v| v}.map {|k,v| "(#{v.size}x) - #{k == "::" ? 'UNKNOWN::No error provided' : k}"}.join(', '), response)
|
545
|
+
end
|
546
|
+
|
547
|
+
if error.uniq.size == 1
|
548
|
+
err, msg = error[0].split('::')
|
549
|
+
err = "(#{error.size}x) - #{err}"
|
550
|
+
raise_errors_helper(err, msg, response, error, success)
|
595
551
|
else
|
596
|
-
|
597
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new('Zuora API Internal Server Error', response)
|
598
|
-
else
|
599
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(error.group_by {|v| v}.map {|k,v| "(#{v.size}x) - #{k == "::" ? 'UNKNOWN::No error provided' : k}"}.join(', '), response, error, success)
|
600
|
-
end
|
552
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(error.group_by {|v| v}.map {|k,v| "(#{v.size}x) - #{k == "::" ? 'UNKNOWN::No error provided' : k}"}.join(', '), response, error, success)
|
601
553
|
end
|
602
554
|
end
|
603
555
|
elsif response.code == 500
|
@@ -722,6 +674,75 @@ module ZuoraAPI
|
|
722
674
|
end
|
723
675
|
end
|
724
676
|
|
677
|
+
def get_soap_error_and_message(body)
|
678
|
+
error = body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text
|
679
|
+
message = body.xpath('//fns:FaultMessage', 'fns' =>'http://fault.api.zuora.com/').text
|
680
|
+
|
681
|
+
if error.blank? || message.blank?
|
682
|
+
error = body.xpath('//faultcode').text
|
683
|
+
message = body.xpath('//faultstring').text
|
684
|
+
end
|
685
|
+
|
686
|
+
if error.blank? || message.blank?
|
687
|
+
error = body.xpath('//ns1:Code', 'ns1' =>'http://api.zuora.com/').text
|
688
|
+
message = body.xpath('//ns1:Message', 'ns1' =>'http://api.zuora.com/').text
|
689
|
+
end
|
690
|
+
|
691
|
+
#Update/Create/Delete Calls with multiple requests and responses
|
692
|
+
if body.xpath('//ns1:result', 'ns1' =>'http://api.zuora.com/').size > 0 && body.xpath('//ns1:Errors', 'ns1' =>'http://api.zuora.com/').size > 0
|
693
|
+
error = []
|
694
|
+
success = []
|
695
|
+
body.xpath('//ns1:result', 'ns1' =>'http://api.zuora.com/').each_with_index do |call, object_index|
|
696
|
+
if call.xpath('./ns1:Success', 'ns1' =>'http://api.zuora.com/').text == 'false' && call.xpath('./ns1:Errors', 'ns1' =>'http://api.zuora.com/').size > 0
|
697
|
+
message = "#{call.xpath('./*/ns1:Code', 'ns1' =>'http://api.zuora.com/').text}::#{call.xpath('./*/ns1:Message', 'ns1' =>'http://api.zuora.com/').text}"
|
698
|
+
error.push(message)
|
699
|
+
else
|
700
|
+
success.push(call.xpath('./ns1:Id', 'ns1' =>'http://api.zuora.com/').text)
|
701
|
+
end
|
702
|
+
end
|
703
|
+
end
|
704
|
+
return error, success, message
|
705
|
+
end
|
706
|
+
|
707
|
+
def raise_errors_helper(error, message, response, errors = [], success = [])
|
708
|
+
case error
|
709
|
+
when /.*INVALID_SESSION/
|
710
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{error}::#{message}", response, errors, success)
|
711
|
+
when /.*REQUEST_EXCEEDED_LIMIT/
|
712
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{error}::#{message}", response, errors, success)
|
713
|
+
when /.*LOCK_COMPETITION/
|
714
|
+
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{error}::#{message}", response, errors, success)
|
715
|
+
when /.*BATCH_FAIL_ERROR/
|
716
|
+
if message.include?("optimistic locking failed")
|
717
|
+
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{error}::#{message}", response, errors, success)
|
718
|
+
else
|
719
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{error}::#{message}", response, errors, success)
|
720
|
+
end
|
721
|
+
when /.*TEMPORARY_ERROR/
|
722
|
+
raise ZuoraAPI::Exceptions::ZuoraAPITemporaryError.new("#{error}::#{message}", response, errors, success)
|
723
|
+
when /.*INVALID_VALUE/
|
724
|
+
if message.include?("data integrity violation")
|
725
|
+
raise ZuoraAPI::Exceptions::ZuoraDataIntegrity.new("Data Integrity Violation", response, errors), success
|
726
|
+
else
|
727
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{error}::#{message}", response, errors, success)
|
728
|
+
end
|
729
|
+
when /.*UNKNOWN_ERROR/
|
730
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIUnkownError.new("#{error}::#{message}", response, errors, success)
|
731
|
+
when /.*soapenv:Server.*/
|
732
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new('Zuora API Internal Server Error', response, errors, success)
|
733
|
+
else
|
734
|
+
if response.code == 500
|
735
|
+
if message.present?
|
736
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{error}::#{message}", response, errors, success)
|
737
|
+
else
|
738
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new('Zuora API Internal Server Error', response, errors, success)
|
739
|
+
end
|
740
|
+
else
|
741
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{error}::#{message}", response, errors, success) if error.present?
|
742
|
+
end
|
743
|
+
end
|
744
|
+
end
|
745
|
+
|
725
746
|
def aqua_query(queryName: '', query: '', version: '1.2', jobName: 'Aqua',partner: '', project: '')
|
726
747
|
params = {
|
727
748
|
"format" => 'csv',
|
data/lib/zuora_api/version.rb
CHANGED