Sha256: b0bd043b74ff3475e48bcf8e7f9116c1e230047403652a79ba76ba46b9ed670e

Contents?: true

Size: 1.07 KB

Versions: 30

Compression:

Stored size: 1.07 KB

Contents

module ActiveZuora
  module Amend

    # This is meant to be included onto a AmendRequest class.
    # Returns true/false on success.
    # Result hash is stored in #result.
    # If success, the ids will be set in the given amendments.
    # If failure, errors will be present on object.

    extend ActiveSupport::Concern

    included do
      include Base
      attr_accessor :result
    end

    def amend
      self.result = self.class.connection.request(:amend) do |soap|
        soap.body do |xml| 
          build_xml(xml, soap, 
            :namespace => soap.namespace,
            :element_name => :requests,
            :force_type => true)
        end
      end[:amend_response][:results]
      if result[:success]
        [result[:amendment_ids]].flatten.compact.each_with_index do |id, i|
          amendments[i].id = id
        end
        clear_changed_attributes
        true
      else
        add_zuora_errors(result[:errors])
        false
      end
    end

    def amend!
      raise "Could not amend: #{errors.full_messages.join ', '}" unless amend
    end

  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
active_zuora-2.6.0 lib/active_zuora/amend.rb
active_zuora-2.5.4 lib/active_zuora/amend.rb
active_zuora-2.5.3 lib/active_zuora/amend.rb
active_zuora-2.5.2 lib/active_zuora/amend.rb
active_zuora-2.5.1 lib/active_zuora/amend.rb
active_zuora-2.5.0 lib/active_zuora/amend.rb
active_zuora-2.4.1 lib/active_zuora/amend.rb
active_zuora-2.4.0 lib/active_zuora/amend.rb
active_zuora-2.3.1 lib/active_zuora/amend.rb
active_zuora-2.3.0 lib/active_zuora/amend.rb
active_zuora-2.2.7 lib/active_zuora/amend.rb
active_zuora-2.2.6 lib/active_zuora/amend.rb
active_zuora-2.2.5 lib/active_zuora/amend.rb
active_zuora-2.2.4 lib/active_zuora/amend.rb
active_zuora-2.2.3 lib/active_zuora/amend.rb
active_zuora-2.2.2 lib/active_zuora/amend.rb
active_zuora-2.2.1 lib/active_zuora/amend.rb
active_zuora-2.2.0 lib/active_zuora/amend.rb
active_zuora-2.1.4 lib/active_zuora/amend.rb
active_zuora-2.1.3 lib/active_zuora/amend.rb