zuora_api 1.6.13 → 1.6.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/Gemfile.lock +1 -1
- data/lib/zuora_api/login.rb +18 -6
- data/lib/zuora_api/logins/oauth.rb +1 -1
- data/lib/zuora_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb1f443e04878b031dbbe67b84f50469a7d3beaa
|
4
|
+
data.tar.gz: 9b30ebd31682149f9b1942dfdb91ed6f2ec86dff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb1ded3eff4c69170246fcc97e47bf8ebea328fb0955e1451e097732829b846f87fdea3c7ae61d0257f2a35825e25f179cff557447c1fedb36fb818b2374b18e
|
7
|
+
data.tar.gz: 29679e0b2db46c700fa44ceb9f2e9f47b544ee258310d2043e913117ae6e3558dc5d1544af9c0e3e44f248ed8a4171c99369522c74f930bf5b891cca8ce59ba1
|
data/Gemfile.lock
CHANGED
data/lib/zuora_api/login.rb
CHANGED
@@ -12,7 +12,7 @@ module ZuoraAPI
|
|
12
12
|
|
13
13
|
def initialize(url: nil, entity_id: nil, session: nil, status: nil, **keyword_args)
|
14
14
|
@url = url.gsub(/(\d{2}\.\d)$/, MIN_Endpoint)
|
15
|
-
@entity_id = entity_id
|
15
|
+
@entity_id = get_entity_id(entity_id: entity_id)
|
16
16
|
@errors = Hash.new
|
17
17
|
@current_session = session
|
18
18
|
@status = status.blank? ? "Active" : status
|
@@ -46,6 +46,18 @@ module ZuoraAPI
|
|
46
46
|
}
|
47
47
|
end
|
48
48
|
|
49
|
+
def get_entity_id(entity_id: nil)
|
50
|
+
if entity_id.present?
|
51
|
+
entity_match = /[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}$/.match(entity_id)
|
52
|
+
if entity_match.blank?
|
53
|
+
raise "Entity length is wrong." if entity_id.length != 32
|
54
|
+
part_one, part_two, part_three, part_four, part_five = [entity_id[0..7], entity_id[8..11], entity_id[12..15], entity_id[16..19], entity_id[20..31]]
|
55
|
+
entity_id = "#{part_one}-#{part_two}-#{part_three}-#{part_four}-#{part_five}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
return entity_id
|
59
|
+
end
|
60
|
+
|
49
61
|
def update_environment
|
50
62
|
if !self.url.blank?
|
51
63
|
env_path = self.url.split('https://').last.split('.zuora.com').first
|
@@ -392,7 +404,7 @@ module ZuoraAPI
|
|
392
404
|
|
393
405
|
base = self.url.include?(".com") ? self.url.split(".com")[0].concat(".com") : self.url.split(".eu")[0].concat(".eu")
|
394
406
|
url = object ? "#{base}/apps/api/describe/#{object}" : "#{base}/apps/api/describe/"
|
395
|
-
headers =
|
407
|
+
headers = self.entity_id.present? ? {"Zuora-Entity-Ids" => self.entity_id, 'Content-Type' => "text/xml; charset=utf-8"} : {'Content-Type' => "text/xml; charset=utf-8"}
|
396
408
|
response = HTTParty.get(url, headers: {"Authorization" => self.get_session(prefix: true, auth_type: :basic)}.merge(headers), :timeout => 120)
|
397
409
|
|
398
410
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("Session Expired") if response.code == 401
|
@@ -447,12 +459,12 @@ module ZuoraAPI
|
|
447
459
|
return des_hash
|
448
460
|
end
|
449
461
|
|
450
|
-
def rest_call(method: :get, body: nil,headers: {}, url: rest_endpoint("catalog/products?pageSize=4"), debug: false, errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError, ZuoraAPI::Exceptions::ZuoraAPIError, ZuoraAPI::Exceptions::ZuoraAPIRequestLimit, ZuoraAPI::Exceptions::ZuoraAPILockCompetition], z_session: true, session_type: :basic, timeout_retry: false, timeout: 120, **keyword_args)
|
462
|
+
def rest_call(method: :get, body: nil, headers: {}, url: rest_endpoint("catalog/products?pageSize=4"), debug: false, errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError, ZuoraAPI::Exceptions::ZuoraAPIError, ZuoraAPI::Exceptions::ZuoraAPIRequestLimit, ZuoraAPI::Exceptions::ZuoraAPILockCompetition], z_session: true, session_type: :basic, timeout_retry: false, timeout: 120, **keyword_args)
|
451
463
|
tries ||= 2
|
452
464
|
|
453
465
|
if self.entity_id.present?
|
454
|
-
headers["
|
455
|
-
headers["
|
466
|
+
headers["Zuora-Entity-Ids"] = self.entity_id if headers.dig("Zuora-Entity-Ids").nil?
|
467
|
+
headers.delete_if { |key, value| ["entityId", "entityName"].include?(key.to_s) }
|
456
468
|
end
|
457
469
|
|
458
470
|
raise "Method not supported, supported methods include: :get, :post, :put, :delete, :patch, :head, :options" if ![:get, :post, :put, :delete, :patch, :head, :options].include?(method)
|
@@ -572,7 +584,7 @@ module ZuoraAPI
|
|
572
584
|
http.use_ssl = true if uri.scheme.downcase == 'https'
|
573
585
|
if z_session
|
574
586
|
headers = headers.merge({"Authorization" => self.get_session(prefix: true)})
|
575
|
-
headers = headers.merge({"
|
587
|
+
headers = headers.merge({"Zuora-Entity-Ids" => self.entity_id}) if !self.entity_id.blank?
|
576
588
|
end
|
577
589
|
|
578
590
|
response_save = nil
|
@@ -31,7 +31,7 @@ module ZuoraAPI
|
|
31
31
|
|
32
32
|
def get_z_session(debug: false)
|
33
33
|
tries ||= 2
|
34
|
-
headers = self.entity_id.present? ? {
|
34
|
+
headers = self.entity_id.present? ? {"Zuora-Entity-Ids" => self.entity_id } : {}
|
35
35
|
output_json, response = self.rest_call(:url => self.rest_endpoint("connections"), :session_type => :bearer, :headers => headers)
|
36
36
|
self.current_session = response.headers.to_h['set-cookie'][0].split(';')[0].split('=',2)[1].gsub('%3D', '=')
|
37
37
|
rescue ZuoraAPI::Exceptions::ZuoraAPISessionError => ex
|
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.6.
|
4
|
+
version: 1.6.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: 2018-11-
|
11
|
+
date: 2018-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|