zuora_api 1.7.13 → 1.7.14
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/lib/zuora_api/login.rb +19 -11
- data/lib/zuora_api/logins/basic.rb +6 -3
- data/lib/zuora_api/logins/oauth.rb +14 -10
- 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: 1341b77e28327eae9e39ecf734228e3e17d1588547521f82b146535b1bd5b624
|
4
|
+
data.tar.gz: a0885a72edd3a19ecc0d78df21de5b853344686a1576048143738c6adedbc536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e5af953d2398afbe87dcc58abe3875d62534af545969d4cef868d622546fb86cbcf2028dc061733f164f72881b34835e5cf53dcf183b5aa543c58ca060393bb
|
7
|
+
data.tar.gz: 9af30e6797dc920c78bb8f075b0e72a02ee532645c457fe91eb87156bf57590706b91e275ad1f711b82bda8f7831639b31ad56bb2434ecfa48df8c94b8dc39f4
|
data/lib/zuora_api/login.rb
CHANGED
@@ -382,10 +382,10 @@ module ZuoraAPI
|
|
382
382
|
return self.wsdl_number > 68 ? '%Y-%m-%d' : '%Y-%m-%dT%H:%M:%S'
|
383
383
|
end
|
384
384
|
|
385
|
-
def new_session(auth_type: :basic, debug: false)
|
385
|
+
def new_session(auth_type: :basic, debug: false, zuora_track_id: nil)
|
386
386
|
end
|
387
387
|
|
388
|
-
def get_session(prefix: false, auth_type: :basic)
|
388
|
+
def get_session(prefix: false, auth_type: :basic, zuora_track_id: nil)
|
389
389
|
Rails.logger.debug("Get session for #{auth_type} - #{self.class.to_s}") if Rails.env.to_s == 'development'
|
390
390
|
case auth_type
|
391
391
|
when :basic
|
@@ -393,13 +393,13 @@ module ZuoraAPI
|
|
393
393
|
case self.class.to_s
|
394
394
|
when 'ZuoraAPI::Oauth'
|
395
395
|
if self.bearer_token.blank? || self.oauth_expired?
|
396
|
-
self.new_session(auth_type: :bearer)
|
396
|
+
self.new_session(auth_type: :bearer, zuora_track_id: zuora_track_id)
|
397
397
|
end
|
398
|
-
self.get_z_session if self.status == 'Active'
|
398
|
+
self.get_z_session(zuora_track_id: zuora_track_id) if self.status == 'Active'
|
399
399
|
when 'ZuoraAPI::Basic'
|
400
|
-
self.new_session(auth_type: :basic)
|
400
|
+
self.new_session(auth_type: :basic, zuora_track_id: zuora_track_id)
|
401
401
|
else
|
402
|
-
self.new_session(auth_type: :basic)
|
402
|
+
self.new_session(auth_type: :basic, zuora_track_id: zuora_track_id)
|
403
403
|
end
|
404
404
|
end
|
405
405
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error) if self.status != 'Active'
|
@@ -408,7 +408,7 @@ module ZuoraAPI
|
|
408
408
|
case self.class.to_s
|
409
409
|
when 'ZuoraAPI::Oauth'
|
410
410
|
if self.bearer_token.blank? || self.oauth_expired?
|
411
|
-
self.new_session(auth_type: :bearer)
|
411
|
+
self.new_session(auth_type: :bearer, zuora_track_id: zuora_track_id)
|
412
412
|
end
|
413
413
|
when 'ZuoraAPI::Basic'
|
414
414
|
raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Basic Login, does not support Authentication of Type: #{auth_type}")
|
@@ -421,7 +421,7 @@ module ZuoraAPI
|
|
421
421
|
end
|
422
422
|
end
|
423
423
|
|
424
|
-
def soap_call(ns1: 'ns1', ns2: 'ns2', batch_size: nil, single_transaction: false, debug: false, errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError].concat(ZUORA_API_ERRORS), z_session: true, timeout_retry: false, timeout: 120,**keyword_args)
|
424
|
+
def soap_call(ns1: 'ns1', ns2: 'ns2', batch_size: nil, single_transaction: false, debug: false, zuora_track_id: nil, errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError].concat(ZUORA_API_ERRORS), z_session: true, timeout_retry: false, timeout: 120,**keyword_args)
|
425
425
|
tries ||= 2
|
426
426
|
xml = Nokogiri::XML::Builder.new do |xml|
|
427
427
|
xml['SOAP-ENV'].Envelope('xmlns:SOAP-ENV' => "http://schemas.xmlsoap.org/soap/envelope/",
|
@@ -431,7 +431,7 @@ module ZuoraAPI
|
|
431
431
|
"xmlns:#{ns1}" => "http://api.zuora.com/") do
|
432
432
|
xml['SOAP-ENV'].Header do
|
433
433
|
xml["#{ns1}"].SessionHeader do
|
434
|
-
xml["#{ns1}"].session self.get_session(prefix: false, auth_type: :basic)
|
434
|
+
xml["#{ns1}"].session self.get_session(prefix: false, auth_type: :basic, zuora_track_id: zuora_track_id)
|
435
435
|
end
|
436
436
|
if single_transaction
|
437
437
|
xml["#{ns1}"].CallOptions do
|
@@ -454,7 +454,15 @@ module ZuoraAPI
|
|
454
454
|
input_xml.xpath('//ns1:session', 'ns1' =>'http://api.zuora.com/').children.remove
|
455
455
|
Rails.logger.debug("Request SOAP XML: #{input_xml.to_xml(:save_with => XML_SAVE_OPTIONS).strip}") if debug
|
456
456
|
|
457
|
-
|
457
|
+
headers = { 'Content-Type' => "text/xml; charset=utf-8" }
|
458
|
+
headers['Zuora-Track-Id'] = zuora_track_id if zuora_track_id.present?
|
459
|
+
|
460
|
+
response = HTTParty.post(
|
461
|
+
self.url,
|
462
|
+
:body => xml.doc.to_xml(:save_with => XML_SAVE_OPTIONS).strip,
|
463
|
+
:headers => headers,
|
464
|
+
:timeout => timeout
|
465
|
+
)
|
458
466
|
output_xml = Nokogiri::XML(response.body)
|
459
467
|
Rails.logger.debug("Response SOAP XML: #{output_xml.to_xml(:save_with => XML_SAVE_OPTIONS).strip}") if debug
|
460
468
|
|
@@ -462,7 +470,7 @@ module ZuoraAPI
|
|
462
470
|
rescue ZuoraAPI::Exceptions::ZuoraAPISessionError => ex
|
463
471
|
if !(tries -= 1).zero? && z_session
|
464
472
|
Rails.logger.debug("SOAP Call - Session Invalid")
|
465
|
-
self.new_session(auth_type: :basic)
|
473
|
+
self.new_session(auth_type: :basic, zuora_track_id: zuora_track_id)
|
466
474
|
retry
|
467
475
|
else
|
468
476
|
if errors.include?(ex.class)
|
@@ -9,7 +9,7 @@ module ZuoraAPI
|
|
9
9
|
super
|
10
10
|
end
|
11
11
|
|
12
|
-
def new_session(auth_type: :basic, debug: false)
|
12
|
+
def new_session(auth_type: :basic, debug: false, zuora_track_id: nil)
|
13
13
|
raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Basic Login, does not support Authentication of Type: #{auth_type}") if auth_type != :basic
|
14
14
|
raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Request Basic Login but either 'Username' or 'Password' were not passed.") if (self.password.blank? && self.username.blank?)
|
15
15
|
|
@@ -30,8 +30,11 @@ module ZuoraAPI
|
|
30
30
|
input_xml = Nokogiri::XML(request.to_xml(:save_with => XML_SAVE_OPTIONS).strip)
|
31
31
|
input_xml.xpath('//ns1:session', 'ns1' =>'http://api.zuora.com/').children.remove
|
32
32
|
Rails.logger.debug('Connect') {"SOAP XML: #{input_xml.to_xml(:save_with => XML_SAVE_OPTIONS).strip}"} if debug
|
33
|
-
|
34
|
-
|
33
|
+
|
34
|
+
headers = { 'Content-Type' => "text/xml; charset=utf-8" }
|
35
|
+
headers['Zuora-Track-Id'] = zuora_track_id if zuora_track_id.present?
|
36
|
+
|
37
|
+
response_query = HTTParty.post(self.url,:body => request.to_xml(:save_with => XML_SAVE_OPTIONS).strip, :headers => headers, :timeout => 10)
|
35
38
|
output_xml = Nokogiri::XML(response_query.body)
|
36
39
|
Rails.logger.debug('Connect') {"Response Code: #{response_query.code} SOAP XML: #{output_xml.to_xml(:save_with => XML_SAVE_OPTIONS).strip}"} if debug
|
37
40
|
|
@@ -11,15 +11,15 @@ module ZuoraAPI
|
|
11
11
|
super
|
12
12
|
end
|
13
13
|
|
14
|
-
def new_session(raise_errors: false, auth_type: nil)
|
14
|
+
def new_session(raise_errors: false, auth_type: nil, zuora_track_id: nil)
|
15
15
|
if auth_type == :bearer
|
16
|
-
get_bearer_token()
|
16
|
+
get_bearer_token(zuora_track_id: zuora_track_id)
|
17
17
|
elsif auth_type == :basic
|
18
|
-
get_bearer_token() if self.oauth_expired?
|
19
|
-
get_z_session() if self.status == 'Active'
|
18
|
+
get_bearer_token(zuora_track_id: zuora_track_id) if self.oauth_expired?
|
19
|
+
get_z_session(zuora_track_id: zuora_track_id) if self.status == 'Active'
|
20
20
|
else
|
21
|
-
get_bearer_token()
|
22
|
-
get_z_session() if self.status == 'Active'
|
21
|
+
get_bearer_token(zuora_track_id: zuora_track_id)
|
22
|
+
get_z_session(zuora_track_id: zuora_track_id) if self.status == 'Active'
|
23
23
|
end
|
24
24
|
return self.status
|
25
25
|
end
|
@@ -29,9 +29,10 @@ module ZuoraAPI
|
|
29
29
|
return self.bearer_token
|
30
30
|
end
|
31
31
|
|
32
|
-
def get_z_session(debug: false)
|
32
|
+
def get_z_session(debug: false, zuora_track_id: nil)
|
33
33
|
tries ||= 2
|
34
|
-
headers = self.entity_id.present? ? {"Zuora-Entity-Ids" => self.entity_id } : {}
|
34
|
+
headers = self.entity_id.present? ? {"Zuora-Entity-Ids" => self.entity_id } : {}
|
35
|
+
headers['Zuora-Track-Id'] = zuora_track_id if zuora_track_id.present?
|
35
36
|
output_json, response = self.rest_call(:url => self.rest_endpoint("connections"), :session_type => :bearer, :headers => headers)
|
36
37
|
self.current_session = response.headers.to_h['set-cookie'][0].split(';')[0].split('=',2)[1].gsub('%3D', '=')
|
37
38
|
rescue ZuoraAPI::Exceptions::ZuoraAPISessionError => ex
|
@@ -64,15 +65,18 @@ module ZuoraAPI
|
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
|
-
def get_bearer_token
|
68
|
+
def get_bearer_token(zuora_track_id: nil)
|
68
69
|
tries ||= 2
|
69
70
|
raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Request Oauth Login but either 'Oauth Client Id' or 'Oauth Secret' were not passed") if self.oauth_client_id.blank? || self.oauth_secret.blank?
|
70
71
|
|
72
|
+
headers = { "content-type" => "application/x-www-form-urlencoded" }
|
73
|
+
headers['Zuora-Track-Id'] = zuora_track_id if zuora_track_id.present?
|
74
|
+
|
71
75
|
output_json, response = self.rest_call(:method => :post,
|
72
76
|
:url => self.rest_endpoint.chomp('v1/').concat("oauth/token"),
|
73
77
|
:z_session => false,
|
74
78
|
:session_type => :bearer,
|
75
|
-
:headers =>
|
79
|
+
:headers => headers,
|
76
80
|
:body => {"client_id"=> self.oauth_client_id, "client_secret"=>self.oauth_secret, "grant_type" =>"client_credentials"}
|
77
81
|
)
|
78
82
|
|
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.14
|
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-
|
11
|
+
date: 2019-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|