2020-11-11 21:15:58 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Integración con la tienda
|
|
|
|
module Tienda
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2024-02-23 15:53:56 +00:00
|
|
|
has_encrypted :tienda_api_key
|
2020-11-11 21:15:58 +00:00
|
|
|
|
|
|
|
def tienda?
|
|
|
|
tienda_api_key.present? && tienda_url.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
# Sugerir una dirección al configurar por primera vez
|
|
|
|
def tienda_url
|
|
|
|
t = read_attribute(:tienda_url)
|
|
|
|
|
|
|
|
return t if new_record?
|
|
|
|
|
2024-05-02 19:05:35 +00:00
|
|
|
t.blank? ? "https://#{name}.#{ENV.fetch('TIENDA', 'tienda.sutty.nl')}" : t
|
2020-11-11 21:15:58 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|