zuora_api 1.7.7f → 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/Gemfile +1 -1
- data/catalog-info.yaml +12 -0
- data/docs/index.md +147 -0
- data/lib/zuora_api/login.rb +6 -11
- data/lib/zuora_api/version.rb +1 -1
- metadata +5 -3
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/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
|
-
MIN_Endpoints = {'Test': '
|
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 = [
|
@@ -156,7 +156,7 @@ module ZuoraAPI
|
|
156
156
|
# 1. Pass in cookies and optionally custom_authorities, name, and description
|
157
157
|
# 2. Pass in user_id, entity_ids, client_id, client_secret, and optionally custom_authorities, name, and description
|
158
158
|
# https://intranet.zuora.com/confluence/display/Sunburst/Create+an+OAuth+Client+through+API+Gateway#CreateanOAuthClientthroughAPIGateway-ZSession
|
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)
|
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)
|
160
160
|
authorization = ""
|
161
161
|
new_client_id = SecureRandom.uuid if new_client_id.blank?
|
162
162
|
new_client_secret = SecureRandom.hex(10) if new_client_secret.blank?
|
@@ -182,11 +182,11 @@ module ZuoraAPI
|
|
182
182
|
end
|
183
183
|
|
184
184
|
if !authorization.blank? && !user_id.blank? && !entity_ids.blank?
|
185
|
-
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")
|
186
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)
|
187
187
|
output_json = JSON.parse(oauth_response.body)
|
188
188
|
if oauth_response.code == 201
|
189
|
-
output_json["clientSecret"] = new_client_secret
|
189
|
+
output_json["clientSecret"] = new_client_secret if !use_api_generated_client_secret
|
190
190
|
return output_json
|
191
191
|
elsif oauth_response.code == 401 && !oauth_response.message.blank?
|
192
192
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(output_json["message"], oauth_response)
|
@@ -534,7 +534,7 @@ module ZuoraAPI
|
|
534
534
|
when ZuoraAPI::Exceptions::ZuoraAPIUnkownError, ZuoraAPI::Exceptions::ZuoraDataIntegrity
|
535
535
|
Rails.logger.error('Zuora Unknown/Integrity Error', ex, exception_args)
|
536
536
|
when ZuoraAPI::Exceptions::ZuoraAPIRequestLimit
|
537
|
-
Rails.logger.info('Zuora APILimit Reached', exception_args)
|
537
|
+
Rails.logger.info('Zuora APILimit Reached', ex, exception_args)
|
538
538
|
when *(ZuoraAPI::Login::ZUORA_API_ERRORS-ZuoraAPI::Login::ZUORA_SERVER_ERRORS)
|
539
539
|
#Rails.logger.debug('Zuora API Error', ex, self.exception_args(ex))
|
540
540
|
when *ZuoraAPI::Login::ZUORA_SERVER_ERRORS
|
@@ -553,12 +553,7 @@ module ZuoraAPI
|
|
553
553
|
|
554
554
|
def exception_args(ex)
|
555
555
|
args = {}
|
556
|
-
if ex.
|
557
|
-
args.merge!({
|
558
|
-
zuora_trace_id: ex.response.headers["zuora-request-id"],
|
559
|
-
zuora_track_id: ex.response.request.options[:headers]["Zuora-Track-Id"]
|
560
|
-
})
|
561
|
-
elsif defined?(ex.response) && ex.response.present?
|
556
|
+
if defined?(ex.response) && ex.response.present?
|
562
557
|
args.merge!({
|
563
558
|
request: {
|
564
559
|
path: ex.response.request.path.to_s,
|
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.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
|
@@ -174,6 +174,8 @@ files:
|
|
174
174
|
- Rakefile
|
175
175
|
- bin/console
|
176
176
|
- bin/setup
|
177
|
+
- catalog-info.yaml
|
178
|
+
- docs/index.md
|
177
179
|
- gemfiles/Gemfile-rails.5.0.x
|
178
180
|
- gemfiles/Gemfile-rails.5.1.x
|
179
181
|
- gemfiles/Gemfile-rails.5.2.x
|
@@ -204,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
206
|
- !ruby/object:Gem::Version
|
205
207
|
version: 1.3.1
|
206
208
|
requirements: []
|
207
|
-
rubygems_version: 3.1.
|
209
|
+
rubygems_version: 3.1.4
|
208
210
|
signing_key:
|
209
211
|
specification_version: 4
|
210
212
|
summary: Gem that provides easy integration to Zuora
|