zuora-ruby 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +10 -0
- data/README.md +2 -3
- data/lib/zuora.rb +1 -0
- data/lib/zuora/calls/subscribe.rb +4 -0
- data/lib/zuora/errors.rb +5 -3
- data/lib/zuora/rest.rb +3 -2
- data/lib/zuora/rest/client.rb +19 -3
- data/lib/zuora/soap/client.rb +2 -1
- data/lib/zuora/utils/envelope.rb +1 -0
- data/lib/zuora/version.rb +2 -1
- data/zuora_ruby.gemspec +1 -1
- metadata +9 -9
- data/circle.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 950ce323c45a5ab88835cbac0ad94ca051f2fb77
|
4
|
+
data.tar.gz: ff96b5ebcb72b7ee90f8a7c00589c147ac44f11d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8151ec6316d825d64e65076c09fd49d619b23817ae224425f313e2695952da9df728a32bb92f6b1508c1ec4252ad651d8184d281a5cc11e11c974a6b0ce76dea
|
7
|
+
data.tar.gz: eee910a1f52b9bbea3e548e8f9ad49ab7d11da191571350b595c8c70c81b51ec21e45729334d28c1242f3fc1e7382a9a756c52051d5762111d7c35e46e15061a
|
data/.DS_Store
CHANGED
Binary file
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
zuora-ruby
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.3.1
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
[![
|
2
|
-
[![Code Climate](https://codeclimate.com/
|
3
|
-
[![Test Coverage](https://codeclimate.com/repos/5706a3fb4f15bd726100652d/badges/4e4615baaec76fd16535/coverage.svg)](https://codeclimate.com/repos/569444dfa3d810003a00313f/coverage)
|
1
|
+
[![Build Status](https://travis-ci.org/contactually/zuora-ruby.svg?branch=master)](https://travis-ci.org/contactually/zuora-ruby)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/contactually/zuora-ruby/badges/gpa.svg)](https://codeclimate.com/github/contactually/zuora-ruby)
|
4
3
|
|
5
4
|
# Zuora SOAP and REST API Client
|
6
5
|
|
data/lib/zuora.rb
CHANGED
@@ -8,6 +8,7 @@ module Zuora
|
|
8
8
|
property :subscribe_options
|
9
9
|
property :subscription
|
10
10
|
property :rate_plan
|
11
|
+
property :rate_plan_charge
|
11
12
|
|
12
13
|
SIMPLE_OBJECTS = [:account, :payment_method, :bill_to_contact].freeze
|
13
14
|
|
@@ -50,6 +51,9 @@ module Zuora
|
|
50
51
|
build_object(builder, :Subscription, subscription)
|
51
52
|
builder[:api].RatePlanData do
|
52
53
|
build_object(builder, :RatePlan, rate_plan)
|
54
|
+
builder[:api].RatePlanChargeData do
|
55
|
+
build_object(builder, :RatePlanCharge, rate_plan_charge)
|
56
|
+
end
|
53
57
|
end
|
54
58
|
end
|
55
59
|
end
|
data/lib/zuora/errors.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Zuora
|
2
2
|
module Errors
|
3
|
-
|
3
|
+
GenericError = Class.new(StandardError)
|
4
|
+
|
5
|
+
class InvalidValue < GenericError
|
4
6
|
attr_reader :response
|
5
7
|
|
6
8
|
def initialize(msg = nil, response = nil)
|
@@ -9,10 +11,10 @@ module Zuora
|
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
12
|
-
class InvalidCredentials <
|
14
|
+
class InvalidCredentials < GenericError
|
13
15
|
end
|
14
16
|
|
15
|
-
class SoapConnectionError <
|
17
|
+
class SoapConnectionError < GenericError
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/zuora/rest.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Zuora
|
2
3
|
module Rest
|
3
4
|
API_URL = 'https://api.zuora.com/rest/v1/'.freeze
|
4
5
|
SANDBOX_URL = 'https://apisandbox-api.zuora.com/rest/v1/'.freeze
|
5
6
|
|
6
7
|
# Unable to connect. Check username / password
|
7
|
-
ConnectionError = Class.new
|
8
|
+
ConnectionError = Class.new Errors::GenericError
|
8
9
|
|
9
10
|
# Non-success response
|
10
|
-
class ErrorResponse <
|
11
|
+
class ErrorResponse < Errors::GenericError
|
11
12
|
attr_reader :response
|
12
13
|
|
13
14
|
def initialize(message = nil, response = nil)
|
data/lib/zuora/rest/client.rb
CHANGED
@@ -88,8 +88,20 @@ module Zuora
|
|
88
88
|
# @throw [ErrorResponse] if unsuccessful
|
89
89
|
# @return [Faraday::Response]
|
90
90
|
def fail_or_response(response)
|
91
|
-
|
92
|
-
|
91
|
+
if response.status != 200
|
92
|
+
fail(ErrorResponse.new("HTTP Status #{response.status}", response))
|
93
|
+
elsif !response.body['success']
|
94
|
+
errors = 'Not successful.'
|
95
|
+
|
96
|
+
if response.body['reasons']
|
97
|
+
reasons = response.body['reasons'].map do |reason|
|
98
|
+
"Error #{reason['code']}: #{reason['message']}"
|
99
|
+
end
|
100
|
+
errors += ' ' + reasons.join(', ')
|
101
|
+
end
|
102
|
+
|
103
|
+
fail(ErrorResponse.new(errors, response))
|
104
|
+
end
|
93
105
|
response
|
94
106
|
end
|
95
107
|
|
@@ -109,12 +121,16 @@ module Zuora
|
|
109
121
|
request.url url
|
110
122
|
request.headers['Content-Type'] = 'application/json'
|
111
123
|
request.headers['Cookie'] = @auth_cookie
|
124
|
+
|
125
|
+
if ENV['ZUORA_API_VERSION'].present?
|
126
|
+
request.headers['zuora-version'] = ENV['ZUORA_API_VERSION']
|
127
|
+
end
|
112
128
|
end
|
113
129
|
|
114
130
|
# @param [String] url
|
115
131
|
# @return [Faraday::Client]
|
116
132
|
def connection(url)
|
117
|
-
Faraday.new(url, ssl: { verify:
|
133
|
+
Faraday.new(url, ssl: { verify: true }) do |conn|
|
118
134
|
conn.request :json
|
119
135
|
conn.response :json, content_type: /\bjson$/
|
120
136
|
conn.use :instrumentation
|
data/lib/zuora/soap/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Zuora
|
2
3
|
module Soap
|
3
4
|
class Client
|
@@ -126,7 +127,7 @@ module Zuora
|
|
126
127
|
# Initializes a connection using api_url
|
127
128
|
# @return [Faraday::Connection]
|
128
129
|
def connection
|
129
|
-
Faraday.new(api_url, ssl: { verify:
|
130
|
+
Faraday.new(api_url, ssl: { verify: true }) do |conn|
|
130
131
|
conn.adapter Faraday.default_adapter
|
131
132
|
end
|
132
133
|
end
|
data/lib/zuora/utils/envelope.rb
CHANGED
data/lib/zuora/version.rb
CHANGED
data/zuora_ruby.gemspec
CHANGED
@@ -47,6 +47,6 @@ Gem::Specification.new do |spec|
|
|
47
47
|
spec.add_development_dependency 'rspec-its'
|
48
48
|
spec.add_development_dependency 'rspec_junit_formatter', '0.2.2'
|
49
49
|
spec.add_development_dependency 'rubocop', '0.36.0'
|
50
|
-
spec.add_development_dependency 'webmock'
|
50
|
+
spec.add_development_dependency 'webmock', '~> 1.22'
|
51
51
|
spec.add_development_dependency 'vcr'
|
52
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contactually Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -238,16 +238,16 @@ dependencies:
|
|
238
238
|
name: webmock
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
240
240
|
requirements:
|
241
|
-
- - "
|
241
|
+
- - "~>"
|
242
242
|
- !ruby/object:Gem::Version
|
243
|
-
version: '
|
243
|
+
version: '1.22'
|
244
244
|
type: :development
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
|
-
- - "
|
248
|
+
- - "~>"
|
249
249
|
- !ruby/object:Gem::Version
|
250
|
-
version: '
|
250
|
+
version: '1.22'
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: vcr
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,7 +274,9 @@ files:
|
|
274
274
|
- ".hound.yml"
|
275
275
|
- ".rspec"
|
276
276
|
- ".rubocop.yml"
|
277
|
+
- ".ruby-gemset"
|
277
278
|
- ".ruby-version"
|
279
|
+
- ".travis.yml"
|
278
280
|
- CODE_OF_CONDUCT.md
|
279
281
|
- Gemfile
|
280
282
|
- LICENSE.txt
|
@@ -282,7 +284,6 @@ files:
|
|
282
284
|
- Rakefile
|
283
285
|
- bin/console
|
284
286
|
- bin/setup
|
285
|
-
- circle.yml
|
286
287
|
- lib/utils/schema_model.rb
|
287
288
|
- lib/zuora.rb
|
288
289
|
- lib/zuora/calls/amend.rb
|
@@ -329,9 +330,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
330
|
version: '0'
|
330
331
|
requirements: []
|
331
332
|
rubyforge_project:
|
332
|
-
rubygems_version: 2.
|
333
|
+
rubygems_version: 2.5.1
|
333
334
|
signing_key:
|
334
335
|
specification_version: 4
|
335
336
|
summary: A Ruby wrapper for Zuora API.
|
336
337
|
test_files: []
|
337
|
-
has_rdoc:
|
data/circle.yml
DELETED