beta build
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
class BrokersController < ApplicationController
|
||||
before_action :set_broker, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /brokers or /brokers.json
|
||||
def index
|
||||
@brokers = Broker.all
|
||||
end
|
||||
|
||||
# GET /brokers/1 or /brokers/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /brokers/new
|
||||
def new
|
||||
@broker = Broker.new
|
||||
end
|
||||
|
||||
# GET /brokers/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /brokers or /brokers.json
|
||||
def create
|
||||
@broker = Broker.new(broker_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @broker.save
|
||||
format.html { redirect_to @broker, notice: "Broker was successfully created." }
|
||||
format.json { render :show, status: :created, location: @broker }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @broker.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /brokers/1 or /brokers/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @broker.update(broker_params)
|
||||
format.html { redirect_to @broker, notice: "Broker was successfully updated.", status: :see_other }
|
||||
format.json { render :show, status: :ok, location: @broker }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @broker.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /brokers/1 or /brokers/1.json
|
||||
def destroy
|
||||
@broker.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to brokers_path, notice: "Broker was successfully destroyed.", status: :see_other }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_broker
|
||||
@broker = Broker.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def broker_params
|
||||
params.require(:broker).permit(:name, :carrier_id)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,70 @@
|
||||
class CarriersController < ApplicationController
|
||||
before_action :set_carrier, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /carriers or /carriers.json
|
||||
def index
|
||||
@carriers = Carrier.all
|
||||
end
|
||||
|
||||
# GET /carriers/1 or /carriers/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /carriers/new
|
||||
def new
|
||||
@carrier = Carrier.new
|
||||
end
|
||||
|
||||
# GET /carriers/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /carriers or /carriers.json
|
||||
def create
|
||||
@carrier = Carrier.new(carrier_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @carrier.save
|
||||
format.html { redirect_to @carrier, notice: "Carrier was successfully created." }
|
||||
format.json { render :show, status: :created, location: @carrier }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @carrier.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /carriers/1 or /carriers/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @carrier.update(carrier_params)
|
||||
format.html { redirect_to @carrier, notice: "Carrier was successfully updated.", status: :see_other }
|
||||
format.json { render :show, status: :ok, location: @carrier }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @carrier.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /carriers/1 or /carriers/1.json
|
||||
def destroy
|
||||
@carrier.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to carriers_path, notice: "Carrier was successfully destroyed.", status: :see_other }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_carrier
|
||||
@carrier = Carrier.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def carrier_params
|
||||
params.require(:carrier).permit(:name)
|
||||
end
|
||||
end
|
||||
@@ -3,9 +3,9 @@ class EmployersController < ApplicationController
|
||||
# View Methods
|
||||
def index
|
||||
@uninitialized = Employer.in_automation_initilization
|
||||
@with_active_id_card_setup = Employer.with_active_id_card_setup
|
||||
@with_active_id_card_setup = Employer.active
|
||||
current_group_numbers = @with_active_id_card_setup.pluck(:group_number)
|
||||
valid_group_numbers = ["62210","61986","42018","41283","0230643","43190","0230642","0230644","0230646","0233955","600102","0249127","0257902","0257947","600112","0260085","600114","0261611","600117","0261684","0261685","0261826","600121","0265450","600123","0267470","0268540","0268599"]
|
||||
valid_group_numbers = ["62210","61986","42018","41283","0230643","43190","0230642","0230644","0230646","0233955","600102","0249127","0257902","0257947","600112","600114","0261611","600117","0261684","0261685","0261826","600121","0265450","600123","0267470","0268540","0268599"]
|
||||
@beta_unassigned_group_numbers = valid_group_numbers - current_group_numbers
|
||||
@deactivated = Employer.deactivated
|
||||
end
|
||||
|
||||
@@ -5,6 +5,7 @@ module IdCard
|
||||
def index
|
||||
@employer_setups = IdCard::Setup.active.to_a
|
||||
@queue_members = IdCardQueueService::GetQueuedMembers.new().call
|
||||
update_missing_members(@queue_members)
|
||||
add_queued_count_to_employer_setup(@queue_members)
|
||||
@queued = @employer_setups.select { |setup| setup.queued_card_count > 0 }.sort_by { |setup| setup.print_name }
|
||||
@not_queued = @employer_setups.select { |setup| setup.queued_card_count == 0 }.sort_by { |setup| setup.print_name }
|
||||
@@ -15,6 +16,9 @@ module IdCard
|
||||
|
||||
def print_all_queued
|
||||
@queue_members = IdCardQueueService::GetQueuedMembers.new().call
|
||||
# @queue_members.delete_if { |em| ["2", "19", "16", "54"].include?(em[:pl_plan_key])}
|
||||
# @queue_members.push({pl_plan_key: "54", member_keys: [383840]})
|
||||
|
||||
cards_pdf = IdCardPrinterService::CardsGenerator.new(@queue_members, "PrintCard").call
|
||||
|
||||
send_data cards_pdf.to_pdf,
|
||||
@@ -28,6 +32,7 @@ module IdCard
|
||||
pl_plan_key = params[:id].to_s
|
||||
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
|
||||
@queue_members = IdCardQueueService::GetQueuedMembers.new(pl_plan_key).call
|
||||
# @queue_members.first[:member_keys].delete(379590) && @queue_members.first[:member_keys].push(379610)
|
||||
cards_pdf = IdCardPrinterService::CardsGenerator.new(@queue_members, "PrintCard").call
|
||||
|
||||
send_data cards_pdf.to_pdf,
|
||||
@@ -103,6 +108,16 @@ module IdCard
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_missing_members(queued_employer_members)
|
||||
queued_employer_members.each do |queued_employer|
|
||||
existing_members = Member.where(pb_entity_key: queued_employer[:member_keys]).pluck(:pb_entity_key)
|
||||
missing_members = queued_employer[:member_keys] - existing_members
|
||||
missing_members.each do |pb_entity_key|
|
||||
AutomationService::MemberUpdate.new(queued_employer[:pl_plan_key], pb_entity_key).call
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def add_queued_count_to_employer_setup(queued_employer_members)
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
class ProviderGroupsController < ApplicationController
|
||||
before_action :set_provider_group, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /provider_groups or /provider_groups.json
|
||||
def index
|
||||
@provider_groups = ProviderGroup.all
|
||||
end
|
||||
|
||||
# GET /provider_groups/1 or /provider_groups/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /provider_groups/new
|
||||
def new
|
||||
@provider_group = ProviderGroup.new
|
||||
end
|
||||
|
||||
# GET /provider_groups/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /provider_groups or /provider_groups.json
|
||||
def create
|
||||
@provider_group = ProviderGroup.new(provider_group_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @provider_group.save
|
||||
format.html { redirect_to @provider_group, notice: "Provider group was successfully created." }
|
||||
format.json { render :show, status: :created, location: @provider_group }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @provider_group.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /provider_groups/1 or /provider_groups/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @provider_group.update(provider_group_params)
|
||||
format.html { redirect_to @provider_group, notice: "Provider group was successfully updated.", status: :see_other }
|
||||
format.json { render :show, status: :ok, location: @provider_group }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @provider_group.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /provider_groups/1 or /provider_groups/1.json
|
||||
def destroy
|
||||
@provider_group.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to provider_groups_path, notice: "Provider group was successfully destroyed.", status: :see_other }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_provider_group
|
||||
@provider_group = ProviderGroup.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def provider_group_params
|
||||
params.require(:provider_group).permit(:name)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,70 @@
|
||||
class ProvidersController < ApplicationController
|
||||
before_action :set_provider, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /providers or /providers.json
|
||||
def index
|
||||
@providers = Provider.all
|
||||
end
|
||||
|
||||
# GET /providers/1 or /providers/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /providers/new
|
||||
def new
|
||||
@provider = Provider.new
|
||||
end
|
||||
|
||||
# GET /providers/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /providers or /providers.json
|
||||
def create
|
||||
@provider = Provider.new(provider_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @provider.save
|
||||
format.html { redirect_to @provider, notice: "Provider was successfully created." }
|
||||
format.json { render :show, status: :created, location: @provider }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @provider.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /providers/1 or /providers/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @provider.update(provider_params)
|
||||
format.html { redirect_to @provider, notice: "Provider was successfully updated.", status: :see_other }
|
||||
format.json { render :show, status: :ok, location: @provider }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @provider.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /providers/1 or /providers/1.json
|
||||
def destroy
|
||||
@provider.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to providers_path, notice: "Provider was successfully destroyed.", status: :see_other }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_provider
|
||||
@provider = Provider.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def provider_params
|
||||
params.fetch(:provider, {})
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
module BrokersHelper
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
module CarriersHelper
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
module ProviderGroupsHelper
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
module ProvidersHelper
|
||||
end
|
||||
@@ -2,14 +2,15 @@
|
||||
import "@hotwired/turbo-rails"
|
||||
import "trix"
|
||||
import "@rails/actiontext"
|
||||
import { Application } from "@hotwired/stimulus"
|
||||
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
||||
import { createIcons, icons } from "lucide-static";
|
||||
// import { Application } from "@hotwired/stimulus"
|
||||
// import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
||||
import "controllers"
|
||||
// import { createIcons, icons } from "lucide-static";
|
||||
|
||||
document.addEventListener("turbo:load", () => {
|
||||
createIcons({ icons });
|
||||
});
|
||||
// document.addEventListener("turbo:load", () => {
|
||||
// createIcons({ icons });
|
||||
// });
|
||||
|
||||
const application = Application.start()
|
||||
eagerLoadControllersFrom("controllers", application)
|
||||
// const application = Application.start()
|
||||
// eagerLoadControllersFrom("controllers", application)
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
// Import and register all your controllers from the importmap under controllers/*
|
||||
|
||||
// This file is auto-generated by ./bin/rails stimulus:manifest:update
|
||||
// Run that command whenever you add a new controller or create them with
|
||||
// ./bin/rails generate stimulus controllerName
|
||||
import { application } from "controllers/application"
|
||||
|
||||
// Eager load all controllers defined in the import map under controllers/**/*_controller
|
||||
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
||||
eagerLoadControllersFrom("controllers", application)
|
||||
|
||||
// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
|
||||
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
|
||||
// lazyLoadControllersFrom("controllers", application)
|
||||
|
||||
@@ -56,14 +56,12 @@ class ProcessMemberCardDataJob < ApplicationJob
|
||||
end
|
||||
|
||||
if has_dental
|
||||
if member.dental_plan_key
|
||||
member_attributes.merge!({dental_coverage: member.coverage_class.upcase})
|
||||
unless member.id_card_plan_id
|
||||
member_attributes.merge!({group_number: "", medical_eff_date: ""})
|
||||
# dental_plan = IdCard::Plan.find_by(pb_product_key: 1025)
|
||||
if IdCard::Plan.find_by(pb_product_key: member.dental_plan_key).blank?
|
||||
member_attributes.merge!({employer_name: 'COBRA'})
|
||||
end
|
||||
member_attributes.merge!({dental_coverage: member.coverage_class.upcase})
|
||||
if member.dental_plan_key && member.id_card_plan_id.blank?
|
||||
member_attributes.merge!({group_number: "", medical_eff_date: ""})
|
||||
# dental_plan = IdCard::Plan.find_by(pb_product_key: 1025)
|
||||
if IdCard::Plan.find_by(pb_product_key: member.dental_plan_key).blank?
|
||||
member_attributes.merge!({employer_name: 'COBRA'})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class UpdateMemberJob < ApplicationJob
|
||||
"PBCoveredEntities"."PBEntityKey" = ?
|
||||
AND "PBProductParticipation"."InEffect" <= ?
|
||||
AND "PBProductParticipation"."OutOfEffect" > ?',
|
||||
vw_mb_member[:pb_entity_key], 2.month.from_now , 1.day.ago
|
||||
vw_mb_member[:pb_entity_key], 3.month.from_now , 1.day.ago
|
||||
)
|
||||
|
||||
if pb_products.present? && vw_mb_member[:social_security_number].present?
|
||||
@@ -53,14 +53,18 @@ class UpdateMemberJob < ApplicationJob
|
||||
INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"
|
||||
INNER JOIN "PBProductAvailability" ON "PBProductAvailability"."PBProductAvailabilityKey" = "PBProductParticipation"."PBProductAvailabilityKey"
|
||||
INNER JOIN "PBProduct" ON "PBProduct"."PBProductKey" = "PBProductAvailability"."PBProductKey"
|
||||
').find_by('
|
||||
').select('
|
||||
"GEN_LookupTables".*, "PBProductParticipation"."InEffect" AS EffDate
|
||||
').where('
|
||||
"PBCoveredEntities"."PBEntityKey" = ?
|
||||
AND "PBProductParticipation"."InEffect" <= ?
|
||||
AND "PBProductParticipation"."OutOfEffect" > ?
|
||||
AND "PBProduct"."PBProductKey" = ?',
|
||||
member.pb_entity_key, 1.month.from_now, 1.day.ago, dental_pb_product_key
|
||||
).short_desc
|
||||
).order('EffDate DESC').first.short_desc
|
||||
member.coverage_class = coverage_class
|
||||
else
|
||||
member.coverage_class = "NONE"
|
||||
end
|
||||
else
|
||||
medical_pb_product_key = pb_products.first.pb_product_key
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class Broker < ApplicationRecord
|
||||
belongs_to :carrier
|
||||
has_many :employers
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
class Carrier < ApplicationRecord
|
||||
has_many :brokers
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
class Employer < ApplicationRecord
|
||||
include EmployerAutomation
|
||||
belongs_to :broker, optional: true
|
||||
has_many :members, dependent: :destroy
|
||||
accepts_nested_attributes_for :members, allow_destroy: true, reject_if: :all_blank
|
||||
has_one :id_card_setup, class_name: 'IdCard::Setup', dependent: :destroy
|
||||
@@ -46,6 +47,13 @@ class Employer < ApplicationRecord
|
||||
}
|
||||
end
|
||||
|
||||
def employer_member_keys_by_plan(pb_product_key)
|
||||
{
|
||||
pl_plan_key: self.pl_plan_key,
|
||||
member_keys: self.plans.find_by(pb_product_key: pb_product_key).members.pluck(:pb_entity_key)
|
||||
}
|
||||
end
|
||||
|
||||
def name_to_logo_filename(extension)
|
||||
Employer.employer_trim_name(self.name).titleize.gsub(/[^a-zA-Z]/, '').concat('Logo').concat(extension.downcase)
|
||||
end
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
module HebWeb
|
||||
class BrokerXRef < HebWebRecord
|
||||
|
||||
self.table_name = 'BrokerXRef'
|
||||
|
||||
alias_attribute :id, :Id
|
||||
alias_attribute :pl_plan_key, :PLPlanKey
|
||||
alias_attribute :pb_entity_key, :PBEntityKey
|
||||
alias_attribute :plan_name, :PlanName
|
||||
alias_attribute :employer_pl_plan_key, :EmployerPLPlanKey
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
class HebWebRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
connects_to database: { writing: :heb_web, reading: :heb_web }
|
||||
end
|
||||
@@ -3,6 +3,7 @@ module IdCard
|
||||
belongs_to :setup, optional: true
|
||||
has_many :plan_benefits, dependent: :destroy
|
||||
accepts_nested_attributes_for :plan_benefits, allow_destroy: true, reject_if: :all_blank
|
||||
has_many :members, class_name: 'Member', foreign_key: :id_card_plan_id
|
||||
|
||||
validates :title, presence: true
|
||||
validates :pb_product_key, :pl_plan_key, presence: true, if: -> { setup&.active }
|
||||
|
||||
@@ -9,8 +9,9 @@ class Member < ApplicationRecord
|
||||
validates :name, :family_id, :mb_member_key, :pl_plan_key,
|
||||
:id_card_display_name, presence: true, unless: :new_record?
|
||||
validates :division, presence: true, if: -> { employer.id_card_setup.has_divisions }
|
||||
validates :coverage_class, :dental_plan_key, presence: true, if: -> { employer.id_card_setup.has_dental }
|
||||
validates :name, :mb_member_key, :pb_entity_key, uniqueness: true
|
||||
# validates :coverage_class, :dental_plan_key, presence: true, if: -> { employer.id_card_setup.has_dental }
|
||||
validates :mb_member_key, :pb_entity_key, uniqueness: true
|
||||
validates :name, uniqueness: { scope: :employer_id }
|
||||
|
||||
before_validation :format_dependents, if: :dependents_changed?
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
class Provider < ApplicationRecord
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
class ProviderGroup < ApplicationRecord
|
||||
end
|
||||
@@ -13,7 +13,7 @@ module AutomationService
|
||||
if member.present?
|
||||
member.save
|
||||
else
|
||||
Member.find_by(pb_entity_key: vw_mb_member[:pb_entity_key]).destroy
|
||||
Member.find_by(pb_entity_key: @pb_entity_key).destroy
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
require 'rake'
|
||||
|
||||
class BetaAutomationSimulationService
|
||||
def initialize()
|
||||
end
|
||||
|
||||
def call
|
||||
Rails::Command.invoke('employer_automation:employer_initialize_test')
|
||||
# Rails::Command.invoke('employer_automation:employer_initialize_test')
|
||||
|
||||
Rails.application.load_tasks
|
||||
Rake::Task['employer_automation:employer_initialize_test'].invoke
|
||||
end
|
||||
end
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
class ImageProcessorService
|
||||
ALLOWED_LOGO_TYPES = ['Network', 'Employer'].freeze
|
||||
|
||||
def initialize(image_path, logo_type, new_filename = nil)
|
||||
@image_path = image_path
|
||||
@logo_type = logo_type.capitalize
|
||||
@new_filename = new_filename
|
||||
|
||||
unless ALLOWED_LOGO_TYPES.include?(@logo_type)
|
||||
raise ArgumentError, "Invalid logo type: #{@logo_type}. Must be one of: #{ALLOWED_LOGO_TYPES.join(', ')}"
|
||||
end
|
||||
end
|
||||
|
||||
def call
|
||||
|
||||
if @new_filename
|
||||
filename = @new_filename
|
||||
else
|
||||
filename = File.basename(@image_path)
|
||||
end
|
||||
|
||||
binary_data = File.binread(@image_path)
|
||||
# binary_data = File.open(@image_path, 'rb').read
|
||||
meme_type = Marcel::MimeType.for Pathname.new(@image_path)
|
||||
|
||||
logo_model = "IdCard::#{@logo_type}Logo".constantize
|
||||
|
||||
logo_model.find_or_create_by(filename: filename) do |logo|
|
||||
logo.image_data = binary_data
|
||||
logo.content_type = meme_type
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user