active_zuora 2.2.7 → 2.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +1 -0
- data/README.md +6 -0
- data/lib/active_zuora/connection.rb +6 -2
- data/lib/active_zuora/generator.rb +4 -0
- data/lib/active_zuora/version.rb +1 -1
- data/spec/connection_spec.rb +29 -0
- data/spec/subscribe_integration_spec.rb +23 -17
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5f5302e3adec5088e1386b7b8cbfb2e8e5ab802b
         | 
| 4 | 
            +
              data.tar.gz: 57ff7f96be0fa495509a9a18593b9393e862a47e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b633b481e1497d5c59e5221ed656953a6460b9a5e9d689e1e9c46cc53da4aebedae3fbf9f57080a6654826441f002d84e2dcc60e00d1c58ebb18ea2825a6bbc2
         | 
| 7 | 
            +
              data.tar.gz: 9630192d73bf3852d21fc44c6803b8f1980dad167d49ec0b2baa2292e3ac1d2c5cea36a4e66c3c5d797a07bb3eff8023b253681da5de6bd50893b37bbe9209eb
         | 
    
        data/CHANGELOG.markdown
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -42,6 +42,12 @@ Override the default endpoint or host loaded from the wsdl | |
| 42 42 | 
             
            ActiveZuora::Base.connection.soap_client.wsdl.endpoint.host = "www.zuora.com" if Rails.env.production?
         | 
| 43 43 | 
             
            ````
         | 
| 44 44 |  | 
| 45 | 
            +
            To add custom headers to your Zuora requests, you can use the following pattern
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            ```
         | 
| 48 | 
            +
            ActiveZuora::Base.connection.custom_header = { 'X-Foo' => 'Bar' }
         | 
| 49 | 
            +
            ```
         | 
| 50 | 
            +
             | 
| 45 51 | 
             
            ## Defining Classes
         | 
| 46 52 |  | 
| 47 53 | 
             
            You can auto-generate all your Zuora classes from the wsdl file.  It will generate all Z-Objects, like Account and Subscription, and Zuora Complex objects, such as SubscribeRequest.
         | 
| @@ -21,7 +21,11 @@ module ActiveZuora | |
| 21 21 | 
             
                  # Returns a session_id upon success, raises an exception on failure.
         | 
| 22 22 | 
             
                  # Instance variables aren't available within the soap request block.
         | 
| 23 23 | 
             
                  body = { :username => @username, :password => @password }
         | 
| 24 | 
            -
                   | 
| 24 | 
            +
                  header = @custom_header
         | 
| 25 | 
            +
                  @soap_client.request(:login) do
         | 
| 26 | 
            +
                    soap.body = body
         | 
| 27 | 
            +
                    soap.header = header
         | 
| 28 | 
            +
                  end[:login_response][:result][:session]
         | 
| 25 29 | 
             
                end
         | 
| 26 30 |  | 
| 27 31 | 
             
                def request(*args, &block)
         | 
| @@ -41,4 +45,4 @@ module ActiveZuora | |
| 41 45 | 
             
                end
         | 
| 42 46 |  | 
| 43 47 | 
             
              end
         | 
| 44 | 
            -
            end
         | 
| 48 | 
            +
            end
         | 
| @@ -152,6 +152,10 @@ module ActiveZuora | |
| 152 152 | 
             
                    lazy_load :body
         | 
| 153 153 | 
             
                  end
         | 
| 154 154 |  | 
| 155 | 
            +
                  customize 'InvoiceItem' do
         | 
| 156 | 
            +
                    exclude_from_queries :product_rate_plan_charge_id
         | 
| 157 | 
            +
                  end
         | 
| 158 | 
            +
             | 
| 155 159 | 
             
                  customize 'InvoiceItemAdjustment' do
         | 
| 156 160 | 
             
                    exclude_from_queries :customer_name, :customer_number
         | 
| 157 161 | 
             
                  end
         | 
    
        data/lib/active_zuora/version.rb
    CHANGED
    
    
    
        data/spec/connection_spec.rb
    CHANGED
    
    | @@ -34,4 +34,33 @@ describe ActiveZuora::Connection do | |
| 34 34 | 
             
                  expect(@stub_was_called).to be_truthy
         | 
| 35 35 | 
             
                end
         | 
| 36 36 | 
             
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              describe 'login' do
         | 
| 39 | 
            +
                before do
         | 
| 40 | 
            +
                  @connection = described_class.new
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                context 'when a custom header is set' do
         | 
| 44 | 
            +
                  it 'uses the custom header' do
         | 
| 45 | 
            +
                    @connection.custom_header = { 'TestHeader' => 'Foo' }
         | 
| 46 | 
            +
                    allow(Savon::SOAP::Request).to receive(:new) do |config, http, soap|
         | 
| 47 | 
            +
                      expect(soap.header).to eq({ 'TestHeader' => 'Foo' })
         | 
| 48 | 
            +
                      double('response').as_null_object
         | 
| 49 | 
            +
                    end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                    @connection.login
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                context 'when a custom header is not set' do
         | 
| 56 | 
            +
                  it 'does not use the custom header' do
         | 
| 57 | 
            +
                    allow(Savon::SOAP::Request).to receive(:new) do |config, http, soap|
         | 
| 58 | 
            +
                      expect(soap.header).to eq({})
         | 
| 59 | 
            +
                      double('response').as_null_object
         | 
| 60 | 
            +
                    end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                    @connection.login
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
              end
         | 
| 37 66 | 
             
            end
         | 
| @@ -1,10 +1,8 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe "Subscribe" do
         | 
| 4 | 
            -
             | 
| 5 4 | 
             
              integration_test do
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                before do
         | 
| 5 | 
            +
                before(:all) do
         | 
| 8 6 | 
             
                  # Setup product.
         | 
| 9 7 | 
             
                  @product = Z::Product.where(:name => "Awesome Product").first ||
         | 
| 10 8 | 
             
                    Z::Product.create!(
         | 
| @@ -38,11 +36,7 @@ describe "Subscribe" do | |
| 38 36 | 
             
                    )
         | 
| 39 37 | 
             
                end
         | 
| 40 38 |  | 
| 41 | 
            -
                after  | 
| 42 | 
            -
                  @product.delete
         | 
| 43 | 
            -
                  @account.delete
         | 
| 44 | 
            -
                  @account_2.delete if !!@account_2
         | 
| 45 | 
            -
                end
         | 
| 39 | 
            +
                after(:all) { @product.try(:delete) }
         | 
| 46 40 |  | 
| 47 41 | 
             
                it "Can successfully subscribe and amend using a new account" do
         | 
| 48 42 |  | 
| @@ -90,9 +84,10 @@ describe "Subscribe" do | |
| 90 84 | 
             
                  )
         | 
| 91 85 |  | 
| 92 86 | 
             
                  subscribe_request.subscribe!
         | 
| 93 | 
            -
                   | 
| 94 | 
            -
             | 
| 95 | 
            -
                  expect( | 
| 87 | 
            +
                  account = subscribe_request.account
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                  expect(account.new_record?).to be_falsey
         | 
| 90 | 
            +
                  expect(account.changed?).to be_falsey
         | 
| 96 91 | 
             
                  expect(subscribe_request.subscription_data.subscription.new_record?).to be_falsey
         | 
| 97 92 | 
             
                  expect(subscribe_request.subscription_data.subscription.rate_plans.first.
         | 
| 98 93 | 
             
                    rate_plan_charges.first.
         | 
| @@ -122,6 +117,8 @@ describe "Subscribe" do | |
| 122 117 | 
             
                  amend_request.amend!
         | 
| 123 118 | 
             
                  expect(amend_request.amendments.first.new_record?).to be_falsey
         | 
| 124 119 | 
             
                  expect(amend_request.result).to be_present
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                  account.delete
         | 
| 125 122 | 
             
                end
         | 
| 126 123 |  | 
| 127 124 | 
             
                it "Can successfully subscribe and generate an invoice" do
         | 
| @@ -171,9 +168,10 @@ describe "Subscribe" do | |
| 171 168 | 
             
                  )
         | 
| 172 169 |  | 
| 173 170 | 
             
                  subscribe_request.subscribe!
         | 
| 174 | 
            -
                   | 
| 175 | 
            -
             | 
| 176 | 
            -
                  expect( | 
| 171 | 
            +
                  account = subscribe_request.account
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                  expect(account.new_record?).to be_falsey
         | 
| 174 | 
            +
                  expect(account.changed?).to be_falsey
         | 
| 177 175 | 
             
                  expect(subscribe_request.subscription_data.subscription.new_record?).to be_falsey
         | 
| 178 176 | 
             
                  expect(subscribe_request.subscription_data.subscription.rate_plans.first.
         | 
| 179 177 | 
             
                    rate_plan_charges.first.
         | 
| @@ -214,6 +212,8 @@ describe "Subscribe" do | |
| 214 212 | 
             
                  expect(invoice.id).to be_present
         | 
| 215 213 | 
             
                  expect(invoice.account_id).to eq(subscribe_request.account.id)
         | 
| 216 214 | 
             
                  expect(invoice.body).to be_present
         | 
| 215 | 
            +
             | 
| 216 | 
            +
                  account.delete
         | 
| 217 217 | 
             
                end
         | 
| 218 218 |  | 
| 219 219 | 
             
                it "Can successfully batch subscribe from a collection proxy of subscribe requests and generate an invoice for the first subscription" do
         | 
| @@ -308,8 +308,12 @@ describe "Subscribe" do | |
| 308 308 | 
             
                  collection = Z::CollectionProxy.new([subscribe_request_1,subscribe_request_2])
         | 
| 309 309 | 
             
                  collection.batch_subscribe!
         | 
| 310 310 |  | 
| 311 | 
            +
                  account_1 = subscribe_request_1.account
         | 
| 312 | 
            +
                  account_2 = subscribe_request_2.account
         | 
| 313 | 
            +
             | 
| 311 314 | 
             
                  #subscribe reqeust 1
         | 
| 312 | 
            -
                   | 
| 315 | 
            +
                  expect(account_1.new_record?).to be_falsey
         | 
| 316 | 
            +
                  expect(account_1.changed?).to be_falsey
         | 
| 313 317 | 
             
                  expect(subscribe_request_1.subscription_data.subscription.new_record?).to be_falsey
         | 
| 314 318 | 
             
                  expect(subscribe_request_1.subscription_data.subscription.rate_plans.first.
         | 
| 315 319 | 
             
                    rate_plan_charges.first.
         | 
| @@ -317,13 +321,15 @@ describe "Subscribe" do | |
| 317 321 | 
             
                  expect(subscribe_request_1.result).to be_present
         | 
| 318 322 |  | 
| 319 323 | 
             
                  #subscribe reqeust 2
         | 
| 320 | 
            -
                   | 
| 324 | 
            +
                  expect(account_2.new_record?).to be_falsey
         | 
| 325 | 
            +
                  expect(account_2.changed?).to be_falsey
         | 
| 321 326 | 
             
                  expect(subscribe_request_2.subscription_data.subscription.new_record?).to be_falsey
         | 
| 322 327 | 
             
                  expect(subscribe_request_2.subscription_data.subscription.rate_plans.first.
         | 
| 323 328 | 
             
                    rate_plan_charges.first.
         | 
| 324 329 | 
             
                    product_rate_plan_charge).to eq(@product_rate_plan_charge)
         | 
| 325 330 | 
             
                  expect(subscribe_request_2.result).to be_present
         | 
| 326 | 
            -
                end
         | 
| 327 331 |  | 
| 332 | 
            +
                  [account_1, account_2].each(&:delete)
         | 
| 333 | 
            +
                end
         | 
| 328 334 | 
             
              end
         | 
| 329 335 | 
             
            end
         | 
    
        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. | 
| 4 | 
            +
              version: 2.3.0
         | 
| 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- | 
| 12 | 
            +
            date: 2015-10-26 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: savon
         |