-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
528 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
fpi-msgr-api-core/src/main/java/com/abavilla/fpi/msgr/codec/EnumCodecProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/****************************************************************************** | ||
* FPI Application - Abavilla * | ||
* Copyright (C) 2022 Vince Jerald Villamora * | ||
* * | ||
* This program is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
package com.abavilla.fpi.msgr.codec; | ||
|
||
import com.abavilla.fpi.fw.config.codec.IEnumCodecProvider; | ||
import com.abavilla.fpi.viber.ext.codec.MessageTypeCodec; | ||
import com.abavilla.fpi.viber.ext.dto.Message; | ||
import org.bson.codecs.Codec; | ||
|
||
/** | ||
* MongoDB Codec registry, contains all the codec for classes that doesn't | ||
* work by default with default POJO codec for MongoDb driver. | ||
* | ||
* @author <a href="mailto:vincevillamora@gmail.com">Vince Villamora</a> | ||
*/ | ||
public class EnumCodecProvider implements IEnumCodecProvider { | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public <T> Codec<T> getCodecProvider(Class<T> tClass) { | ||
if (tClass == Message.Type.class) { | ||
return (Codec<T>) new MessageTypeCodec(); | ||
} | ||
return null; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
fpi-msgr-api-core/src/main/java/com/abavilla/fpi/msgr/config/ViberApiKeyConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/****************************************************************************** | ||
* FPI Application - Abavilla * | ||
* Copyright (C) 2022 Vince Jerald Villamora * | ||
* * | ||
* This program is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
package com.abavilla.fpi.msgr.config; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import lombok.Getter; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
@ApplicationScoped | ||
@Getter | ||
public class ViberApiKeyConfig { | ||
|
||
@ConfigProperty(name = "com.viber.auth-token") | ||
String authToken; | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
fpi-msgr-api-core/src/main/java/com/abavilla/fpi/msgr/controller/MsgReqResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/************************************************************************* | ||
* FPI Application - Abavilla * | ||
* Copyright (C) 2022 Vince Jerald Villamora * | ||
* * | ||
* This program is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>.* | ||
*************************************************************************/ | ||
|
||
package com.abavilla.fpi.msgr.controller; | ||
|
||
import javax.ws.rs.HeaderParam; | ||
import javax.ws.rs.POST; | ||
|
||
import com.abavilla.fpi.fw.controller.AbsBaseResource; | ||
import com.abavilla.fpi.fw.dto.IDto; | ||
import com.abavilla.fpi.fw.dto.impl.RespDto; | ||
import com.abavilla.fpi.fw.entity.AbsItem; | ||
import com.abavilla.fpi.fw.mapper.IMapper; | ||
import com.abavilla.fpi.fw.repo.AbsMongoRepo; | ||
import com.abavilla.fpi.fw.util.DateUtil; | ||
import com.abavilla.fpi.fw.util.FWConst; | ||
import com.abavilla.fpi.msgr.ext.dto.MsgrMsgReqDto; | ||
import com.abavilla.fpi.msgr.service.MsgReqSvc; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
public abstract class MsgReqResource<Q, I extends AbsItem, R extends AbsMongoRepo<I>, M extends IMapper, K, S extends | ||
MsgReqSvc<Q, I, R, M, K>> extends AbsBaseResource<MsgrMsgReqDto, I, S> { | ||
|
||
@POST | ||
public Uni<RespDto<IDto>> sendMsg( | ||
MsgrMsgReqDto msgReq, @HeaderParam("X-FPI-User") String fpiUser) { | ||
return service.postMsg(msgReq, fpiUser).map(svcResp -> { | ||
var resp = new RespDto<>(); | ||
resp.setTimestamp(DateUtil.nowAsStr()); | ||
resp.setStatus(FWConst.SUCCESS); | ||
return resp; | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
fpi-msgr-api-core/src/main/java/com/abavilla/fpi/msgr/controller/ViberReqResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/****************************************************************************** | ||
* FPI Application - Abavilla * | ||
* Copyright (C) 2022 Vince Jerald Villamora * | ||
* * | ||
* This program is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
package com.abavilla.fpi.msgr.controller; | ||
|
||
import javax.ws.rs.Path; | ||
|
||
import com.abavilla.fpi.fw.dto.IDto; | ||
import com.abavilla.fpi.fw.dto.impl.RespDto; | ||
import com.abavilla.fpi.fw.exceptions.FPISvcEx; | ||
import com.abavilla.fpi.msgr.config.ViberApiKeyConfig; | ||
import com.abavilla.fpi.msgr.entity.ViberLog; | ||
import com.abavilla.fpi.msgr.mapper.ViberMsgReqMapper; | ||
import com.abavilla.fpi.msgr.repo.ViberLogRepo; | ||
import com.abavilla.fpi.msgr.service.ViberReqSvc; | ||
import com.abavilla.fpi.viber.ext.dto.SendResponse; | ||
import org.jboss.resteasy.reactive.RestResponse; | ||
import org.jboss.resteasy.reactive.server.ServerExceptionMapper; | ||
|
||
@Path("/fpi/viber") | ||
public class ViberReqResource | ||
extends MsgReqResource<SendResponse, ViberLog, ViberLogRepo, ViberMsgReqMapper, | ||
ViberApiKeyConfig, ViberReqSvc> { | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
@ServerExceptionMapper | ||
protected RestResponse<RespDto<IDto>> mapException(FPISvcEx x) { | ||
return super.mapException(x); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
fpi-msgr-api-core/src/main/java/com/abavilla/fpi/msgr/entity/ViberLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/************************************************************************* | ||
* FPI Application - Abavilla * | ||
* Copyright (C) 2022 Vince Jerald Villamora * | ||
* * | ||
* This program is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>.* | ||
*************************************************************************/ | ||
|
||
package com.abavilla.fpi.msgr.entity; | ||
|
||
import com.abavilla.fpi.fw.entity.mongo.AbsMongoItem; | ||
import com.abavilla.fpi.viber.ext.dto.Location; | ||
import com.abavilla.fpi.viber.ext.dto.Message; | ||
import com.abavilla.fpi.viber.ext.dto.Sender; | ||
import io.quarkus.mongodb.panache.common.MongoEntity; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import org.bson.codecs.pojo.annotations.BsonDiscriminator; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@ToString(callSuper = true) | ||
@NoArgsConstructor | ||
@BsonDiscriminator | ||
@MongoEntity(collection="viber_log") | ||
public class ViberLog extends AbsMongoItem { | ||
|
||
private String text; | ||
private Message.Type type; | ||
private String trackingData; | ||
private String media; | ||
private Location location; | ||
private String receiver; | ||
private Sender sender; | ||
private Integer minApiVersion; | ||
private Integer status; | ||
private String statusMsg; | ||
private String msgToken; | ||
private String chatHostname; | ||
private Integer billingStatus; | ||
private String fpiUser; | ||
private String fpiSystem; | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
fpi-msgr-api-core/src/main/java/com/abavilla/fpi/msgr/mapper/ViberMsgReqMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/************************************************************************* | ||
* FPI Application - Abavilla * | ||
* Copyright (C) 2022 Vince Jerald Villamora * | ||
* * | ||
* This program is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>.* | ||
*************************************************************************/ | ||
|
||
package com.abavilla.fpi.msgr.mapper; | ||
|
||
import com.abavilla.fpi.fw.mapper.IDtoToEntityMapper; | ||
import com.abavilla.fpi.msgr.entity.ViberLog; | ||
import com.abavilla.fpi.msgr.ext.dto.MsgrMsgReqDto; | ||
import com.abavilla.fpi.viber.ext.dto.MessageRequest; | ||
import com.abavilla.fpi.viber.ext.dto.SendResponse; | ||
import org.mapstruct.BeanMapping; | ||
import org.mapstruct.InjectionStrategy; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.MappingConstants; | ||
import org.mapstruct.MappingTarget; | ||
import org.mapstruct.NullValuePropertyMappingStrategy; | ||
|
||
@Mapper(componentModel = MappingConstants.ComponentModel.CDI, | ||
injectionStrategy = InjectionStrategy.CONSTRUCTOR) | ||
public interface ViberMsgReqMapper extends IDtoToEntityMapper<MessageRequest, ViberLog> { | ||
|
||
@Mapping(target = "text", source = "content") | ||
@Mapping(target = "receiver", source = "recipient") | ||
@Mapping(target = "trackingData", source = "replyTo") | ||
@Mapping(target = "minApiVersion", constant = "1") | ||
@Mapping(target = "type", constant = "TEXT") | ||
MessageRequest mapToMsgReq(MsgrMsgReqDto msgReq); | ||
|
||
@BeanMapping( | ||
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE | ||
) | ||
void mapResponseToEntity(@MappingTarget ViberLog entity, SendResponse response); | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
fpi-msgr-api-core/src/main/java/com/abavilla/fpi/msgr/repo/ViberLogRepo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/************************************************************************* | ||
* FPI Application - Abavilla * | ||
* Copyright (C) 2022 Vince Jerald Villamora * | ||
* * | ||
* This program is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>.* | ||
*************************************************************************/ | ||
|
||
package com.abavilla.fpi.msgr.repo; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import com.abavilla.fpi.fw.repo.AbsMongoRepo; | ||
import com.abavilla.fpi.msgr.entity.ViberLog; | ||
|
||
@ApplicationScoped | ||
public class ViberLogRepo extends AbsMongoRepo<ViberLog> { | ||
} |
Oops, something went wrong.