active_zuora 2.3.0 → 2.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f5302e3adec5088e1386b7b8cbfb2e8e5ab802b
4
- data.tar.gz: 57ff7f96be0fa495509a9a18593b9393e862a47e
3
+ metadata.gz: 65ef7a2fd66b972b6a70886b761192cc1fe479db
4
+ data.tar.gz: 742f84177e47b462ec319369fe934b2969155c73
5
5
  SHA512:
6
- metadata.gz: b633b481e1497d5c59e5221ed656953a6460b9a5e9d689e1e9c46cc53da4aebedae3fbf9f57080a6654826441f002d84e2dcc60e00d1c58ebb18ea2825a6bbc2
7
- data.tar.gz: 9630192d73bf3852d21fc44c6803b8f1980dad167d49ec0b2baa2292e3ac1d2c5cea36a4e66c3c5d797a07bb3eff8023b253681da5de6bd50893b37bbe9209eb
6
+ metadata.gz: a57f894f4afd97482f7f2e03584a8b9839b4a85a1b56c370bb07278d037d9123ff9fb14030213cdf87bda47f68ebb12a36b337b4bf17a36539225fbf6786523a
7
+ data.tar.gz: 584a68481832b02a117519bdb2a64f68f9ed635685ff80ca2f9dcf008dd31fff12bd48900927016b1b1ee7eac877598e65afd6bbeb872d2254e03a366d3b07e6
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,6 @@
1
+ #### v2.3.1
2
+ * Add billing preview capability
3
+ * Capitalize first letter of wsdl object name to ensure that it is a valid Ruby constant
1
4
  #### v2.3.0
2
5
  #### v2.2.7
3
6
  #### v2.2.6
@@ -10,8 +13,6 @@
10
13
  * Fix #43 - Add invoice_payment_data to exclusions list
11
14
 
12
15
  > David: : https://github.com/sportngin/active_zuora/pull/44
13
-
14
- #### v2.2.1
15
16
  #### v2.2.0
16
17
  #### v2.1.4
17
18
  #### v2.1.3
data/lib/active_zuora.rb CHANGED
@@ -16,6 +16,7 @@ require 'active_zuora/z_object'
16
16
  require 'active_zuora/subscribe'
17
17
  require 'active_zuora/amend'
18
18
  require 'active_zuora/generate'
19
+ require 'active_zuora/billing_preview'
19
20
  require 'active_zuora/batch_subscribe'
20
21
  require 'active_zuora/collection_proxy'
21
22
  require 'active_zuora/lazy_attr'
@@ -0,0 +1,49 @@
1
+ module ActiveZuora
2
+ module BillingPreview
3
+
4
+ # This is meant to be included onto an BillingPreviewRequest class.
5
+ # Returns a BillingPreviewResponse object on success.
6
+ # Result hash is stored in #result.
7
+ # If failure, errors will be present on object.
8
+
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ include Base
13
+ attr_accessor :result
14
+ end
15
+
16
+ def billing_preview
17
+ self.result = self.class.connection.request(:billing_preview) do |soap|
18
+ soap.body do |xml|
19
+ build_xml(xml, soap,
20
+ :namespace => soap.namespace,
21
+ :element_name => :requests,
22
+ :force_type => true)
23
+ end
24
+ end[:billing_preview_response][:results]
25
+
26
+ if result[:success]
27
+ clear_changed_attributes
28
+ filtered_invoice_items = self.result[:invoice_item].map do |invoice_item|
29
+ #Filter out data in the return value that are not valid invoice item fields such as
30
+ # :"@xmlns:ns2"=>"http://object.api.zuora.com/",
31
+ # :"@xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
32
+ # :"@xsi:type"=>"ns2:InvoiceItem"
33
+ invoice_item.select{|key, v| ActiveZuora::InvoiceItem.field_names.include?(key)}
34
+ end
35
+ ActiveZuora::BillingPreviewResult.new(self.result.merge(invoice_item: filtered_invoice_items))
36
+ else
37
+ add_zuora_errors(result[:errors])
38
+ false
39
+ end
40
+ end
41
+
42
+ def billing_preview!
43
+ billing_preview.tap do |preview|
44
+ raise "Could not billing preview: #{errors.full_messages.join ', '}" unless preview
45
+ end
46
+ end
47
+
48
+ end
49
+ end
@@ -30,6 +30,7 @@ module ActiveZuora
30
30
  # Skip the zObject base class, we define our own.
31
31
  next if class_name == "zObject"
32
32
 
33
+ class_name[0] = class_name[0].upcase
33
34
  zuora_class = Class.new
34
35
  @class_nesting.const_set(class_name, zuora_class)
35
36
  @classes << zuora_class
@@ -72,7 +73,7 @@ module ActiveZuora
72
73
  :zuora_name => zuora_name, :array => is_array,
73
74
  :class_name => zuora_class.nested_class_name(field_type.split(':').last)
74
75
  else
75
- puts "Unkown field type: #{field_type}"
76
+ puts "Unknown field type: #{field_type}"
76
77
  end
77
78
  end # each element
78
79
 
@@ -156,6 +157,10 @@ module ActiveZuora
156
157
  exclude_from_queries :product_rate_plan_charge_id
157
158
  end
158
159
 
160
+ customize 'BillingPreviewRequest' do
161
+ include BillingPreview
162
+ end
163
+
159
164
  customize 'InvoiceItemAdjustment' do
160
165
  exclude_from_queries :customer_name, :customer_number
161
166
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveZuora
2
- VERSION = "2.3.0"
2
+ VERSION = "2.3.1"
3
3
  end
@@ -121,7 +121,7 @@ describe "Subscribe" do
121
121
  account.delete
122
122
  end
123
123
 
124
- it "Can successfully subscribe and generate an invoice" do
124
+ it "Can successfully subscribe and generate a bill preview and an invoice" do
125
125
 
126
126
  subscribe_request = Z::SubscribeRequest.new(
127
127
  :account => {
@@ -200,6 +200,15 @@ describe "Subscribe" do
200
200
  expect(amend_request.amendments.first.new_record?).to be_falsey
201
201
  expect(amend_request.result).to be_present
202
202
 
203
+ billing_preview_request = Z::BillingPreviewRequest.new(
204
+ account_id: subscribe_request.account.id,
205
+ target_date: Date.today + 2.months
206
+ )
207
+
208
+ billing_preview_result = billing_preview_request.billing_preview!
209
+ expect(billing_preview_result).to be_present
210
+ expect(billing_preview_result.invoice_item).to be_present
211
+
203
212
  invoice = Z::Invoice.new(
204
213
  account_id: subscribe_request.account.id,
205
214
  invoice_date: Date.today,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_zuora
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Lebert
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-26 00:00:00.000000000 Z
12
+ date: 2015-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -119,6 +119,7 @@ files:
119
119
  - lib/active_zuora/base.rb
120
120
  - lib/active_zuora/batch_subscribe.rb
121
121
  - lib/active_zuora/belongs_to_associations.rb
122
+ - lib/active_zuora/billing_preview.rb
122
123
  - lib/active_zuora/collection_proxy.rb
123
124
  - lib/active_zuora/connection.rb
124
125
  - lib/active_zuora/fields.rb