Sha256: 45a9df999b86eb0f0e99e38e5ef4693d34574dc35bc7f324c26e82932c25f729

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 Bytes

Contents

module Zuora
  module Calls
    class Upsert < Hashie::Dash
      # Base class for Create and Update

      # @params [Symbol] type e.g. :BillRun, :Refund
      # @params [Array] objects - collection of objects of type `type`
      property :type, required: true
      property :objects, required: true

      def call_name
        fail 'This class is abstract. Subclassers must def :call_name'
      end

      # Generates a function that takes a builder
      # adds call of call_name and z-object(s) ogit rf type
      # @return [Callable] - function of builder
      def xml_builder
        fail 'objects must respond to :each' unless objects.respond_to?(:each)

        lambda do |builder|
          builder[:api].send(call_name) do
            Zuora::Utils::Envelope.build_objects builder, type, objects
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zuora-ruby-0.6.0 lib/zuora/calls/upsert.rb
zuora-ruby-0.5.0 lib/zuora/calls/upsert.rb
zuora-ruby-0.4.0 lib/zuora/calls/upsert.rb
zuora-ruby-0.3.0 lib/zuora/calls/upsert.rb