diff --git a/tutorials/compile.sh b/tutorials/compile.sh
index cdeab37..1381413 100755
--- a/tutorials/compile.sh
+++ b/tutorials/compile.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-(cd sms/auto-subscribe-app && mvn clean package)
+(cd sms/user-consent-app && mvn clean package)
(cd voice/capture-leads-app && mvn clean package)
diff --git a/tutorials/sms/auto-subscribe-app/README.md b/tutorials/sms/user-consent-app/README.md
similarity index 89%
rename from tutorials/sms/auto-subscribe-app/README.md
rename to tutorials/sms/user-consent-app/README.md
index ca64e90..42cb647 100644
--- a/tutorials/sms/auto-subscribe-app/README.md
+++ b/tutorials/sms/user-consent-app/README.md
@@ -1,6 +1,6 @@
-# auto-subscribe application sample
+# user-consent application sample
-This directory contains sample related to Java SDK tutorials: [auto-subscribe](https://developers.sinch.com/docs/sms/tutorials/sms/tutorials/java-sdk/auto-subscribe)
+This directory contains sample related to Java SDK tutorials: [user-consent](https://developers.sinch.com/docs/sms/tutorials/sms/tutorials/java-sdk/user-consent)
## Requirements
diff --git a/tutorials/sms/auto-subscribe-app/pom.xml b/tutorials/sms/user-consent-app/pom.xml
similarity index 87%
rename from tutorials/sms/auto-subscribe-app/pom.xml
rename to tutorials/sms/user-consent-app/pom.xml
index ec93517..5833620 100644
--- a/tutorials/sms/auto-subscribe-app/pom.xml
+++ b/tutorials/sms/user-consent-app/pom.xml
@@ -11,10 +11,10 @@
my.company.com
- sinch-sdk-java-tuturial-auto-subscribe
+ sinch-sdk-java-tuturial-user-consent
0.0.1-SNAPSHOT
- Sinch Java SDK auto-subscribe Sample Application
- Demo Project for auto-subscribe
+ Sinch Java SDK user consent Sample Application
+ Demo Project for user consent
[1.0.0,)
diff --git a/tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/App.java b/tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/App.java
similarity index 100%
rename from tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/App.java
rename to tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/App.java
diff --git a/tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/Config.java b/tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/Config.java
similarity index 66%
rename from tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/Config.java
rename to tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/Config.java
index 49cce89..c5b780d 100644
--- a/tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/Config.java
+++ b/tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/Config.java
@@ -19,17 +19,18 @@ public class Config {
@Value("${credentials.key-secret}")
String keySecret;
+ @Value("${sms.region}")
+ String smsRegion;
+
@Bean
public SMSService smsService() {
- var configuration =
- Configuration.builder()
- .setProjectId(projectId)
- .setKeyId(keyId)
- .setKeySecret(keySecret)
- .setSmsRegion(SMSRegion.US)
- .build();
+ var builder =
+ Configuration.builder().setProjectId(projectId).setKeyId(keyId).setKeySecret(keySecret);
- return new SinchClient(configuration).sms();
+ if (!smsRegion.isEmpty()) {
+ builder.setSmsRegion(SMSRegion.from(smsRegion));
+ }
+ return new SinchClient(builder.build()).sms();
}
}
diff --git a/tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/GroupManager.java b/tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/GroupManager.java
similarity index 100%
rename from tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/GroupManager.java
rename to tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/GroupManager.java
diff --git a/tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/AutoSubscribeController.java b/tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/UserConsentController.java
similarity index 79%
rename from tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/AutoSubscribeController.java
rename to tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/UserConsentController.java
index 9a6c0b3..1311c1c 100644
--- a/tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/AutoSubscribeController.java
+++ b/tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/UserConsentController.java
@@ -10,13 +10,13 @@
import org.springframework.web.bind.annotation.RestController;
@RestController
-public class AutoSubscribeController {
+public class UserConsentController {
private final SMSService smsService;
- private final AutoSubscribeService service;
+ private final UserConsentService service;
@Autowired
- public AutoSubscribeController(SMSService smsService, AutoSubscribeService service) {
+ public UserConsentController(SMSService smsService, UserConsentService service) {
this.smsService = smsService;
this.service = service;
}
@@ -30,8 +30,6 @@ public void smsDeliveryEvent(@RequestBody String body) {
// let business layer process the request
if (Objects.requireNonNull(event) instanceof InboundText e) {
service.processInboundEvent(e);
- } else {
- throw new IllegalStateException("Unexpected value: " + event);
}
}
}
diff --git a/tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/AutoSubscribeService.java b/tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/UserConsentService.java
similarity index 86%
rename from tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/AutoSubscribeService.java
rename to tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/UserConsentService.java
index d6d1024..1d310d8 100644
--- a/tutorials/sms/auto-subscribe-app/src/main/java/com/mycompany/app/AutoSubscribeService.java
+++ b/tutorials/sms/user-consent-app/src/main/java/com/mycompany/app/UserConsentService.java
@@ -12,9 +12,9 @@
import org.springframework.stereotype.Service;
@Service
-public class AutoSubscribeService {
+public class UserConsentService {
- private static final Logger LOGGER = Logger.getLogger(AutoSubscribeService.class.getName());
+ private static final Logger LOGGER = Logger.getLogger(UserConsentService.class.getName());
static final String SUBSCRIBE_ACTION = "SUBSCRIBE";
static final String STOP_ACTION = "STOP";
@@ -23,7 +23,7 @@ public class AutoSubscribeService {
private final Group group;
@Autowired
- public AutoSubscribeService(SMSService smsService, GroupManager groupManager) {
+ public UserConsentService(SMSService smsService, GroupManager groupManager) {
this.smsService = smsService;
this.group = groupManager.getGroup();
}
@@ -39,7 +39,7 @@ public void processInboundEvent(InboundText event) {
var membersList = getMembersList(group);
var isMemberInGroup = isMemberInGroup(membersList, from);
- String response = processAction(from, to, action, membersList, isMemberInGroup);
+ String response = processAction(from, to, action, isMemberInGroup);
sendResponse(to, from, response);
}
@@ -52,12 +52,7 @@ private boolean isMemberInGroup(Collection membersList, String member) {
return membersList.contains(member);
}
- private String processAction(
- String from,
- String to,
- String action,
- Collection membersList,
- boolean isMemberInGroup) {
+ private String processAction(String from, String to, String action, boolean isMemberInGroup) {
if (SUBSCRIBE_ACTION.equals(action)) {
return subscribe(group, isMemberInGroup, to, from);
@@ -65,7 +60,7 @@ private String processAction(
return unsubscribe(group, isMemberInGroup, to, from);
}
- return unknwownAction(isMemberInGroup, to);
+ return unknownAction(isMemberInGroup, to);
}
private String subscribe(
@@ -100,7 +95,7 @@ private String unsubscribe(
.formatted(group.getName(), SUBSCRIBE_ACTION, groupPhoneNumber);
}
- private String unknwownAction(boolean isMemberInGroup, String to) {
+ private String unknownAction(boolean isMemberInGroup, String to) {
String message =
isMemberInGroup
diff --git a/tutorials/sms/auto-subscribe-app/src/main/resources/application.yaml b/tutorials/sms/user-consent-app/src/main/resources/application.yaml
similarity index 61%
rename from tutorials/sms/auto-subscribe-app/src/main/resources/application.yaml
rename to tutorials/sms/user-consent-app/src/main/resources/application.yaml
index 9d962b3..c80e209 100644
--- a/tutorials/sms/auto-subscribe-app/src/main/resources/application.yaml
+++ b/tutorials/sms/user-consent-app/src/main/resources/application.yaml
@@ -10,5 +10,8 @@ server:
credentials:
project-id:
key-id:
- key-secret:
+ key-secret:
+# Set a value if not using the default "us" region
+sms:
+ region: