How can I cast buffs with secure buttons (or macros) like the action bar does; casts the highest rank of the buff that the target can successfully receive

I write an addon called MagnetButtons, it uses secure button templates. The whole spell rank thing has caused several issues for me; but one in particular…

With buffs, the actionbar applies the highest rank a target can receive. So if I have “Mark of the Wild(Rank 3)”, but target can only receive Rank 2; the actionbar will cast the appropriate spell (Rank 2). Ideally it would be nice if there were “special spell id’s”, that carried out the same behavior as the actionbar. But I’m looking for any solution possible. Besides solutions, tips and ideas about how to deal with this are very welcome.

Thanks

Each spell rank has a unique spell id.

That is not helpful, I knew that.