zuora_api 1.6.38 → 1.6.39

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
  SHA256:
3
- metadata.gz: db27825f234df0bf22824cd3100d5b4ed5f6565fc46cbbbab742dd62f2b02261
4
- data.tar.gz: 298711ae7f8362f91c67c8f66fa3b685e7f8beb44eb3dbc9233225b5e5e6e1e4
3
+ metadata.gz: 327020361fd779fff57aad1eae6b019cb0d89117e5e6a2f43bcb6b73577287ab
4
+ data.tar.gz: 14b99e36c696d2b8627fce73ad56ae24e6e49e3805a480f532d9a42837638405
5
5
  SHA512:
6
- metadata.gz: cf541c7e898feec11cc498a81fa1f3eacb9920d8315eee5feca4001ea656de14c71b14fcca73ada4065c80950aa25b490d054b61c59432588d60e8a7fae22eeb
7
- data.tar.gz: 2d4f8d1c8c141e3646eb25deefac6acd288ff2e996d73736ce96c8f8d9a3844079bfff08b08f2af2f07cc205fbd870b8896af61bb77b72e97aac68e859627c36
6
+ metadata.gz: 1cbb02c248d3cf410fdb16b4dfaabe11b7cb5328c8c0ed665aa7bc878221a23b1db8cd1733f8c0f71a171deee979452c36885c783262e9c9c07fca3bc8e831ce
7
+ data.tar.gz: 13262076080a1aadfaa9bc40921c8287cf6c921e7dcd93d481b57d83d1878cc6b639f19f985f8814dbd90d113c8212cbe5b4519114e0c725dfad28224ae98545
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zuora_api (1.6.38)
4
+ zuora_api (1.6.39)
5
5
  httparty
6
6
  nokogiri
7
7
  railties (>= 4.1.0, < 5.2)
@@ -13,18 +13,24 @@ module ZuoraAPI
13
13
  CONNECTION_READ_EXCEPTIONS = [Net::ReadTimeout, Errno::ECONNRESET, Errno::EPIPE]
14
14
  ZUORA_API_ERRORS = [ZuoraAPI::Exceptions::ZuoraAPIError, ZuoraAPI::Exceptions::ZuoraAPIRequestLimit, ZuoraAPI::Exceptions::ZuoraAPILockCompetition, ZuoraAPI::Exceptions::ZuoraAPITemporaryError, ZuoraAPI::Exceptions::ZuoraDataIntegrity]
15
15
 
16
- attr_accessor :region, :url, :wsdl_number, :current_session, :environment, :status, :errors, :current_error, :user_info, :tenant_id, :tenant_name, :entity_id, :timeout_sleep, :hostname, :zconnect_provider
16
+ 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
17
17
 
18
- def initialize(url: nil, entity_id: nil, session: nil, status: nil, **keyword_args)
18
+ def initialize(url: nil, entity_id: nil, session: nil, status: nil, bearer_token: nil, oauth_session_expires_at: nil, **keyword_args)
19
19
  raise "URL is nil or empty, but URL is required" if url.nil? || url.empty?
20
20
  # raise "URL is improper. URL must contain zuora.com, zuora.eu, or zuora.na" if /zuora.com|zuora.eu|zuora.na/ === url
