You have to differentiate when you put the IOP before o after the verb.
Only you can put the redundant IOP before the verb when you want to enmphasize.
Example: A mi amigo LE voy a regalar una pelota - You put IOP between the IO and the verb
It's optional with the verbs that express goals, receivers o destinations like dar, regalar, vender, enseñar, mostrar,decir, comunicar... Those express a transmission process with an object to a receiver.
Example: Le vendí la casa a un amigo - Vendí la casa a un amigo
It's optional, but in oral expression it's better with the IOP
The IOP is required when you use a DOP.
Example: Vendí la casa a un amigo
You cannot say: La vendí a un amigo
You have to say: SE la vendí a un amigo
The IOP is required whit verbs that express benefits, detriments or possession like gustar, dar, encantar, corregir, romper, sacar...
Example: LE doy el dinero a Tomás
I think that it's all, more or less.
Sorry about my english, I just learning.
I hope it is useful