zuora_api 1.7.7a → 1.7.7g
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 +2 -1
- data/.gitlab-ci.yml +15 -16
- data/Gemfile +1 -1
- data/catalog-info.yaml +12 -0
- data/docs/index.md +147 -0
- data/gemfiles/Gemfile-rails.5.0.x +5 -0
- data/gemfiles/Gemfile-rails.5.1.x +5 -0
- data/gemfiles/Gemfile-rails.5.2.x +5 -0
- data/gemfiles/Gemfile-rails.6.0.x +5 -0
- data/lib/zuora_api/login.rb +44 -25
- data/lib/zuora_api/version.rb +1 -1
- data/zuora_api.gemspec +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68af74b388dcd84b9501fd4ebba908f409dcba70a1addd0c252b346691872f6f
|
4
|
+
data.tar.gz: 971171042af2ad4fcf3259c060476b370c0138766eeba2291455463ba53eda77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 947ab5bd0709372f38fa297e8a00ca370f2ece1e324abbb113c3aa43c7216205c30c1db1e4e5b5ee8b2f8e83110fd37ad24ed7e0fe05094d8d096b7888e40403
|
7
|
+
data.tar.gz: 555913dd2a5277700d472d6ff83b9eef62f8033c15a8b162926c6c55da637a0453d70662c44673edf0a35882427cadb7f4974bbb11931943edc4e4e36d173a64
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
@@ -1,21 +1,8 @@
|
|
1
1
|
image: ruby:2.7
|
2
2
|
stages:
|
3
|
-
- setup
|
4
3
|
- test
|
5
4
|
- deploy
|
6
5
|
|
7
|
-
setup:
|
8
|
-
stage: setup
|
9
|
-
allow_failure: true
|
10
|
-
cache:
|
11
|
-
key: gems
|
12
|
-
paths:
|
13
|
-
- vendor/bundle
|
14
|
-
script:
|
15
|
-
- apt-get update -qy
|
16
|
-
- apt-get install -y nodejs
|
17
|
-
- bundle install
|
18
|
-
|
19
6
|
rubocop-testing:
|
20
7
|
stage: test
|
21
8
|
allow_failure: true
|
@@ -30,11 +17,23 @@ security-testing:
|
|
30
17
|
- gem install brakeman
|
31
18
|
- brakeman
|
32
19
|
|
33
|
-
|
20
|
+
ruby:test:
|
34
21
|
stage: test
|
22
|
+
cache:
|
23
|
+
key: ruby:$RUBY_VERSION-rails:$RAILS_VERSION
|
24
|
+
paths:
|
25
|
+
- vendor/ruby
|
26
|
+
parallel:
|
27
|
+
matrix:
|
28
|
+
- RUBY_VERSION: "2.7"
|
29
|
+
RAILS_VERSION: ["5.0", "5.1", "5.2", "6.0"]
|
30
|
+
before_script:
|
31
|
+
- bundle config set path 'vendor/ruby'
|
32
|
+
- bundle config --global gemfile "gemfiles/Gemfile-rails.$RAILS_VERSION.x"
|
33
|
+
- bundle install
|
35
34
|
script:
|
36
|
-
|
37
|
-
|
35
|
+
- bundle exec rails -v
|
36
|
+
- bundle exec rspec
|
38
37
|
coverage: '/\(\d+.\d+\%\) covered/'
|
39
38
|
|
40
39
|
rubygems-deploy:
|
data/Gemfile
CHANGED
data/catalog-info.yaml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
apiVersion: backstage.io/v1alpha1
|
3
|
+
kind: Component
|
4
|
+
metadata:
|
5
|
+
annotations:
|
6
|
+
backstage.io/techdocs-ref: "gitlab:https://gitlab.zeta.tools/extension-products/shared-libraries/zuora-gem.git"
|
7
|
+
description: "Zuora API Rails Gem"
|
8
|
+
name: Zuora-Gem
|
9
|
+
spec:
|
10
|
+
lifecycle: production
|
11
|
+
owner: connect@zuora.com
|
12
|
+
type: library
|
data/docs/index.md
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
# Zuora Gem
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/zuora_api) [](https://gitlab.0.ecc.auw2.zuora/extension-products/shared-libraries/zuora-gem/commits/master)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'zuora_api'
|
10
|
+
```
|
11
|
+
Then execute `bundle install` in your terminal
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
### Zuora Login Object
|
16
|
+
In order to make API calls a Zuora Login object must be created
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
zuora_client = ZuoraAPI::Login.new(username: "username", password: "password", url: "url")
|
20
|
+
```
|
21
|
+
|
22
|
+
| Name | Type | Description | Example |
|
23
|
+
| ------------------- | ----------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
24
|
+
| username | `Attribute` | Username to the Zuora environment | `zuora_client.username = "username"` |
|
25
|
+
| password | `Attribute` | password to the Zuora environment | `zuora_client.password = "Password"` |
|
26
|
+
| url | `Attribute` | Endpoint to the Zuora tenant | `zuora_client.url = "www.zuora.com"` |
|
27
|
+
| wsdl_number | `Attribute` | WSDL number of the zuora login | `wsdl = zuora_client.wsdl_number` |
|
28
|
+
| status | `Attribute` | Status of the login | `zuora_client.status` |
|
29
|
+
| current_session | `Attribute` | Current session for the login | `zuora_client.current_session` |
|
30
|
+
| environment | `Attribute` | environment of the login | `zuora_client.environment` |
|
31
|
+
| errors | `Attribute` | Any errors that the login has based on the login call | `zuora_client.errors` |
|
32
|
+
| current_error | `Attribute` | Current error from the new_session call | `zuora_client.current_error` |
|
33
|
+
| user_info | `Attribute` | Information related to the login | `zuora_client.user_info` |
|
34
|
+
| tenant_id | `Attribute` | Tenant ID the login is associated to | `zuora_client.tenant_id` |
|
35
|
+
| tenant_name | `Attribute` | Tenant Name of tenant the login is associated to | `zuora_client.tenant_name` |
|
36
|
+
| entity_id | `Attribute` | Current entity the login session is associated to | `zuora_client.entity_id` |
|
37
|
+
| rest_call | `Method` | Executes a REST call | `zuora_client.rest_call()` |
|
38
|
+
| soap_call | `Method` | Executes a SOAP call | `output_xml, input_xml = zuora_client.soap_call() do `|xml, args|` xml['ns1'].query do xml['ns1'].queryString "select id, name from account" end end` |
|
39
|
+
| query | `Method` | Executes a query call | `zuora_client.query("select id, name from account")` |
|
40
|
+
| getDataSourceExport | `Method` | Pulls a data source export with the given query and returns the file location | `zuora_client.getDataSourceExport("select id, name from account")` |
|
41
|
+
| describe_call | `Method` | Performs the describe call against the Zuora tenant for all objects or a specific object | `response = zuora_client.describe_call("Account")` |
|
42
|
+
| createJournalRun | `Method` | Creates a Journal Run | `zuora_client.createJournalRun(call)` |
|
43
|
+
| checkJRStatus | `Method` | Checks the status of a journal run | `zuora_client.checkJRStatus(journal_run_id)` |
|
44
|
+
| update_environment | `Method` | Sets the login's environment based on the url | `zuora_client.update_environment` |
|
45
|
+
| aqua_endpoint | `Method` | Returns the AQuA endpoint for the login based off the environment | `zuora_client.aqua_endpoint` |
|
46
|
+
| rest_endpoint | `Method` | Returns the REST endpoint for the login based off the environment | `zuora_client.rest_endpoint` |
|
47
|
+
| fileURL | `Method` | Returns the URL for files | `zuora_client.fileURL` |
|
48
|
+
| dateFormat | `Method` | Returns the data format syntax based on the wsdl_number | `zuora_client.dateFormat` |
|
49
|
+
| new_session | `Method` | Create a new session | `zuora_client.new_session` |
|
50
|
+
| get_session | `Method` | Returns the current session | `zuora_client.get_session`|
|
51
|
+
|
52
|
+
## Rest Call
|
53
|
+
```ruby
|
54
|
+
zuora_client.rest_call(method: :get, body: {}, url: zuora_client.rest_endpoint("catalog/products?pageSize=4"))
|
55
|
+
```
|
56
|
+
|
57
|
+
### Soap Call
|
58
|
+
Returns both output and input XML
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
zuora_client.soap_call(ns1: 'ns1', ns2: 'ns2', batch_size: nil, single_transaction: false)
|
62
|
+
```
|
63
|
+
|
64
|
+
Example Call
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
output_xml, input_xml = zuora_client.soap_call() do |xml, args|
|
68
|
+
xml['ns1'].query do
|
69
|
+
xml['ns1'].queryString "select id, name from account"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
```
|
73
|
+
### Query
|
74
|
+
```ruby
|
75
|
+
zuora_client.query("select id from account")
|
76
|
+
```
|
77
|
+
### Data Export
|
78
|
+
Returns the file location of the data source export after downloading from Zuora
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
zuora_client.getDataSourceExport("select id from account")
|
82
|
+
```
|
83
|
+
|
84
|
+
| Name | Description | Default | Example |
|
85
|
+
| --------- | ---------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------- |
|
86
|
+
| query | The query to execute | `N/A` | `zuora_client.getDataSourceExport("select id from account")` |
|
87
|
+
| zip | Indicates if the data source export should be a zip | `true` | `zuora_client.getDataSourceExport("select id from account", zip: false)` |
|
88
|
+
| extract | Indicates if the data source export should be extracted if it is a zip | `true` | `zuora_client.getDataSourceExport("select id from account", extract: false)` |
|
89
|
+
| encrypted | Indicates if the data source export should be encrypted | `false` | `zuora_client.getDataSourceExport("select id from account", encrypted: true)` |
|
90
|
+
|
91
|
+
### Describe Call
|
92
|
+
This returns all available objects from the describe call as a hash. This response can be accessed by using response["Account"] to retrieve all related data about that object.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
response = zuora_client.describe_call("Account")
|
96
|
+
```
|
97
|
+
This returns all information and fields related to that object model as a hash.
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
response = zuora_client.describe_call()
|
101
|
+
```
|
102
|
+
|
103
|
+
### Journal Run
|
104
|
+
```ruby
|
105
|
+
zuora_client.createJournalRun(call)
|
106
|
+
```
|
107
|
+
|
108
|
+
## Insights API
|
109
|
+
|
110
|
+
In order to make API calls a Zuora Login object must be created by running:
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
insightsapi = InsightsAPI::Login.new(api_token: "api token", url: "Nw1.api.insights.zuora.com/api/")
|
114
|
+
```
|
115
|
+
|
116
|
+
Note that the login will default to the insights production url.
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
Date format: "YYYY-MM-DDT00:00:00Z"
|
120
|
+
```
|
121
|
+
|
122
|
+
### Uploading Data into Insights
|
123
|
+
```ruby
|
124
|
+
insightsapi.upload_into_insights(dataSourceName, recordType, batchDate, filePath)
|
125
|
+
```
|
126
|
+
dataSourceName: What system the data is coming from.
|
127
|
+
recordType: The type of records ie: "EVENTS, ATTRIBUTES, and METRICS"
|
128
|
+
batachDate: The date the data applies to.
|
129
|
+
|
130
|
+
### Describing Insights Data
|
131
|
+
```ruby
|
132
|
+
insightsapi.describe(type: "ACCOUNT/USER", object: "ATTRIBUTES/EVENTS/SEGMENTS/METRICS")
|
133
|
+
```
|
134
|
+
Returns json payload describing attributes, events, metrics for each Account or User.
|
135
|
+
|
136
|
+
### Downloading Data from Insights
|
137
|
+
```ruby
|
138
|
+
insightsapi.data_export_insights(objecttype, segmentuuid, startDate: nil, endDate: nil, tries: 30)
|
139
|
+
```
|
140
|
+
```ruby
|
141
|
+
insightsapi.data_export_insights_file(objecttype, segmentuuid, startDate: nil, endDate: nil, tries: 30)
|
142
|
+
```
|
143
|
+
Both do the same thing except one returns a url(data_export_insights) to download the file yourself and the other returns an actual Ruby temporary file(data_export_insights_file).
|
144
|
+
|
145
|
+
objectype: "ACCOUNT/USER"
|
146
|
+
|
147
|
+
segmentuuid: A single or array of string or int of a segment uuid(s) that you get from the describe call. The csv holds a column with a bool that represents if that User or Account belongs to that segment.
|
data/lib/zuora_api/login.rb
CHANGED
@@ -7,7 +7,7 @@ module ZuoraAPI
|
|
7
7
|
class Login
|
8
8
|
ENVIRONMENTS = [TEST = 'Test', SANDBOX = 'Sandbox', PRODUCTION = 'Production', PREFORMANCE = 'Preformance', SERVICES = 'Services', UNKNOWN = 'Unknown', STAGING = 'Staging' ]
|
9
9
|
REGIONS = [EU = 'EU', US = 'US', NA = 'NA' ]
|
10
|
-
|
10
|
+
MIN_Endpoints = {'Test': '107.0', 'Sandbox': '107.0', 'Production': '107.0', 'Performance': '107.0', 'Services': '96.0', 'Unknown': '96.0', 'Staging': '107.0'}.freeze
|
11
11
|
XML_SAVE_OPTIONS = Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
|
12
12
|
|
13
13
|
CONNECTION_EXCEPTIONS = [
|
@@ -50,10 +50,12 @@ module ZuoraAPI
|
|
50
50
|
raise "URL is nil or empty, but URL is required" if url.nil? || url.empty?
|
51
51
|
# raise "URL is improper. URL must contain zuora.com, zuora.eu, or zuora.na" if /zuora.com|zuora.eu|zuora.na/ === url
|
52
52
|
self.hostname = /(?<=https:\/\/|http:\/\/)(.*?)(?=\/|$)/.match(url)[0] if !/(?<=https:\/\/|http:\/\/)(.*?)(?=\/|$)/.match(url).nil?
|
53
|
+
self.update_environment
|
54
|
+
min_endpoint = MIN_Endpoints[self.environment.to_sym]
|
53
55
|
if !/apps\/services\/a\/\d+\.\d$/.match(url.strip)
|
54
|
-
self.url = "https://#{hostname}/apps/services/a/#{
|
55
|
-
elsif
|
56
|
-
self.url = url.gsub(/(\d+\.\d)$/,
|
56
|
+
self.url = "https://#{hostname}/apps/services/a/#{min_endpoint}"
|
57
|
+
elsif min_endpoint.to_f > url.scan(/(\d+\.\d)$/).dig(0,0).to_f
|
58
|
+
self.url = url.gsub(/(\d+\.\d)$/, min_endpoint)
|
57
59
|
else
|
58
60
|
self.url = url
|
59
61
|
end
|
@@ -65,7 +67,6 @@ module ZuoraAPI
|
|
65
67
|
self.status = status.blank? ? "Active" : status
|
66
68
|
self.user_info = Hash.new
|
67
69
|
self.update_region
|
68
|
-
self.update_environment
|
69
70
|
self.update_zconnect_provider
|
70
71
|
@timeout_sleep = 5
|
71
72
|
end
|
@@ -155,7 +156,7 @@ module ZuoraAPI
|
|
155
156
|
# 1. Pass in cookies and optionally custom_authorities, name, and description
|
156
157
|
# 2. Pass in user_id, entity_ids, client_id, client_secret, and optionally custom_authorities, name, and description
|
157
158
|
# https://intranet.zuora.com/confluence/display/Sunburst/Create+an+OAuth+Client+through+API+Gateway#CreateanOAuthClientthroughAPIGateway-ZSession
|
158
|
-
def get_oauth_client (custom_authorities = [], info_name: "No Name", info_desc: "This client was created without a description.", user_id: nil, entity_ids: nil, client_id: nil, client_secret: nil, new_client_id: nil, new_client_secret: nil, cookies: nil)
|
159
|
+
def get_oauth_client (custom_authorities = [], info_name: "No Name", info_desc: "This client was created without a description.", user_id: nil, entity_ids: nil, client_id: nil, client_secret: nil, new_client_id: nil, new_client_secret: nil, cookies: nil, chomp_v1_from_genesis_endpoint: false, use_api_generated_client_secret: false)
|
159
160
|
authorization = ""
|
160
161
|
new_client_id = SecureRandom.uuid if new_client_id.blank?
|
161
162
|
new_client_secret = SecureRandom.hex(10) if new_client_secret.blank?
|
@@ -181,11 +182,11 @@ module ZuoraAPI
|
|
181
182
|
end
|
182
183
|
|
183
184
|
if !authorization.blank? && !user_id.blank? && !entity_ids.blank?
|
184
|
-
endpoint = self.rest_endpoint("genesis/clients")
|
185
|
+
endpoint = chomp_v1_from_genesis_endpoint ? self.rest_endpoint.chomp("v1/").concat("genesis/clients") : self.rest_endpoint("genesis/clients")
|
185
186
|
oauth_response = HTTParty.post(endpoint, :headers => {'authorization' => authorization, 'Content-Type' => 'application/json'}, :body => {'clientId' => new_client_id, 'clientSecret' => new_client_secret, 'userId' => user_id, 'entityIds' => entity_ids, 'customAuthorities' => custom_authorities, 'additionalInformation' => {'description' => info_desc, 'name' => info_name}}.to_json)
|
186
187
|
output_json = JSON.parse(oauth_response.body)
|
187
188
|
if oauth_response.code == 201
|
188
|
-
output_json["clientSecret"] = new_client_secret
|
189
|
+
output_json["clientSecret"] = new_client_secret if !use_api_generated_client_secret
|
189
190
|
return output_json
|
190
191
|
elsif oauth_response.code == 401 && !oauth_response.message.blank?
|
191
192
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(output_json["message"], oauth_response)
|
@@ -252,7 +253,7 @@ module ZuoraAPI
|
|
252
253
|
end
|
253
254
|
|
254
255
|
def update_environment
|
255
|
-
if !self.
|
256
|
+
if !self.hostname.blank?
|
256
257
|
case self.hostname
|
257
258
|
when /(?<=\.|\/|-|^)(apisandbox|sandbox)(?=\.|\/|-|$)/
|
258
259
|
self.environment = 'Sandbox'
|
@@ -275,13 +276,13 @@ module ZuoraAPI
|
|
275
276
|
end
|
276
277
|
|
277
278
|
def update_zconnect_provider
|
278
|
-
|
279
|
-
|
279
|
+
update_region if self.region.blank?
|
280
|
+
update_environment if self.environment.blank?
|
280
281
|
mappings = {"US" => {"Sandbox" => "ZConnectSbx", "Services" => "ZConnectSvcUS", "Production" => "ZConnectProd", "Performance" => "ZConnectPT1", "Test" => "ZConnectTest", "Staging" => "ZConnectQA", "KubeSTG" => "ZConnectDev", "KubeDEV" => "ZConnectDev", "KubePROD" => "ZConnectDev"},
|
281
282
|
"NA" => {"Sandbox" => "ZConnectSbxNA", "Services" => "ZConnectSvcNA", "Production" => "ZConnectProdNA", "Performance" => "ZConnectPT1NA"},
|
282
283
|
"EU" => {"Sandbox" => "ZConnectSbxEU", "Services" => "ZConnectSvcEU", "Production" => "ZConnectProdEU", "Performance" => "ZConnectPT1EU", "Test" => "ZConnectTest"},
|
283
284
|
"Unknown" => {"Unknown" => "Unknown"}}
|
284
|
-
self.zconnect_provider = mappings[region][environment]
|
285
|
+
self.zconnect_provider = mappings[self.region][self.environment]
|
285
286
|
end
|
286
287
|
|
287
288
|
def aqua_endpoint(url="")
|
@@ -533,7 +534,7 @@ module ZuoraAPI
|
|
533
534
|
when ZuoraAPI::Exceptions::ZuoraAPIUnkownError, ZuoraAPI::Exceptions::ZuoraDataIntegrity
|
534
535
|
Rails.logger.error('Zuora Unknown/Integrity Error', ex, exception_args)
|
535
536
|
when ZuoraAPI::Exceptions::ZuoraAPIRequestLimit
|
536
|
-
Rails.logger.info('Zuora APILimit Reached', exception_args)
|
537
|
+
Rails.logger.info('Zuora APILimit Reached', ex, exception_args)
|
537
538
|
when *(ZuoraAPI::Login::ZUORA_API_ERRORS-ZuoraAPI::Login::ZUORA_SERVER_ERRORS)
|
538
539
|
#Rails.logger.debug('Zuora API Error', ex, self.exception_args(ex))
|
539
540
|
when *ZuoraAPI::Login::ZUORA_SERVER_ERRORS
|
@@ -552,12 +553,7 @@ module ZuoraAPI
|
|
552
553
|
|
553
554
|
def exception_args(ex)
|
554
555
|
args = {}
|
555
|
-
if ex.
|
556
|
-
args.merge!({
|
557
|
-
zuora_trace_id: ex.response.headers["zuora-request-id"],
|
558
|
-
zuora_track_id: ex.response.request.options[:headers]["Zuora-Track-Id"]
|
559
|
-
})
|
560
|
-
elsif defined?(ex.response) && ex.response.present?
|
556
|
+
if defined?(ex.response) && ex.response.present?
|
561
557
|
args.merge!({
|
562
558
|
request: {
|
563
559
|
path: ex.response.request.path.to_s,
|
@@ -702,14 +698,27 @@ module ZuoraAPI
|
|
702
698
|
if body['code'].present? && /61$/.match(body['code'].to_s).present? # if last 2 digits of code are 61
|
703
699
|
raise ZuoraAPI::Exceptions::ZuoraAPITemporaryError.new(body['message'], nil, body['details'])
|
704
700
|
end
|
701
|
+
when /^\/api\/v1\/payment_plans.*/
|
702
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(body['error'], response) if body['error']
|
705
703
|
end
|
706
704
|
|
707
705
|
body = body.dig("results").present? ? body["results"] : body if body.class == Hash
|
708
706
|
if body.class == Hash && (!body["success"] || !body["Success"] || response.code != 200)
|
709
|
-
|
710
|
-
|
711
|
-
codes_array =
|
712
|
-
|
707
|
+
reason_keys = %w(reasons errors)
|
708
|
+
message_keys = %w(message title)
|
709
|
+
messages_array, codes_array = [[],[]]
|
710
|
+
reason_keys.each do |rsn_key|
|
711
|
+
message_keys.each do |msg_key|
|
712
|
+
messages_array = body.fetch(rsn_key, []).map {|error| error[msg_key]}.compact
|
713
|
+
break if messages_array.present?
|
714
|
+
end
|
715
|
+
codes_array = body.fetch(rsn_key, []).map {|error| error['code']}.compact
|
716
|
+
break if messages_array.present? && codes_array.present?
|
717
|
+
end
|
718
|
+
if body.dig('error').class == Hash
|
719
|
+
messages_array = messages_array.push(body.dig("error", 'message')).compact
|
720
|
+
codes_array = codes_array.push(body.dig("error", 'code')).compact
|
721
|
+
end
|
713
722
|
|
714
723
|
if body['message'] == 'request exceeded limit'
|
715
724
|
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)
|
@@ -852,7 +861,7 @@ module ZuoraAPI
|
|
852
861
|
output_json = JSON.parse(response.body)
|
853
862
|
self.raise_errors(type: :JSON, body: output_json, response: response)
|
854
863
|
|
855
|
-
elsif (response_content_types.include?('application/xml') || response_content_types.include?('text/xml')) and type != :xml
|
864
|
+
elsif (response_content_types.include?('application/xml') || response_content_types.include?('text/xml') || response_content_types.include?('application/soap+xml')) and type != :xml
|
856
865
|
output_xml = Nokogiri::XML(response.body)
|
857
866
|
self.raise_errors(type: :SOAP, body: output_xml, response: response)
|
858
867
|
|
@@ -900,6 +909,11 @@ module ZuoraAPI
|
|
900
909
|
message = body.xpath('//ns1:Message', 'ns1' =>'http://api.zuora.com/').text
|
901
910
|
end
|
902
911
|
|
912
|
+
if error.blank? || message.blank?
|
913
|
+
error = body.xpath('//soapenv:Value', 'soapenv'=>'http://www.w3.org/2003/05/soap-envelope').text
|
914
|
+
message = body.xpath('//soapenv:Text', 'soapenv'=>'http://www.w3.org/2003/05/soap-envelope').text
|
915
|
+
end
|
916
|
+
|
903
917
|
#Update/Create/Delete Calls with multiple requests and responses
|
904
918
|
if body.xpath('//ns1:result', 'ns1' =>'http://api.zuora.com/').size > 0 && body.xpath('//ns1:Errors', 'ns1' =>'http://api.zuora.com/').size > 0
|
905
919
|
error = []
|
@@ -950,10 +964,15 @@ module ZuoraAPI
|
|
950
964
|
when /.*soapenv:Server.*/
|
951
965
|
if /^Invalid value.*for type.*|^Id is invalid|^date string can not be less than 19 charactors$/.match(message).present?
|
952
966
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(message, response, errors, success)
|
953
|
-
elsif /^Invalid white space character \(.*\) in text to output$|^Invalid null character in text to output$/.match(message).present?
|
967
|
+
elsif /^unknown$|^Invalid white space character \(.*\) in text to output$|^Invalid null character in text to output$/.match(message).present?
|
954
968
|
raise ZuoraAPI::Exceptions::ZuoraAPIUnkownError.new(message, response, errors, success)
|
955
969
|
end
|
956
970
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(message, response, errors, success)
|
971
|
+
when /soapenv:Receiver/
|
972
|
+
if /^com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character.*$/.match(message).present?
|
973
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(message, response, errors, success)
|
974
|
+
end
|
975
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(message, response, errors, success)
|
957
976
|
else
|
958
977
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new("Z:#{error}::#{message}", response, errors, success)
|
959
978
|
end
|
data/lib/zuora_api/version.rb
CHANGED
data/zuora_api.gemspec
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.7g
|
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:
|
11
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -145,7 +145,7 @@ dependencies:
|
|
145
145
|
version: 4.1.0
|
146
146
|
- - "<"
|
147
147
|
- !ruby/object:Gem::Version
|
148
|
-
version: '6'
|
148
|
+
version: '6.1'
|
149
149
|
type: :runtime
|
150
150
|
prerelease: false
|
151
151
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -155,7 +155,7 @@ dependencies:
|
|
155
155
|
version: 4.1.0
|
156
156
|
- - "<"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: '6'
|
158
|
+
version: '6.1'
|
159
159
|
description: Gem that provides easy integration to Zuora
|
160
160
|
email:
|
161
161
|
- connect@zuora.com
|
@@ -174,6 +174,12 @@ files:
|
|
174
174
|
- Rakefile
|
175
175
|
- bin/console
|
176
176
|
- bin/setup
|
177
|
+
- catalog-info.yaml
|
178
|
+
- docs/index.md
|
179
|
+
- gemfiles/Gemfile-rails.5.0.x
|
180
|
+
- gemfiles/Gemfile-rails.5.1.x
|
181
|
+
- gemfiles/Gemfile-rails.5.2.x
|
182
|
+
- gemfiles/Gemfile-rails.6.0.x
|
177
183
|
- lib/insights_api/login.rb
|
178
184
|
- lib/zuora_api.rb
|
179
185
|
- lib/zuora_api/exceptions.rb
|
@@ -200,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
206
|
- !ruby/object:Gem::Version
|
201
207
|
version: 1.3.1
|
202
208
|
requirements: []
|
203
|
-
rubygems_version: 3.1.
|
209
|
+
rubygems_version: 3.1.4
|
204
210
|
signing_key:
|
205
211
|
specification_version: 4
|
206
212
|
summary: Gem that provides easy integration to Zuora
|