active_zuora 1.5.2 → 2.0.0

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.
Files changed (78) hide show
  1. data/Gemfile +4 -0
  2. data/Gemfile.lock +57 -0
  3. data/README.md +155 -0
  4. data/Rakefile +6 -22
  5. data/TODO.md +2 -0
  6. data/active_zuora.gemspec +25 -68
  7. data/lib/active_zuora.rb +37 -6
  8. data/lib/active_zuora/amend.rb +43 -0
  9. data/lib/active_zuora/base.rb +73 -0
  10. data/lib/active_zuora/belongs_to_associations.rb +56 -0
  11. data/lib/active_zuora/connection.rb +41 -0
  12. data/lib/active_zuora/fields.rb +122 -0
  13. data/lib/active_zuora/fields/array_field_decorator.rb +28 -0
  14. data/lib/active_zuora/fields/boolean_field.rb +12 -0
  15. data/lib/active_zuora/fields/date_time_field.rb +19 -0
  16. data/lib/active_zuora/fields/decimal_field.rb +12 -0
  17. data/lib/active_zuora/fields/field.rb +76 -0
  18. data/lib/active_zuora/fields/integer_field.rb +11 -0
  19. data/lib/active_zuora/fields/object_field.rb +31 -0
  20. data/lib/active_zuora/fields/string_field.rb +11 -0
  21. data/lib/active_zuora/generate.rb +43 -0
  22. data/lib/active_zuora/generator.rb +220 -0
  23. data/lib/active_zuora/has_many_associations.rb +37 -0
  24. data/lib/active_zuora/has_many_proxy.rb +50 -0
  25. data/lib/active_zuora/persistence.rb +176 -0
  26. data/lib/active_zuora/relation.rb +253 -0
  27. data/lib/active_zuora/scoping.rb +50 -0
  28. data/lib/active_zuora/subscribe.rb +42 -0
  29. data/lib/active_zuora/version.rb +3 -0
  30. data/lib/active_zuora/z_object.rb +21 -0
  31. data/spec/belongs_to_associations_spec.rb +35 -0
  32. data/spec/has_many_integration_spec.rb +53 -0
  33. data/spec/spec_helper.rb +21 -0
  34. data/spec/subscribe_integration_spec.rb +218 -0
  35. data/spec/zobject_integration_spec.rb +104 -0
  36. data/wsdl/zuora.wsdl +1548 -0
  37. metadata +128 -72
  38. checksums.yaml +0 -7
  39. data/LICENSE +0 -202
  40. data/README.rdoc +0 -36
  41. data/VERSION +0 -1
  42. data/custom_fields.yml +0 -17
  43. data/lib/active_zuora/account.rb +0 -31
  44. data/lib/active_zuora/amendment.rb +0 -7
  45. data/lib/active_zuora/bill_run.rb +0 -4
  46. data/lib/active_zuora/contact.rb +0 -7
  47. data/lib/active_zuora/invoice.rb +0 -46
  48. data/lib/active_zuora/invoice_item.rb +0 -26
  49. data/lib/active_zuora/invoice_item_adjustment.rb +0 -4
  50. data/lib/active_zuora/invoice_payment.rb +0 -11
  51. data/lib/active_zuora/payment.rb +0 -18
  52. data/lib/active_zuora/payment_method.rb +0 -10
  53. data/lib/active_zuora/product.rb +0 -4
  54. data/lib/active_zuora/product_rate_plan.rb +0 -9
  55. data/lib/active_zuora/product_rate_plan_charge.rb +0 -11
  56. data/lib/active_zuora/product_rate_plan_charge_tier.rb +0 -7
  57. data/lib/active_zuora/product_rate_plan_charge_tier_data.rb +0 -4
  58. data/lib/active_zuora/rate_plan.rb +0 -16
  59. data/lib/active_zuora/rate_plan_charge.rb +0 -71
  60. data/lib/active_zuora/rate_plan_charge_data.rb +0 -4
  61. data/lib/active_zuora/rate_plan_charge_tier.rb +0 -4
  62. data/lib/active_zuora/rate_plan_data.rb +0 -4
  63. data/lib/active_zuora/refund.rb +0 -4
  64. data/lib/active_zuora/subscribe_options.rb +0 -4
  65. data/lib/active_zuora/subscribe_request.rb +0 -13
  66. data/lib/active_zuora/subscribe_with_existing_account_request.rb +0 -4
  67. data/lib/active_zuora/subscription.rb +0 -17
  68. data/lib/active_zuora/subscription_data.rb +0 -4
  69. data/lib/active_zuora/usage.rb +0 -4
  70. data/lib/active_zuora/zobject.rb +0 -154
  71. data/lib/soap/property +0 -1
  72. data/lib/zuora/ZUORA.rb +0 -1560
  73. data/lib/zuora/ZUORADriver.rb +0 -145
  74. data/lib/zuora/ZUORAMappingRegistry.rb +0 -1709
  75. data/lib/zuora/ZuoraServiceClient.rb +0 -124
  76. data/lib/zuora/api.rb +0 -18
  77. data/lib/zuora_client.rb +0 -191
  78. data/lib/zuora_interface.rb +0 -215
@@ -1,36 +0,0 @@
1
- == Active Zuora Version 2
2
- * This fork has been moved from its {original location}[https://github.com/anfleene/active_zuora] to its {current location}[https://github.com/tstmedia/active_zuora_v1]
3
- * The Active Zuora Version 2 gem can be found at https://github.com/tstmedia/active_zuora.
4
-
5
- == Active Zoura Version 1
6
-
7
- Client for Zuora API
8
-
9
- This is a wrapper for sample code provided by {Zuora}[http://developer.zuora.com/samplecode.html]
10
-
11
- This is a fork of the Zuora4r Gem that has started to develop a mind of its own.
12
- The fork is adding a new interface to the gem along with removing parts deemed unnecessary.
13
- The underlying implementation of the zuora4r gem is still in place but that is going to change in the future.
14
-
15
-
16
-
17
- == Installing the Gem
18
- $ sudo gem sources -a http://gemcutter.org
19
- $ sudo gem install active_zuora
20
-
21
- == Future Releases
22
-
23
- In the short term this gem will hold on to most of the existing zuora api code with more active recordy style additions to its interface
24
- In the long term the underlying implementation will be refactored and condensed into something smaller and more idiomatic
25
-
26
- === Important Missing Features
27
-
28
- Completion of active zuora's CRUD actions on instance methods
29
- Support for Zuora's queryMore api call
30
-
31
- Remove weird error handling Anti Pattern that rescues and prints all Exceptions
32
-
33
- BUG:
34
- Auto quote where calls
35
-
36
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.4.21
@@ -1,17 +0,0 @@
1
- Account:
2
- - ScreenName
3
- - Locale
4
- Subscription:
5
- - AppID
6
- - Subdomain
7
- Product:
8
- - NumInstances
9
- - InclusionList
10
- - AvailabilityList
11
- - ProductType
12
- ProductRatePlan:
13
- - NumInstances
14
- - Slug
15
- - NextSlug
16
- - Duration
17
- - Trial
@@ -1,31 +0,0 @@
1
- module Zuora
2
- class Account < ZObject
3
- def billTo
4
- @billTo ||= Contact.find(self.billToId)
5
- end
6
-
7
- def soldTo
8
- @soldTo ||= Contact.find(self.soldToId)
9
- end
10
-
11
- def subscriptions
12
- @subscriptions ||= Subscription.where(:accountid => self.id)
13
- end
14
-
15
- def invoices
16
- @invoices ||= Invoice.where(:accountid => self.id)
17
- end
18
-
19
- def invoices_with_balance
20
- @invoices_with_balance ||= Invoice.where("accountId = '#{self.id}' AND Balance > 0")
21
- end
22
-
23
- def payment_methods
24
- @payment_methods ||= PaymentMethod.where(:accountid => self.id)
25
- end
26
-
27
- def contacts
28
- @contacts ||= Contact.where(:accountid => self.id)
29
- end
30
- end
31
- end
@@ -1,7 +0,0 @@
1
- module Zuora
2
- class Amendment < ZObject
3
-
4
- exclude_query_attributes :ratePlanData, :termCommitment
5
-
6
- end
7
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class BillRun < ZObject
3
- end
4
- end
@@ -1,7 +0,0 @@
1
- module Zuora
2
- class Contact < ZObject
3
- def account
4
- @account ||= Account.find(self.accountId)
5
- end
6
- end
7
- end
@@ -1,46 +0,0 @@
1
- module Zuora
2
- class Invoice < ZObject
3
- def self.extra_attributes(attributes=[])
4
- super([:body])
5
- end
6
-
7
- def self.create(attributes={})
8
- self.client.generate([self.new(attributes).to_zobject]).first
9
- end
10
-
11
- def save
12
- result = self.class.create(self.attributes)
13
- if result[:success]
14
- @errors = []
15
- __setobj__(self.class.find(result[:id]).to_zobject)
16
- else
17
- @errors = result[:errors]
18
- end
19
- result[:success]
20
- end
21
-
22
- def errors
23
- @errors || []
24
- end
25
-
26
- def post
27
- return false unless self.id
28
- result = self.class.update_attributes(:id => self.id, :status => "Posted").first
29
- @errors = result[:errors]
30
- result[:success]
31
- end
32
-
33
- def invoice_items
34
- @invoice_items ||= InvoiceItem.where(:invoiceid => self.id)
35
- end
36
-
37
- def account
38
- @account ||= Account.find(self.accountId)
39
- end
40
-
41
- def payments
42
- # Payments, sorted by date.
43
- @payments ||= InvoicePayment.where(:invoiceId => self.id).map(&:payment).sort { |a, b| a.effectiveDate <=> b.effectiveDate }
44
- end
45
- end
46
- end
@@ -1,26 +0,0 @@
1
- module Zuora
2
- class InvoiceItem < ZObject
3
-
4
- def invoice
5
- @invoice ||= Invoice.find(invoiceId)
6
- end
7
-
8
- def rate_plan_charge
9
- @rate_plan_charge ||= RatePlanCharge.find(ratePlanChargeId)
10
- end
11
-
12
- def adjustments
13
- @adjustments ||= InvoiceItemAdjustment.where(:sourceType => 'InvoiceDetail', :sourceId => id)
14
- end
15
-
16
- def adjusted_charge_amount
17
- @adjusted_charge_amount ||=
18
- adjustments.inject(chargeAmount) do |amount, adjustment|
19
- # Adjustment types are either Credit or Charge
20
- # Credits will have a reducing (subtracting) effect on the invoice item charge.
21
- adjustment.type == "Credit" ? amount - adjustment.amount : amount + adjustment.amount
22
- end
23
- end
24
-
25
- end
26
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class InvoiceItemAdjustment < ZObject
3
- end
4
- end
@@ -1,11 +0,0 @@
1
- module Zuora
2
- class InvoicePayment < ZObject
3
- def invoice
4
- @invoice ||= Invoice.find(self.invoiceId)
5
- end
6
-
7
- def payment
8
- @payment ||= Payment.find(self.paymentId)
9
- end
10
- end
11
- end
@@ -1,18 +0,0 @@
1
- module Zuora
2
- class Payment < ZObject
3
-
4
- exclude_query_attributes :appliedInvoiceAmount, :invoiceId
5
-
6
- def account
7
- @account ||= Account.find(self.accountId)
8
- end
9
-
10
- def payment_method
11
- @payment_method ||= PaymentMethod.find(self.paymentMethodId)
12
- end
13
-
14
- def invoices
15
- @invoices ||= InvoicePayment.where(:paymentId => self.id).map(&:invoice)
16
- end
17
- end
18
- end
@@ -1,10 +0,0 @@
1
- module Zuora
2
- class PaymentMethod < ZObject
3
-
4
- exclude_query_attributes :achAccountNumber, :creditCardNumber, :creditCardSecurityCode
5
-
6
- def account
7
- @account ||= Account.find(self.accountId)
8
- end
9
- end
10
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class Product < ZObject
3
- end
4
- end
@@ -1,9 +0,0 @@
1
- module Zuora
2
- class ProductRatePlan < ZObject
3
-
4
- def charges
5
- @charges ||= ProductRatePlanCharge.where(:productRatePlanId => id)
6
- end
7
-
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- module Zuora
2
- class ProductRatePlanCharge < ZObject
3
- def product_rate_plan
4
- @product_rate_plan ||= ProductRatePlan.find(self.ProductRatePlanId)
5
- end
6
-
7
- def product_rate_plan_charge_tiers
8
- @product_rate_plan_charge_tiers ||= ProductRatePlanChargeTier.where(:productRatePlanChargeId => self.id)
9
- end
10
- end
11
- end
@@ -1,7 +0,0 @@
1
- module Zuora
2
- class ProductRatePlanChargeTier < ZObject
3
- def product_rate_plan_charge
4
- @product_rate_plan_charge ||= ProductRatePlanCharge.find(self.productRatePlanChargeId)
5
- end
6
- end
7
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class ProductRatePlanChargeTierData < ZObject
3
- end
4
- end
@@ -1,16 +0,0 @@
1
- module Zuora
2
- class RatePlan < ZObject
3
- def rate_plan_charges
4
- @rate_plan_charges ||= RatePlanCharge.where(:ratePlanId => self.id)
5
- end
6
-
7
- def subscription
8
- @subscription ||= Subscription.find(self.subscriptionId)
9
- end
10
-
11
- def product_rate_plan
12
- @product_rate_plan ||= ProductRatePlan.find(self.productRatePlanId)
13
- end
14
-
15
- end
16
- end
@@ -1,71 +0,0 @@
1
- module Zuora
2
- class RatePlanCharge < ZObject
3
-
4
- #this code only supports flat fee, per unit and volume pricing. It does not support tiered pricing.
5
-
6
-
7
- exclude_query_attributes :overagePrice, :includedUnits, :discountAmount, :discountPercentage, :price
8
-
9
- def rate_plan
10
- @rate_plan ||= RatePlan.find(self.ratePlanId)
11
- end
12
-
13
- def rate_plan_charge_tier
14
- query = charge_tier_query("ratePlanChargeId", id)
15
- @rate_plan_charge_tier ||= RatePlanChargeTier.where(query).first
16
- end
17
-
18
- def product_rate_plan_charge_tier
19
- query = charge_tier_query("productRatePlanChargeId", productRatePlanChargeId)
20
- @product_rate_plan_charge_tier ||= ProductRatePlanChargeTier.where(query).first
21
- end
22
-
23
- def charge_tier_query(identifier_name, identifier_value)
24
- query = "#{identifier_name} = '#{identifier_value}'"
25
- query += " and startingUnit <= #{charge_quantity} and endingUnit >= #{charge_quantity}" if chargeModel == "Volume Pricing"
26
- query
27
- end
28
-
29
- def product_rate_plan_charge
30
- @product_rate_plan_charge ||= ProductRatePlanCharge.find(self.productRatePlanChargeId)
31
- end
32
-
33
- def usages
34
- @usages ||= Usage.where(:chargeId => id)
35
- end
36
-
37
- def unload_usages
38
- @usages = nil
39
- self
40
- end
41
-
42
- def charge_quantity
43
- quantity || 1
44
- end
45
-
46
- def price
47
- super || rate_plan_charge_tier.price
48
- end
49
-
50
- def total_price
51
- rate_plan_charge_tier.priceFormat == "Flat Fee" ? price : charge_quantity * price
52
- end
53
-
54
- def list_price
55
- product_rate_plan_charge_tier.price
56
- end
57
-
58
- def total_list_price
59
- product_rate_plan_charge_tier.priceFormat == "Flat Fee" ? list_price : charge_quantity * list_price
60
- end
61
-
62
- def discount?
63
- price < list_price
64
- end
65
-
66
- def discount_percent
67
- list_price.zero? ? nil : (1 - price / list_price) * 100
68
- end
69
-
70
- end
71
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class RatePlanChargeData < ZObject
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class RatePlanChargeTier < ZObject
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class RatePlanData < ZObject
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class Refund < ZObject
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class SubscribeOptions < ZObject
3
- end
4
- end
@@ -1,13 +0,0 @@
1
- module Zuora
2
- class SubscribeRequest < ZObject
3
- def self.create(args={})
4
- self.client.subscribe([self.new(args).to_zobject])
5
- end
6
-
7
- def save
8
- result = self.class.client.subscribe([self.to_zobject])
9
- self.account.id = result.accountId
10
- result.success
11
- end
12
- end
13
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class SubscribeWithExistingAccountRequest < ZObject
3
- end
4
- end
@@ -1,17 +0,0 @@
1
- module Zuora
2
- class Subscription < ZObject
3
-
4
- def account
5
- @account ||= Account.find(self.accountId)
6
- end
7
-
8
- def rate_plans
9
- @rate_plans ||= RatePlan.where(:subscriptionId => self.id)
10
- end
11
-
12
- def unload_rate_plans
13
- @rate_plans = nil
14
- end
15
-
16
- end
17
- end
@@ -1,4 +0,0 @@
1
- module Zuora
2
- class SubscriptionData < ZObject
3
- end
4
- end