21
- @url = url.gsub(/(\d{2}\.\d)$/, MIN_Endpoint) if MIN_Endpoint.to_f > url.scan(/(\d{2}\.\d)$/).dig(0,0).to_f
22
- @hostname = /(?<=https:\/\/|http:\/\/)(.*?)(?=\/|$)/.match(url)[0] if !/(?<=https:\/\/|http:\/\/)(.*?)(?=\/|$)/.match(url).nil?
23
- @entity_id = get_entity_id(entity_id: entity_id)
24
- @errors = Hash.new
25
- @current_session = session
26
- @status = status.blank? ? "Active" : status
27
- @user_info = Hash.new
21
+ self.hostname = /(?<=https:\/\/|http:\/\/)(.*?)(?=\/|$)/.match(url)[0] if !/(?<=https:\/\/|http:\/\/)(.*?)(?=\/|$)/.match(url).nil?
22
+ if !/apps\/services\/a\/\d{2}\.\d$/.match(url.strip)
23
+ self.url = "https://#{hostname}/apps/services/#{MIN_Endpoint}"
24
+ elsif MIN_Endpoint.to_f > url.scan(/(\d{2}\.\d)$/).dig(0,0).to_f
25
+ self.url = url.gsub(/(\d{2}\.\d)$/, MIN_Endpoint)
26
+ end
27
+ self.entity_id = get_entity_id(entity_id: entity_id)
28
+ self.errors = Hash.new
29
+ self.current_session = session
30
+ self.bearer_token = bearer_token
31
+ self.oauth_session_expires_at = oauth_session_expires_at
32
+ self.status = status.blank? ? "Active" : status
33
+ self.user_info = Hash.new
28
34
  self.update_region
29
35
  self.update_environment
30
36
  self.update_zconnect_provider
@@ -634,7 +640,7 @@ module ZuoraAPI
634
640
  end
635
641
 
636
642
  #All other errors
637
- if response.code != 200
643
+ if ![200,201].include?(response.code)
638
644
  if response.code == 429
639
645
  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)
640
646
  else
@@ -768,7 +774,7 @@ module ZuoraAPI
768
774
  raise_errors(type: :JSON, body: output_json, response: response)
769
775
  rescue ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError => ex
770
776
  if self.class.to_s == 'ZuoraAPI::Oauth'
771
- self.rest_call(method: method.to_sym, url: url, debug: debug, errors: errors, z_session: z_session, session_type: :bearer, timeout_retry: timeout_retry, timeout: timeout)
777
+ self.rest_call(method: method.to_sym, url: url, body: body, debug: debug, errors: errors, z_session: z_session, session_type: :bearer, timeout_retry: timeout_retry, timeout: timeout)
772
778
  else
773
779
  Rails.logger.debug("Rest Call - Session Bad Auth type")
774
780
  raise ex
@@ -2,8 +2,8 @@ module ZuoraAPI
2
2
  class Basic < Login
3
3
  attr_accessor :username, :password
4
4
  def initialize(username: nil, password: nil, **keyword_args)
5
- @username = username
6
- @password = password
5
+ self.username = username
6
+ self.password = password
7
7
  super
8
8
  end
9
9
 
@@ -5,9 +5,9 @@ module ZuoraAPI
5
5
  def initialize(oauth_client_id: nil, oauth_secret: nil, bearer_token: nil, oauth_session_expires_at: nil, **keyword_args)
6
6
  self.oauth_client_id = oauth_client_id
7
7
  self.oauth_secret = oauth_secret
8
- self.bearer_token = bearer_token if !bearer_token.blank?
9
- self.oauth_session_expires_at = oauth_session_expires_at if !oauth_session_expires_at.blank?
10
- raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Request Oauth Login but either 'Oauth Client Id' or 'Oauth Secret' were not passed") if @oauth_client_id.blank? || @oauth_secret.blank?
8
+ self.bearer_token = bearer_token
9
+ self.oauth_session_expires_at = oauth_session_expires_at
10
+ raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Request Oauth Login but either 'Oauth Client Id' or 'Oauth Secret' were not passed") if self.bearer_token.blank? && (self.oauth_client_id.blank? || self.oauth_secret.blank?)
11
11
  super
12
12
  end
13
13
 
@@ -66,6 +66,8 @@ module ZuoraAPI
66
66
 
67
67
  def get_bearer_token
68
68
  tries ||= 2
69
+ 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
+
69
71
  output_json, response = self.rest_call(:method => :post,
70
72
  :url => self.rest_endpoint.chomp('v1/').concat("oauth/token"),
71
73
  :z_session => false,
@@ -1,3 +1,3 @@
1
1
  module ZuoraAPI
2
- VERSION = "1.6.38"
2
+ VERSION = "1.6.39"
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.38
4
+ version: 1.6.39
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-05-26 00:00:00.000000000 Z
11
+ date: 2019-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler