zuora_api 1.7.66 → 1.8.00
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zuora_api/login.rb +6 -59
- data/lib/zuora_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e79d63055902d66670dad6abed776b5c02ccb422b886bad2e632624e43eb16ba
|
4
|
+
data.tar.gz: 8abaee55dad2d4c3636bcbd08159a26dc403a8041aecb7d2ce2f6d84bd9f3917
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72165d5892a404b6e25c6f32e83e52065a23837eeb7f4d72a40f13e7c642c460362a3c4ed83b51760e5efac650c5eaffc4d4baa1b97b6c980818273af3fa9af1
|
7
|
+
data.tar.gz: 271b546b700d026e9ac12a22418eb90fc45a2a2b1bd66f872586a5552a4dfe703cb95f9f7dd78cb38960d4885a65e20acab0095ab0a2b5c5b3339295b129b995
|
data/lib/zuora_api/login.rb
CHANGED
@@ -72,29 +72,12 @@ module ZuoraAPI
|
|
72
72
|
|
73
73
|
def get_identity(cookies)
|
74
74
|
zsession = cookies["ZSession"]
|
75
|
-
zconnect_accesstoken = get_zconnect_accesstoken(cookies)
|
76
75
|
begin
|
77
76
|
if !zsession.blank?
|
78
77
|
response = HTTParty.get("https://#{self.hostname}/apps/v1/identity", :headers => {'Cookie' => "ZSession=#{zsession}", 'Content-Type' => 'application/json'})
|
79
78
|
output_json = JSON.parse(response.body)
|
80
|
-
elsif zconnect_accesstoken.present?
|
81
|
-
begin
|
82
|
-
code = zconnect_accesstoken.split("#!").last
|
83
|
-
encrypted_token, tenant_id = Base64.decode64(code).split(":")
|
84
|
-
body = {'token' => encrypted_token}.to_json
|
85
|
-
rescue => ex
|
86
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("Invalid ZConnect Cookie")
|
87
|
-
end
|
88
|
-
Rails.logger.info("Using ZConnect cookie in get_identity method")
|
89
|
-
|
90
|
-
response = HTTParty.post("https://#{self.hostname}/apps/zconnectsession/identity", :body => body, :headers => { 'Content-Type' => 'application/json' })
|
91
|
-
output_json = JSON.parse(response.body)
|
92
79
|
else
|
93
|
-
|
94
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZConnect cookie present matching #{self.hostname}")
|
95
|
-
else
|
96
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZSession cookie present")
|
97
|
-
end
|
80
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZSession cookie present")
|
98
81
|
end
|
99
82
|
rescue JSON::ParserError => ex
|
100
83
|
output_json = {}
|
@@ -105,21 +88,12 @@ module ZuoraAPI
|
|
105
88
|
|
106
89
|
def get_full_nav(cookies)
|
107
90
|
zsession = cookies["ZSession"]
|
108
|
-
zconnect_accesstoken = get_zconnect_accesstoken(cookies)
|
109
91
|
begin
|
110
92
|
if zsession.present?
|
111
93
|
response = HTTParty.get("https://#{self.hostname}/apps/v1/navigation", :headers => {'Cookie' => "ZSession=#{zsession}", 'Content-Type' => 'application/json'})
|
112
94
|
output_json = JSON.parse(response.body)
|
113
|
-
elsif zconnect_accesstoken.present?
|
114
|
-
Rails.logger.info("Using ZConnect cookie in get_full_nav method")
|
115
|
-
response = HTTParty.get("https://#{self.hostname}/apps/zconnectsession/navigation", :headers => {'Cookie' => "#{self.zconnect_provider}=#{zconnect_accesstoken}",'Content-Type' => 'application/json'})
|
116
|
-
output_json = JSON.parse(response.body)
|
117
95
|
else
|
118
|
-
|
119
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZConnect cookie present matching #{self.hostname}")
|
120
|
-
else
|
121
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZSession cookie present")
|
122
|
-
end
|
96
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZSession cookie present")
|
123
97
|
end
|
124
98
|
rescue JSON::ParserError => ex
|
125
99
|
output_json = {}
|
@@ -130,21 +104,12 @@ module ZuoraAPI
|
|
130
104
|
|
131
105
|
def set_nav(state, cookies)
|
132
106
|
zsession = cookies["ZSession"]
|
133
|
-
zconnect_accesstoken = get_zconnect_accesstoken(cookies)
|
134
107
|
begin
|
135
108
|
if !zsession.blank?
|
136
109
|
response = HTTParty.put("https://#{self.hostname}/apps/v1/preference/navigation", :body => state.to_json, :headers => {'Cookie' => "ZSession=#{zsession}", 'Content-Type' => 'application/json'})
|
137
110
|
output_json = JSON.parse(response.body)
|
138
|
-
elsif !zconnect_accesstoken.blank?
|
139
|
-
Rails.logger.info("Using ZConnect cookie in set_nav method")
|
140
|
-
response = HTTParty.post("https://#{self.hostname}/apps/zconnectsession/navigationstate", :body => state.to_json, :headers => {'Cookie' => "#{self.zconnect_provider}=#{zconnect_accesstoken}", 'Content-Type' => 'application/json'})
|
141
|
-
output_json = JSON.parse(response.body)
|
142
111
|
else
|
143
|
-
|
144
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZConnect cookie present matching #{self.hostname}")
|
145
|
-
else
|
146
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZSession cookie present")
|
147
|
-
end
|
112
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZSession cookie present")
|
148
113
|
end
|
149
114
|
rescue JSON::ParserError => ex
|
150
115
|
output_json = {}
|
@@ -155,21 +120,12 @@ module ZuoraAPI
|
|
155
120
|
|
156
121
|
def refresh_nav(cookies)
|
157
122
|
zsession = cookies["ZSession"]
|
158
|
-
zconnect_accesstoken = get_zconnect_accesstoken(cookies)
|
159
123
|
begin
|
160
124
|
if !zsession.blank?
|
161
125
|
response = HTTParty.post("https://#{self.hostname}/apps/v1/navigation/fetch", :headers => {'Cookie' => "ZSession=#{zsession}", 'Content-Type' => 'application/json'})
|
162
126
|
output_json = JSON.parse(response.body)
|
163
|
-
elsif !zconnect_accesstoken.blank?
|
164
|
-
Rails.logger.info("Using ZConnect cookie in refresh_nav method")
|
165
|
-
response = HTTParty.post("https://#{self.hostname}/apps/zconnectsession/refresh-navbarcache", :headers => {'Cookie' => "#{self.zconnect_provider}=#{zconnect_accesstoken}", 'Content-Type' => 'application/json'})
|
166
|
-
output_json = JSON.parse(response.body)
|
167
127
|
else
|
168
|
-
|
169
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZConnect cookie present matching #{self.hostname}")
|
170
|
-
else
|
171
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZSession cookie present")
|
172
|
-
end
|
128
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("No ZSession cookie present")
|
173
129
|
end
|
174
130
|
rescue JSON::ParserError => ex
|
175
131
|
output_json = {}
|
@@ -178,15 +134,6 @@ module ZuoraAPI
|
|
178
134
|
return output_json
|
179
135
|
end
|
180
136
|
|
181
|
-
def get_zconnect_accesstoken(cookies)
|
182
|
-
accesstoken = nil
|
183
|
-
self.update_zconnect_provider
|
184
|
-
if !cookies[self.zconnect_provider].nil? && !cookies[self.zconnect_provider].empty?
|
185
|
-
accesstoken = cookies[self.zconnect_provider]
|
186
|
-
end
|
187
|
-
return accesstoken
|
188
|
-
end
|
189
|
-
|
190
137
|
def reporting_url(path)
|
191
138
|
map = {"US" => {"Sandbox" => "https://zconnectsandbox.zuora.com/api/rest/v1/",
|
192
139
|
"Production" => "https://zconnect.zuora.com/api/rest/v1/",
|
@@ -208,7 +155,7 @@ module ZuoraAPI
|
|
208
155
|
# 1. Pass in cookies and optionally custom_authorities, name, and description
|
209
156
|
# 2. Pass in user_id, entity_ids, client_id, client_secret, and optionally custom_authorities, name, and description
|
210
157
|
# https://intranet.zuora.com/confluence/display/Sunburst/Create+an+OAuth+Client+through+API+Gateway#CreateanOAuthClientthroughAPIGateway-ZSession
|
211
|
-
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)
|
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, chomp_v1_from_genesis_endpoint: false)
|
212
159
|
authorization = ""
|
213
160
|
new_client_id = SecureRandom.uuid if new_client_id.blank?
|
214
161
|
new_client_secret = SecureRandom.hex(10) if new_client_secret.blank?
|
@@ -234,7 +181,7 @@ module ZuoraAPI
|
|
234
181
|
end
|
235
182
|
|
236
183
|
if !authorization.blank? && !user_id.blank? && !entity_ids.blank?
|
237
|
-
endpoint = self.rest_endpoint("genesis/clients")
|
184
|
+
endpoint = chomp_v1_from_genesis_endpoint ? self.rest_endpoint.chomp("v1/").concat("genesis/clients") : self.rest_endpoint("genesis/clients")
|
238
185
|
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)
|
239
186
|
output_json = JSON.parse(oauth_response.body)
|
240
187
|
if oauth_response.code == 201
|
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.
|
4
|
+
version: 1.8.00
|
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: 2020-
|
11
|
+
date: 2020-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|