-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(m360-api): decouple components to external lib
- Loading branch information
Showing
17 changed files
with
188 additions
and
252 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
52 changes: 52 additions & 0 deletions
52
core/src/main/java/com/abavilla/fpi/sms/beanloader/M360ApiLoader.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,52 @@ | ||
/************************************************************************* | ||
* FPI Application - Abavilla * | ||
* Copyright (C) 2023 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.sms.beanloader; | ||
|
||
import com.abavilla.fpi.sms.rest.m360.M360ApiKeys; | ||
import com.vincejv.m360.M360ApiClient; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.inject.Inject; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
/** | ||
* Bean definition for {@link M360ApiClient}. | ||
* | ||
* @author <a href="mailto:vincevillamora@gmail.com">Vince Villamora</a> | ||
*/ | ||
@ApplicationScoped | ||
public class M360ApiLoader { | ||
|
||
@Inject | ||
M360ApiKeys keys; | ||
|
||
@ConfigProperty(name = "ph.com.m360.base-url") | ||
String baseUrl; | ||
|
||
/** | ||
* Creates a {@link M360ApiClient} instance using the default configurations | ||
* | ||
* @return {@link M360ApiClient} instance | ||
*/ | ||
@Produces | ||
M360ApiClient m360ApiClient() { | ||
return new M360ApiClient(baseUrl, keys.getApiKey(), keys.getApiSecret(), keys.getSenderId()); | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
core/src/main/java/com/abavilla/fpi/sms/codec/M360CodecProvider.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,64 @@ | ||
/************************************************************************* | ||
* FPI Application - Abavilla * | ||
* Copyright (C) 2023 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.sms.codec; | ||
|
||
import java.util.List; | ||
|
||
import com.vincejv.m360.dto.BroadcastRequest; | ||
import com.vincejv.m360.dto.IApiRequest; | ||
import com.vincejv.m360.dto.SMSRequest; | ||
import org.bson.codecs.Codec; | ||
import org.bson.codecs.configuration.CodecProvider; | ||
import org.bson.codecs.configuration.CodecRegistry; | ||
import org.bson.codecs.pojo.ClassModel; | ||
import org.bson.codecs.pojo.PojoCodecProvider; | ||
|
||
/** | ||
* MongoDB Codec registry, contains the codec for saving DVS API Objects to mongodb. | ||
* | ||
* @author <a href="mailto:vincevillamora@gmail.com">Vince Villamora</a> | ||
*/ | ||
public class M360CodecProvider implements CodecProvider { | ||
|
||
@SuppressWarnings("rawtypes") | ||
private static final List<Class> discriminatorClasses; | ||
|
||
static { | ||
discriminatorClasses = List.of( | ||
IApiRequest.class, BroadcastRequest.class, SMSRequest.class | ||
); | ||
} | ||
|
||
@Override | ||
public <T> Codec<T> get(Class<T> clazz, CodecRegistry registry) { | ||
if (discriminatorClasses.contains(clazz)) { | ||
return buildDiscriminatorCodec(clazz, registry); | ||
} | ||
return null; // Don't throw here, this tells | ||
} | ||
|
||
private static <T> Codec<T> buildDiscriminatorCodec(Class<T> clazz, CodecRegistry registry) { | ||
ClassModel<T> discriminatorModel = ClassModel.builder(clazz) | ||
.enableDiscriminator(true).build(); | ||
return PojoCodecProvider.builder() | ||
.register(discriminatorModel) | ||
.build().get(clazz, registry); | ||
} | ||
|
||
} |
63 changes: 0 additions & 63 deletions
63
core/src/main/java/com/abavilla/fpi/sms/dto/api/m360/BroadcastRequestDto.java
This file was deleted.
Oops, something went wrong.
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
46 changes: 0 additions & 46 deletions
46
core/src/main/java/com/abavilla/fpi/sms/dto/api/m360/M360ResponseDto.java
This file was deleted.
Oops, something went wrong.
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
48 changes: 0 additions & 48 deletions
48
core/src/main/java/com/abavilla/fpi/sms/mapper/sms/BroadcastRequestMapper.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.