SubscribeConvert UnsubscribeConvert update
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Struchkov Mark 2023-11-25 12:18:26 +03:00
parent f45281fa9a
commit 02f037c292
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6
4 changed files with 36 additions and 6 deletions

View File

@ -4,8 +4,11 @@ import dev.struchkov.godfather.telegram.domain.event.Subscribe;
import org.telegram.telegrambots.meta.api.objects.ChatMemberUpdated; import org.telegram.telegrambots.meta.api.objects.ChatMemberUpdated;
import org.telegram.telegrambots.meta.api.objects.User; import org.telegram.telegrambots.meta.api.objects.User;
import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
import static dev.struchkov.haiti.utils.Exceptions.utilityClass; import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
public final class SubscribeConvert { public final class SubscribeConvert {
@ -21,9 +24,18 @@ public final class SubscribeConvert {
subscribe.setTelegramId(user.getId().toString()); subscribe.setTelegramId(user.getId().toString());
subscribe.setLastName(user.getLastName()); subscribe.setLastName(user.getLastName());
subscribe.setFirstName(user.getFirstName()); subscribe.setFirstName(user.getFirstName());
subscribe.setSubscriptionDate(LocalDateTime.now()); subscribe.setSubscriptionDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(updated.getDate()), ZoneId.systemDefault()));
subscribe.setLogin(user.getUserName()); subscribe.setLogin(user.getUserName());
subscribe.setLanguageCode(user.getLanguageCode());
subscribe.setPremium(convert(user.getIsPremium()));
return subscribe; return subscribe;
} }
private static boolean convert(Boolean isPremium) {
if (checkNotNull(isPremium)) {
return isPremium;
}
return false;
}
} }

View File

@ -4,8 +4,11 @@ import dev.struchkov.godfather.telegram.domain.event.Unsubscribe;
import org.telegram.telegrambots.meta.api.objects.ChatMemberUpdated; import org.telegram.telegrambots.meta.api.objects.ChatMemberUpdated;
import org.telegram.telegrambots.meta.api.objects.User; import org.telegram.telegrambots.meta.api.objects.User;
import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
import static dev.struchkov.haiti.utils.Exceptions.utilityClass; import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
public final class UnsubscribeConvert { public final class UnsubscribeConvert {
@ -19,10 +22,20 @@ public final class UnsubscribeConvert {
final Unsubscribe unsubscribe = new Unsubscribe(); final Unsubscribe unsubscribe = new Unsubscribe();
unsubscribe.setTelegramId(user.getId().toString()); unsubscribe.setTelegramId(user.getId().toString());
unsubscribe.setLastName(user.getLastName()); unsubscribe.setLogin(user.getUserName());
unsubscribe.setFirstName(user.getFirstName()); unsubscribe.setFirstName(user.getFirstName());
unsubscribe.setUnsubscriptionDate(LocalDateTime.now()); unsubscribe.setUnsubscriptionDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(updated.getDate()), ZoneId.systemDefault()));
unsubscribe.setPremium(convert(user.getIsPremium()));
unsubscribe.setLastName(user.getLastName());
unsubscribe.setLanguageCode(user.getLanguageCode());
return unsubscribe; return unsubscribe;
} }
private static boolean convert(Boolean isPremium) {
if (checkNotNull(isPremium)) {
return isPremium;
}
return false;
}
} }

View File

@ -10,9 +10,11 @@ import java.time.LocalDateTime;
public class Subscribe { public class Subscribe {
private String telegramId; private String telegramId;
private String firstName;
private String lastName;
private String login; private String login;
private LocalDateTime subscriptionDate; private LocalDateTime subscriptionDate;
private String languageCode;
private boolean premium;
private String firstName;
private String lastName;
} }

View File

@ -17,8 +17,11 @@ import java.time.LocalDateTime;
public class Unsubscribe { public class Unsubscribe {
private String telegramId; private String telegramId;
private String login;
private LocalDateTime unsubscriptionDate;
private String languageCode;
private boolean premium;
private String firstName; private String firstName;
private String lastName; private String lastName;
private LocalDateTime unsubscriptionDate;
} }