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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 851d0abfff60f962e9325f3f2640b98e26757c9c
4
- data.tar.gz: f45b66d5be58bef7ee808bb850d4ac3fd3a95990
3
+ metadata.gz: 950ce323c45a5ab88835cbac0ad94ca051f2fb77
4
+ data.tar.gz: ff96b5ebcb72b7ee90f8a7c00589c147ac44f11d
5
5
  SHA512:
6
- metadata.gz: 98234b223c83ab68a662eb5dfd48f5fd827e69375cb142d101dc0570538212a674fbe9961710671644cee8494b14ab42e1b2b122c0bf22094a1a9fd54721626d
7
- data.tar.gz: 1221da190beb70589a3260e0af9797d48f8b603a58e60ada3d5b6d4c803d3869c3761a540323fafb9376697a8121ff19a9e6a9647605eadfe17f2b61119dec1b
6
+ metadata.gz: 8151ec6316d825d64e65076c09fd49d619b23817ae224425f313e2695952da9df728a32bb92f6b1508c1ec4252ad651d8184d281a5cc11e11c974a6b0ce76dea
7
+ data.tar.gz: eee910a1f52b9bbea3e548e8f9ad49ab7d11da191571350b595c8c70c81b51ec21e45729334d28c1242f3fc1e7382a9a756c52051d5762111d7c35e46e15061a
data/.DS_Store CHANGED
Binary file
@@ -0,0 +1 @@
1
+ zuora-ruby
@@ -1 +1 @@
1
- ruby-2.2.3
1
+ ruby-2.3.1
@@ -0,0 +1,10 @@
1
+ sudo: required
2
+ dist: trusty
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.1
7
+
8
+ script:
9
+ - bundle exec rspec
10
+ - bundle exec rubocop
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
- [![Circle CI](https://circleci.com/gh/contactually/zuora-ruby.svg?style=shield&circle-token=808be5d625e91e331bedb37a2fe94412bb3bc15e)](https://circleci.com/gh/contactually/zuora-ruby)
2
- [![Code Climate](https://codeclimate.com/repos/5706a3fb4f15bd726100652d/badges/4e4615baaec76fd16535/gpa.svg)](https://codeclimate.com/repos/569444dfa3d810003a00313f/feed)
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
 
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  # Dependencies
4
5
  require 'faraday'
@@ -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
@@ -1,6 +1,8 @@
1
1
  module Zuora
2
2
  module Errors
3
- class InvalidValue < StandardError
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 < StandardError
14
+ class InvalidCredentials < GenericError
13
15
  end
14
16
 
15
- class SoapConnectionError < StandardError
17
+ class SoapConnectionError < GenericError
16
18
  end
17
19
  end
18
20
  end
@@ -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 StandardError
8
+ ConnectionError = Class.new Errors::GenericError
8
9
 
9
10
  # Non-success response
10
- class ErrorResponse < StandardError
11
+ class ErrorResponse < Errors::GenericError
11
12
  attr_reader :response
12
13
 
13
14
  def initialize(message = nil, response = nil)
@@ -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
- success = response.body['success'] && response.status == 200
92
- fail(ErrorResponse.new('Non-200', response)) unless success
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: false }) do |conn|
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
@@ -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: false }) do |conn|
130
+ Faraday.new(api_url, ssl: { verify: true }) do |conn|
130
131
  conn.adapter Faraday.default_adapter
131
132
  end
132
133
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Zuora
2
3
  module Utils
3
4
  module Envelope
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Zuora
2
- VERSION = '0.5.0'.freeze
3
+ VERSION = '0.6.0'.freeze
3
4
  end
@@ -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.5.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: 2016-05-12 00:00:00.000000000 Z
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: '0'
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: '0'
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.4.8
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
@@ -1,3 +0,0 @@
1
- test:
2
- post:
3
- - bundle exec rubocop