Sha256: f8bada9d27705e05eb383823ade7d3f5ba3bd688ecc7b4bbe0b5717613c35fb7

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

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

    attr_accessor :tax_id, :company_name, :phone, :email, :created_at,
                  :parent_id, :default

    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.send(parent)._url + "/fiscal_entities/" + id
    end

    def parent
      self.respond_to?(:order) ? "order" : "customer"
    end

    def delete
      self.delete_member(parent,'fiscal_entities')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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