zuora_rest_client 1.2.1.5 → 1.2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +20 -12
- data/lib/zuora_rest_client/client.rb +15 -9
- data/lib/zuora_rest_client/connection.rb +17 -7
- data/lib/zuora_rest_client/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3637cbe1e944055ad2b7303e6e92735b736224dfa77ad00153430c6da7674db4
|
4
|
+
data.tar.gz: de9dd2e15c1d52fec7533b6fa04ddeb4b8650f8b025a6b47d07c4d186710832d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76df5debfb8ec385702e50537e2693f1879fe62832fe683947b46a4159626a1142f705b27c4f8d54c8e6e74de48f8a403a61bb29fb69c8c39a8ac6b2291f88d3
|
7
|
+
data.tar.gz: 1aa64f505dbddad21e621037d691f2c2120f4e1979c6df0637781685418624560f08dd607a9ff419246a520f88a0fb840874e3d9d486c7db71a90858179df2bf
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# ZuoraRestClient
|
2
2
|
|
3
|
-
This is a simple Zuora client for Ruby.
|
4
|
-
|
3
|
+
This is a simple Zuora client for Ruby. It mainly consists of methods that wrap the operations described in the Zuora
|
4
|
+
API Reference
|
5
5
|
(https://www.zuora.com/developer/api-reference), as well as a few helper methods.
|
6
6
|
|
7
|
-
Most of the methods take either the query parameters and/or a hash representing the JSON
|
8
|
-
|
9
|
-
represents ths JSON response.
|
7
|
+
Most of the methods take either the query parameters and/or a hash representing the JSON request body as arguments. The
|
8
|
+
methods return a `ZuoraRestClient::Result` object which represents ths JSON response.
|
10
9
|
|
11
10
|
## Installation
|
12
11
|
|
@@ -27,26 +26,35 @@ Or install it yourself as:
|
|
27
26
|
## Usage
|
28
27
|
|
29
28
|
First, construct a client object:
|
29
|
+
|
30
30
|
```ruby
|
31
31
|
username = 'zuora_username@example.com'
|
32
32
|
password = 'mypassword'
|
33
|
-
client = ZuoraRestClient::Client.new(username, password)
|
33
|
+
client = ZuoraRestClient::Client.new(username, password) # Create a production client
|
34
34
|
```
|
35
35
|
|
36
|
-
For
|
36
|
+
For an API Sandbox tenant, you can specify the following:
|
37
|
+
|
37
38
|
```ruby
|
38
|
-
client = ZuoraRestClient::Client.new(username, password, :api_sandbox)
|
39
|
+
client = ZuoraRestClient::Client.new(username, password, :api_sandbox) # Create an api sandbox client
|
39
40
|
```
|
40
41
|
|
41
|
-
For a
|
42
|
-
|
42
|
+
For a Zuora Central Sandbox tenant, you can specify the following:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
client = ZuoraRestClient::Client.new(username, password, :test) # Create an zuora central sandbox client
|
46
|
+
```
|
47
|
+
|
48
|
+
For a "serivces*NNN*" tenant, where *NNN* is the number that follows "services", you may also need an API proxy port
|
49
|
+
number to invoke calls to `/action/*` and `/object/*`. Assuming your services tenant is `services000`
|
43
50
|
and your API proxy port number is `1234`, you can specify the following:
|
44
51
|
|
45
52
|
```ruby
|
46
|
-
client = ZuoraRestClient::Client.new(username, password, :services000, api_proxy_port: 1234)
|
53
|
+
client = ZuoraRestClient::Client.new(username, password, :services000, api_proxy_port: 1234) # Create an api services000 client
|
47
54
|
```
|
48
55
|
|
49
|
-
Call one of the client methods.
|
56
|
+
Call one of the client methods. For example, to create an account:
|
57
|
+
|
50
58
|
```ruby
|
51
59
|
account_to_create = {
|
52
60
|
Batch: 'Batch1',
|
@@ -237,7 +237,7 @@ module ZuoraRestClient
|
|
237
237
|
|
238
238
|
def aqua_query(request, options = {})
|
239
239
|
aqua_query_options = {}.merge(DEFAULT_AQUA_QUERY_OPTIONS).merge(options)
|
240
|
-
result = @connection.
|
240
|
+
result = @connection.rest_post('/batch-query/', request)
|
241
241
|
logger.debug "********* AQUA POST QUERY RESULT: #{result.inspect}"
|
242
242
|
|
243
243
|
raise "Error: #{result.message}" if result.status.downcase == 'error'
|
@@ -260,11 +260,11 @@ module ZuoraRestClient
|
|
260
260
|
end
|
261
261
|
|
262
262
|
def get_aqua_job_result(job_id)
|
263
|
-
@connection.
|
263
|
+
@connection.rest_get("/batch-query/jobs/#{job_id}")
|
264
264
|
end
|
265
265
|
|
266
266
|
def get_last_aqua_job_result(partner, project)
|
267
|
-
@connection.
|
267
|
+
@connection.rest_get("/batch-query/jobs/partner/#{partner}/project/#{project}")
|
268
268
|
end
|
269
269
|
|
270
270
|
##############################################################################
|
@@ -797,12 +797,12 @@ module ZuoraRestClient
|
|
797
797
|
# Check status and if complete, output file to destination IO
|
798
798
|
logger.debug "********* FINAL EXPORT STATUS: #{export_record.Status}"
|
799
799
|
case export_record.Status
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
800
|
+
when 'Completed'
|
801
|
+
get_file(export_zobject.FileId, destination_io)
|
802
|
+
when 'Canceled'
|
803
|
+
raise "Error downloading file: #{export_record.Status} - #{export_record.StatusReason}"
|
804
|
+
when 'Failed'
|
805
|
+
raise "Error downloading file: #{export_record.Status} - #{export_record.StatusReason}"
|
806
806
|
end
|
807
807
|
|
808
808
|
# If requested, delete export from server
|
@@ -995,6 +995,12 @@ module ZuoraRestClient
|
|
995
995
|
# #
|
996
996
|
##############################################################################
|
997
997
|
|
998
|
+
def get_invoice_files(invoice_id, page_size = nil, zuora_version = nil)
|
999
|
+
uri = Addressable::URI.parse("/invoices/#{invoice_id}/files")
|
1000
|
+
uri.query_values = { pageSize: page_size.to_s } if !page_size.nil?
|
1001
|
+
@connection.rest_get(uri.to_s, zuora_version)
|
1002
|
+
end
|
1003
|
+
|
998
1004
|
def reverse_invoice(invoice_id, zuora_version = nil)
|
999
1005
|
@connection.rest_put("/invoices/#{invoice_id}/reverse", nil, zuora_version)
|
1000
1006
|
end
|
@@ -32,7 +32,9 @@ module ZuoraRestClient
|
|
32
32
|
@options = {}.merge(DEFAULT_OPTIONS).merge(options)
|
33
33
|
end
|
34
34
|
|
35
|
+
# @deprecated Since the Client class no longer uses this, it will be removed.
|
35
36
|
def app_get(path)
|
37
|
+
warn "[DEPRECATION] `app_get` is deprecated. Please use `rest_get` instead."
|
36
38
|
response = app_connection.get do |request|
|
37
39
|
request.url path
|
38
40
|
request.headers = app_headers
|
@@ -40,7 +42,9 @@ module ZuoraRestClient
|
|
40
42
|
process_response(response)
|
41
43
|
end
|
42
44
|
|
45
|
+
# @deprecated Since the Client class no longer uses this, it will be removed.
|
43
46
|
def app_post(path, post_data = nil, is_json = true)
|
47
|
+
warn "[DEPRECATION] `app_post` is deprecated. Please use `rest_post` instead."
|
44
48
|
response = app_connection.post do |request|
|
45
49
|
request.url path
|
46
50
|
request.headers = app_headers
|
@@ -52,7 +56,7 @@ module ZuoraRestClient
|
|
52
56
|
|
53
57
|
def rest_get(path, zuora_version = nil)
|
54
58
|
response = rest_connection(use_api_proxy?(path)).get do |request|
|
55
|
-
request.url [
|
59
|
+
request.url [ZUORA_REST_MAJOR_VERSION, path].join('')
|
56
60
|
request.headers = rest_headers(zuora_version)
|
57
61
|
end
|
58
62
|
process_response(response)
|
@@ -66,7 +70,7 @@ module ZuoraRestClient
|
|
66
70
|
endpoint_uri = Addressable::URI.parse(zuora_endpoint.rest)
|
67
71
|
Net::HTTP.start(endpoint_uri.normalized_host, endpoint_uri.normalized_port,
|
68
72
|
use_ssl: endpoint_uri.normalized_scheme == 'https') do |http|
|
69
|
-
request = Net::HTTP::Get.new [
|
73
|
+
request = Net::HTTP::Get.new [endpoint_uri.normalized_path, '/', ZUORA_REST_MAJOR_VERSION, path].join('')
|
70
74
|
rest_headers(zuora_version).each_pair do |header_key, header_value|
|
71
75
|
request[header_key] = header_value
|
72
76
|
end
|
@@ -89,7 +93,7 @@ module ZuoraRestClient
|
|
89
93
|
|
90
94
|
def rest_post(path, post_data = nil, zuora_version = nil, is_json = true)
|
91
95
|
response = rest_connection(use_api_proxy?(path)).post do |request|
|
92
|
-
request.url [
|
96
|
+
request.url [ZUORA_REST_MAJOR_VERSION, path].join('')
|
93
97
|
request.headers = rest_headers(zuora_version)
|
94
98
|
request.body = MultiJson.dump(post_data) if !post_data.nil? && is_json
|
95
99
|
request.body = post_data if !post_data.nil? && !is_json
|
@@ -99,7 +103,7 @@ module ZuoraRestClient
|
|
99
103
|
|
100
104
|
def rest_put(path, put_data = nil, zuora_version = nil, is_json = true)
|
101
105
|
response = rest_connection(use_api_proxy?(path)).put do |request|
|
102
|
-
request.url [
|
106
|
+
request.url [ZUORA_REST_MAJOR_VERSION, path].join('')
|
103
107
|
request.headers = rest_headers(zuora_version)
|
104
108
|
request.body = MultiJson.dump(put_data) if !put_data.nil? && is_json
|
105
109
|
request.body = put_data if !put_data.nil? && !is_json
|
@@ -109,7 +113,7 @@ module ZuoraRestClient
|
|
109
113
|
|
110
114
|
def rest_delete(path, zuora_version = nil)
|
111
115
|
response = rest_connection(use_api_proxy?(path)).delete do |request|
|
112
|
-
request.url [
|
116
|
+
request.url [ZUORA_REST_MAJOR_VERSION, path].join('')
|
113
117
|
request.headers = rest_headers(zuora_version)
|
114
118
|
end
|
115
119
|
process_response(response)
|
@@ -125,8 +129,13 @@ module ZuoraRestClient
|
|
125
129
|
app: 'https://www.zuora.com' },
|
126
130
|
api_sandbox: {
|
127
131
|
rest: 'https://rest.apisandbox.zuora.com',
|
128
|
-
app: 'https://apisandbox.zuora.com' }
|
132
|
+
app: 'https://apisandbox.zuora.com' },
|
133
|
+
test: {
|
134
|
+
rest: 'https://rest.test.zuora.com',
|
135
|
+
app: 'https://test.zuora.com' }
|
136
|
+
}
|
129
137
|
|
138
|
+
# @deprecated Since the Client class no longer uses this, it will be removed.
|
130
139
|
def app_connection
|
131
140
|
Faraday.new(url: zuora_endpoint.app, request: {
|
132
141
|
open_timeout: @options[:request_open_timeout] || 120,
|
@@ -139,6 +148,7 @@ module ZuoraRestClient
|
|
139
148
|
end
|
140
149
|
end
|
141
150
|
|
151
|
+
# @deprecated Since the Client class no longer uses this, it will be removed.
|
142
152
|
def app_headers
|
143
153
|
headers = { 'Content-Type' => 'application/json' }
|
144
154
|
headers['entityId'] = @options[:entity_id] if !@options[:entity_id].nil?
|
@@ -216,7 +226,7 @@ module ZuoraRestClient
|
|
216
226
|
rest_endpoint = "#{@environment[:rest]}"
|
217
227
|
app_endpoint = "#{@environment[:app]}/apps/api"
|
218
228
|
else
|
219
|
-
raise 'Possible values for environment are: :production, :api_sandbox, :servicesNNN or a hash with base URL values for :rest and :app.'
|
229
|
+
raise 'Possible values for environment are: :production, :api_sandbox, :test, :servicesNNN or a hash with base URL values for :rest and :app.'
|
220
230
|
end
|
221
231
|
OpenStruct.new({ rest: rest_endpoint, app: app_endpoint })
|
222
232
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_rest_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Massad
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -318,7 +318,7 @@ homepage: https://github.com/FronteraConsulting/zuora_rest_client
|
|
318
318
|
licenses:
|
319
319
|
- MIT
|
320
320
|
metadata: {}
|
321
|
-
post_install_message:
|
321
|
+
post_install_message:
|
322
322
|
rdoc_options: []
|
323
323
|
require_paths:
|
324
324
|
- lib
|
@@ -333,8 +333,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
333
333
|
- !ruby/object:Gem::Version
|
334
334
|
version: '0'
|
335
335
|
requirements: []
|
336
|
-
rubygems_version: 3.1.
|
337
|
-
signing_key:
|
336
|
+
rubygems_version: 3.1.2
|
337
|
+
signing_key:
|
338
338
|
specification_version: 4
|
339
339
|
summary: Zuora REST Client
|
340
340
|
test_files: []
|