zuora_api 1.6.13 → 1.6.14

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
  SHA1:
3
- metadata.gz: da08f80d742b03a45b22fe84857980e2fb5ea2d7
4
- data.tar.gz: 80272875b0d22ecccd0c7eb043b65901978cc4dc
3
+ metadata.gz: eb1f443e04878b031dbbe67b84f50469a7d3beaa
4
+ data.tar.gz: 9b30ebd31682149f9b1942dfdb91ed6f2ec86dff
5
5
  SHA512:
6
- metadata.gz: 2ad860b5226a2c423e2663e5ffc0a75d8496467998fd5ad521b7745db7d5fe3a1cf1cdfe6d87cf9bcfb4f8d4d8252690802c26d76ec2f3ca12a83d8004f5b56b
7
- data.tar.gz: 73bd63442c49eda3056ff1cfbf245ba018c185e191860d4a13d136d5bf3764012f1be5795aa1a4f106d5a610c601d42ea34e3f76650fbb34ae26e1cd1aa9d6ea
6
+ metadata.gz: eb1ded3eff4c69170246fcc97e47bf8ebea328fb0955e1451e097732829b846f87fdea3c7ae61d0257f2a35825e25f179cff557447c1fedb36fb818b2374b18e
7
+ data.tar.gz: 29679e0b2db46c700fa44ceb9f2e9f47b544ee258310d2043e913117ae6e3558dc5d1544af9c0e3e44f248ed8a4171c99369522c74f930bf5b891cca8ce59ba1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zuora_api (1.6.13)
4
+ zuora_api (1.6.14)
5
5
  httparty
6
6
  nokogiri
7
7
  railties (>= 4.1.0, < 5.2)
@@ -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 = !self.entity_id.blank? ? {"entityId" => self.entity_id, 'Content-Type' => "text/xml; charset=utf-8"} : {'Content-Type' => "text/xml; charset=utf-8"}
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["entityId"] = self.entity_id
455
- headers["Zuora-Entity-Ids"] = self.entity_id if !url.end_with?("/oauth/token")
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({"entityId" => self.entity_id}) if !self.entity_id.blank?
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? ? {:entityId => self.entity_id } : {}
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
@@ -1,3 +1,3 @@
1
1
  module ZuoraAPI
2
- VERSION = "1.6.13"
2
+ VERSION = "1.6.14"
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.6.13
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-13 00:00:00.000000000 Z
11
+ date: 2018-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler