Sha256: 5b654ac287473b57a28b25f14394687f6a9d9be5bf8a919c3dcdaf63802529c6

Contents?: true

Size: 890 Bytes

Versions: 5

Compression:

Stored size: 890 Bytes

Contents

module Conekta
  class DiscountLine < Resource
    include Conekta::Operations::Delete
    include Conekta::Operations::Update
    include Conekta::Operations::CustomAction

    attr_accessor :code, :amount, :type, :parent_id

    def _url
      if (id.nil? || id.to_s.empty?)
        exception = Error.new({
          "message" => I18n.t('error.resource.id',  { resource: self.class.class_name, locale: :en }),
          "message_to_purchaser" => I18n.t('error.resource.id_purchaser',  { locale: Conekta.locale.to_sym })
        })

        if Conekta.api_version == "2.0.0"
          error_list = Conekta::ErrorList.new
          error_list.details << exception
          exception = error_list
        end

        raise exception
      end

      "#{self.order._url}#{self.class._url}/#{id}"
    end

    def delete
      self.delete_member('order', 'discount_lines')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
conekta-2.0.0 lib/conekta/discount_line.rb
conekta-1.1.3 lib/conekta/discount_line.rb
conekta-1.1.2 lib/conekta/discount_line.rb
conekta-1.1.1 lib/conekta/discount_line.rb
conekta-1.1.0 lib/conekta/discount_line.rb