The pain in the ribs could be because of coughing. Hacking cough is known to cause rib fracture
also. You could have developed a contusion
or a rib fracture because of coughing. There is nothing much that can be done for the fracture as it will heal gradually overtime. But you should take care of your cough for which in my opinion you may require inhalers after consulting your doctor.