Sha256: 827f9fee0a3f3d3dd9991fb5250d5b01e97892050dbabd8015b5a8ffbe46492d

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

module BillForward
  # This entity exposes the following child entities via method_missing:
  # 
  # Invoice         .invoice
  class SubscriptionCharge < MutableEntity
  	@resource_path = BillForward::ResourcePath.new('charges', 'subscriptionCharge')

    class << self
      def create(entity = nil)
        raise DenyMethod.new 'Create support is denied for this entity; '+
                                 'Please use Invoice.create_charge or Subscription.create_charge instead.'
      end

      def recalculate(id, request_object = {}, custom_client = nil)
        raise ArgumentError.new("id cannot be nil") if id.nil?

        endpoint = sprintf('%s/recalculate',
                           ERB::Util.url_encode(id)
        )

        request_entity = BillForward::GenericEntity.new(
            request_object
        )

        self.request_first('post', endpoint, request_entity, nil, custom_client)
      end

      def batch_recalculate(id, request_object = {}, custom_client = nil)
        raise ArgumentError.new("id cannot be nil") if id.nil?

        endpoint = sprintf('recalculate',
                           ERB::Util.url_encode(id)
        )

        request_entity = BillForward::GenericEntity.new(
            request_object
        )

        self.request_first('post', endpoint, request_entity, nil, custom_client)
      end
    end

  protected
    def unserialize_all(hash)
      super
      unserialize_entity('invoice', Invoice, hash)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bill_forward-2.2016.241 lib/bill_forward/entities/subscription_charge.rb
bill_forward-2.2016.227 lib/bill_forward/entities/subscription_charge.rb
bill_forward-2.2016.222 lib/bill_forward/entities/subscription_charge.rb
bill_forward-2.2016.209 lib/bill_forward/entities/subscription_charge.rb
bill_forward-1.2016.117 lib/bill_forward/entities/subscription_charge.rb