write sms type to db
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.safeqr.app.qrcode.service;
|
||||
|
||||
import com.safeqr.app.exceptions.InvalidFormatExceptions;
|
||||
import com.safeqr.app.exceptions.ResourceNotFoundExceptions;
|
||||
import com.safeqr.app.qrcode.entity.SMSEntity;
|
||||
import com.safeqr.app.qrcode.repository.SMSRepository;
|
||||
@@ -29,4 +30,25 @@ public class SMSVerificationService {
|
||||
smsRepository.save(smsEntity);
|
||||
}
|
||||
|
||||
public void parseSMSString(SMSEntity smsEntity, String smsto) throws IllegalArgumentException{
|
||||
// Remove the "SMSTO:" prefix
|
||||
String data = smsto.substring(6);
|
||||
|
||||
// Split the data into phone number and message
|
||||
String[] parts = data.split(":", 2);
|
||||
|
||||
// If both phone number and message are available
|
||||
if (parts.length == 2) {
|
||||
String phone = parts[0];
|
||||
String message = parts[1];
|
||||
|
||||
// Populate the SMSEntity object
|
||||
smsEntity.setPhone(phone);
|
||||
smsEntity.setMessage(message);
|
||||
} else {
|
||||
// Handle the case where the format is invalid
|
||||
throw new InvalidFormatExceptions("Invalid SMSTO format. Expected format: SMSTO:<phone>:<message>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user