Add CustomFriendlyName parameter to Twilio Verify requests
This commit is contained in:
parent
6c37b658ac
commit
5ee56b022c
|
@ -11,6 +11,7 @@ twilio: # Twilio gateway configuration
|
||||||
android202103VerificationText: # Text to use for the verification message on android-2021-03 client types. Will be passed to String.format with the verification code as argument 1.
|
android202103VerificationText: # Text to use for the verification message on android-2021-03 client types. Will be passed to String.format with the verification code as argument 1.
|
||||||
genericVerificationText: # Text to use when the client type is unrecognized. Will be passed to String.format with the verification code as argument 1.
|
genericVerificationText: # Text to use when the client type is unrecognized. Will be passed to String.format with the verification code as argument 1.
|
||||||
androidAppHash: # Hash appended to Android
|
androidAppHash: # Hash appended to Android
|
||||||
|
verifyServiceFriendlyName: # Service name used in template. Requires Twilio account rep to enable
|
||||||
|
|
||||||
push:
|
push:
|
||||||
queueSize: # Size of push pending queue
|
queueSize: # Size of push pending queue
|
||||||
|
|
|
@ -55,6 +55,9 @@ public class TwilioConfiguration {
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String androidAppHash;
|
private String androidAppHash;
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
private String verifyServiceFriendlyName;
|
||||||
|
|
||||||
public String getAccountId() {
|
public String getAccountId() {
|
||||||
return accountId;
|
return accountId;
|
||||||
}
|
}
|
||||||
|
@ -178,4 +181,12 @@ public class TwilioConfiguration {
|
||||||
public void setAndroidAppHash(String androidAppHash) {
|
public void setAndroidAppHash(String androidAppHash) {
|
||||||
this.androidAppHash = androidAppHash;
|
this.androidAppHash = androidAppHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setVerifyServiceFriendlyName(String serviceFriendlyName) {
|
||||||
|
this.verifyServiceFriendlyName = serviceFriendlyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVerifyServiceFriendlyName() {
|
||||||
|
return verifyServiceFriendlyName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ class TwilioVerifySender {
|
||||||
private final URI verifyServiceUri;
|
private final URI verifyServiceUri;
|
||||||
private final URI verifyApprovalBaseUri;
|
private final URI verifyApprovalBaseUri;
|
||||||
private final String androidAppHash;
|
private final String androidAppHash;
|
||||||
|
private final String verifyServiceFriendlyName;
|
||||||
private final FaultTolerantHttpClient httpClient;
|
private final FaultTolerantHttpClient httpClient;
|
||||||
|
|
||||||
TwilioVerifySender(String baseUri, FaultTolerantHttpClient httpClient, TwilioConfiguration twilioConfiguration) {
|
TwilioVerifySender(String baseUri, FaultTolerantHttpClient httpClient, TwilioConfiguration twilioConfiguration) {
|
||||||
|
@ -85,7 +86,7 @@ class TwilioVerifySender {
|
||||||
.create(baseUri + "/v2/Services/" + twilioConfiguration.getVerifyServiceSid() + "/Verifications/");
|
.create(baseUri + "/v2/Services/" + twilioConfiguration.getVerifyServiceSid() + "/Verifications/");
|
||||||
|
|
||||||
this.androidAppHash = twilioConfiguration.getAndroidAppHash();
|
this.androidAppHash = twilioConfiguration.getAndroidAppHash();
|
||||||
|
this.verifyServiceFriendlyName = twilioConfiguration.getVerifyServiceFriendlyName();
|
||||||
this.httpClient = httpClient;
|
this.httpClient = httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +154,7 @@ class TwilioVerifySender {
|
||||||
requestParameters.put("To", destination);
|
requestParameters.put("To", destination);
|
||||||
requestParameters.put("CustomCode", verificationCode);
|
requestParameters.put("CustomCode", verificationCode);
|
||||||
requestParameters.put("Channel", channel);
|
requestParameters.put("Channel", channel);
|
||||||
|
requestParameters.put("CustomFriendlyName", verifyServiceFriendlyName);
|
||||||
locale.ifPresent(loc -> requestParameters.put("Locale", loc));
|
locale.ifPresent(loc -> requestParameters.put("Locale", loc));
|
||||||
clientType.filter(client -> client.startsWith("android"))
|
clientType.filter(client -> client.startsWith("android"))
|
||||||
.ifPresent(ignored -> requestParameters.put("AppHash", androidAppHash));
|
.ifPresent(ignored -> requestParameters.put("AppHash", androidAppHash));
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class TwilioVerifySenderTest {
|
||||||
private static final String VERIFY_SERVICE_SID = "verify_service_sid";
|
private static final String VERIFY_SERVICE_SID = "verify_service_sid";
|
||||||
private static final String LOCAL_DOMAIN = "test.com";
|
private static final String LOCAL_DOMAIN = "test.com";
|
||||||
private static final String ANDROID_APP_HASH = "someHash";
|
private static final String ANDROID_APP_HASH = "someHash";
|
||||||
|
private static final String SERVICE_FRIENDLY_NAME = "SignalTest";
|
||||||
|
|
||||||
private static final String VERIFICATION_SID = "verification";
|
private static final String VERIFICATION_SID = "verification";
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ public class TwilioVerifySenderTest {
|
||||||
configuration.setVerifyServiceSid(VERIFY_SERVICE_SID);
|
configuration.setVerifyServiceSid(VERIFY_SERVICE_SID);
|
||||||
configuration.setLocalDomain(LOCAL_DOMAIN);
|
configuration.setLocalDomain(LOCAL_DOMAIN);
|
||||||
configuration.setAndroidAppHash(ANDROID_APP_HASH);
|
configuration.setAndroidAppHash(ANDROID_APP_HASH);
|
||||||
|
configuration.setVerifyServiceFriendlyName(SERVICE_FRIENDLY_NAME);
|
||||||
|
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
@ -108,8 +110,8 @@ public class TwilioVerifySenderTest {
|
||||||
.withHeader("Content-Type", equalTo("application/x-www-form-urlencoded"))
|
.withHeader("Content-Type", equalTo("application/x-www-form-urlencoded"))
|
||||||
.withRequestBody(equalTo(
|
.withRequestBody(equalTo(
|
||||||
(expectedLocale == null ? "" : "Locale=" + expectedLocale + "&")
|
(expectedLocale == null ? "" : "Locale=" + expectedLocale + "&")
|
||||||
+ "Channel=sms&To=%2B14153333333&CustomCode=123456"
|
+ "Channel=sms&To=%2B14153333333&CustomFriendlyName=" + SERVICE_FRIENDLY_NAME
|
||||||
+ (expectAppHash ? "&AppHash=" + ANDROID_APP_HASH : "")
|
+ "&CustomCode=123456" + (expectAppHash ? "&AppHash=" + ANDROID_APP_HASH : "")
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +144,8 @@ public class TwilioVerifySenderTest {
|
||||||
.withHeader("Content-Type", equalTo("application/x-www-form-urlencoded"))
|
.withHeader("Content-Type", equalTo("application/x-www-form-urlencoded"))
|
||||||
.withRequestBody(equalTo(
|
.withRequestBody(equalTo(
|
||||||
(expectedLocale == null ? "" : "Locale=" + expectedLocale + "&")
|
(expectedLocale == null ? "" : "Locale=" + expectedLocale + "&")
|
||||||
+ "Channel=call&To=%2B14153333333&CustomCode=123456")));
|
+ "Channel=call&To=%2B14153333333&CustomFriendlyName=" + SERVICE_FRIENDLY_NAME
|
||||||
|
+ "&CustomCode=123456")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object argumentsForDeliverVoxVerificationWithVerify() {
|
private static Object argumentsForDeliverVoxVerificationWithVerify() {
|
||||||
|
@ -171,7 +174,8 @@ public class TwilioVerifySenderTest {
|
||||||
|
|
||||||
verify(3, postRequestedFor(urlEqualTo("/v2/Services/" + VERIFY_SERVICE_SID + "/Verifications"))
|
verify(3, postRequestedFor(urlEqualTo("/v2/Services/" + VERIFY_SERVICE_SID + "/Verifications"))
|
||||||
.withHeader("Content-Type", equalTo("application/x-www-form-urlencoded"))
|
.withHeader("Content-Type", equalTo("application/x-www-form-urlencoded"))
|
||||||
.withRequestBody(equalTo("Channel=sms&To=%2B14153333333&CustomCode=123456")));
|
.withRequestBody(equalTo("Channel=sms&To=%2B14153333333&CustomFriendlyName=" + SERVICE_FRIENDLY_NAME
|
||||||
|
+ "&CustomCode=123456")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -190,7 +194,8 @@ public class TwilioVerifySenderTest {
|
||||||
|
|
||||||
verify(3, postRequestedFor(urlEqualTo("/v2/Services/" + VERIFY_SERVICE_SID + "/Verifications"))
|
verify(3, postRequestedFor(urlEqualTo("/v2/Services/" + VERIFY_SERVICE_SID + "/Verifications"))
|
||||||
.withHeader("Content-Type", equalTo("application/x-www-form-urlencoded"))
|
.withHeader("Content-Type", equalTo("application/x-www-form-urlencoded"))
|
||||||
.withRequestBody(equalTo("Channel=call&To=%2B14153333333&CustomCode=123456")));
|
.withRequestBody(equalTo("Channel=call&To=%2B14153333333&CustomFriendlyName=" + SERVICE_FRIENDLY_NAME
|
||||||
|
+ "&CustomCode=123456")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue