It is not easy to get gratuity in your case because of two reasons.
Eligibility criteria for gratuity
Total service for eligibility is 5 years. Though there are some verdicts from the High Courts (Kerala High Court, Madras High Court) that 240 days in the fifth year shall make an employee entitled to gratuity, there is no decision either from the Apex Court or the legislature who brought in the Social Security Code. Therefore, if you want to establish that 240 days will make an employee eligible for gratuity, you may have to fight for that.
Service under third-party rolls
Secondly, the service in the third-party roll will not be counted as part of your service unless you prove that the same was just a camouflage arrangement but for all purposes including reporting, the principal employer was your employer. In short, if you had received your salary from the contractor (third party) and not from the principal employer, then it will be difficult to establish that your service with the company had started from the date on which you joined under the third-party rolls.