module AutomationService
    class MemberUpdate

        def initialize(pl_plan_key, pb_entity_key)
            @pl_plan_key = pl_plan_key
            @pb_entity_key = pb_entity_key
        end

        def call
            employer = Employer.includes(:id_card_setup).find_by(pl_plan_key: @pl_plan_key)
            card_setup = employer.id_card_setup
            member = UpdateMemberJob.perform_now(@pb_entity_key, employer.id, card_setup.has_divisions, card_setup.has_dental)
            if member.present?
                member.save
            else
                Member.find_by(pb_entity_key: vw_mb_member[:pb_entity_key]).destroy
            end
        end
        
    end
end

# AutomationService::MemberUpdate('13', 337710)