From a85091b5f2c0c67a9740b65ab3d484bc431c25ae Mon Sep 17 00:00:00 2001 From: kapilp93 <88089849+kapilp93@users.noreply.github.com> Date: Fri, 3 Nov 2023 14:51:11 +0530 Subject: [PATCH] PHONUM-3179 (#263) * tollfree verification api integration * added tf fields in list numbers response * updated optin field names * added release notes --- CHANGELOG.md | 5 + README.md | 6 +- pom.properties | 2 +- pom.xml | 2 +- .../java/com/plivo/api/PlivoAPIService.java | 25 +++ .../com/plivo/api/models/number/Number.java | 10 + .../plivo/api/models/number/NumberLister.java | 11 +- .../TollfreeVerification.java | 140 ++++++++++++++ .../TollfreeVerificationCreateResponse.java | 15 ++ .../TollfreeVerificationCreator.java | 175 ++++++++++++++++++ .../TollfreeVerificationDeleter.java | 19 ++ .../TollfreeVerificationGetter.java | 16 ++ .../TollfreeVerificationLister.java | 67 +++++++ .../TollfreeVerificationUpdateResponse.java | 7 + .../TollfreeVerificationUpdater.java | 146 +++++++++++++++ src/main/resources/com/plivo/api/version.txt | 2 +- .../plivo/api/TollfreeVerificationTest.java | 134 ++++++++++++++ .../tollfreeVerificationCreateResponse.json | 5 + .../api/tollfreeVerificationGetResponse.json | 20 ++ .../api/tollfreeVerificationListResponse.json | 50 +++++ .../tollfreeVerificationUpdateResponse.json | 4 + 21 files changed, 854 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerification.java create mode 100644 src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationCreateResponse.java create mode 100644 src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationCreator.java create mode 100644 src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationDeleter.java create mode 100644 src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationGetter.java create mode 100644 src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationLister.java create mode 100644 src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationUpdateResponse.java create mode 100644 src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationUpdater.java create mode 100644 src/test/java/com/plivo/api/TollfreeVerificationTest.java create mode 100644 src/test/resources/com/plivo/api/tollfreeVerificationCreateResponse.json create mode 100644 src/test/resources/com/plivo/api/tollfreeVerificationGetResponse.json create mode 100644 src/test/resources/com/plivo/api/tollfreeVerificationListResponse.json create mode 100644 src/test/resources/com/plivo/api/tollfreeVerificationUpdateResponse.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 69cf9ab5..896bdef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Change Log +## [5.34.0](https://github.com/plivo/plivo-java/tree/v5.34.0) (2023-11-03) +**Feature - TollFree Verification API Support** +- API support for Create, Update, Get, Delete and List Tollfree Verification. +- Added New Param `toll_free_sms_verification_id` and `toll_free_sms_verification_order_status `in to the response of the [list all numbers API], [list single number API] +- Added `toll_free_sms_verification_order_status` filter to AccountPhoneNumber - list all my numbers API. ## [5.33.0](https://github.com/plivo/plivo-java/tree/v5.33.0) (2023-10-20) **Feature - campaign_source field** diff --git a/README.md b/README.md index 77286502..e1654a4a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The Plivo Java SDK makes it simpler to integrate communications into your Java a ### To Install Stable release -You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the [JAR file](https://search.maven.org/remotecontent?filepath=com/plivo/plivo-java/5.33.0/plivo-java-5.33.0.jar). +You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the [JAR file](https://search.maven.org/remotecontent?filepath=com/plivo/plivo-java/5.34.0/plivo-java-5.34.0.jar). If you are using Maven, use the following XML to include the Plivo SDK as a dependency. @@ -18,13 +18,13 @@ If you are using Maven, use the following XML to include the Plivo SDK as a depe com.plivo plivo-java - 5.33.0 + 5.34.0 ``` If you are using Gradle, use the following line in your dependencies. ``` -compile 'com.plivo:plivo-java:5.33.0' +compile 'com.plivo:plivo-java:5.34.0' ``` ### To Install Beta release diff --git a/pom.properties b/pom.properties index 1c25a8d0..4e9655f2 100644 --- a/pom.properties +++ b/pom.properties @@ -1,6 +1,6 @@ # Written manually. -version=5.33.0 +version=5.34.0 groupId=com.plivo artifactId=plivo-java diff --git a/pom.xml b/pom.xml index 6c215419..12f5c2af 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.plivo plivo-java - 5.33.0 + 5.34.0 plivo-java A Java SDK to make voice calls & send SMS using Plivo and to generate Plivo XML diff --git a/src/main/java/com/plivo/api/PlivoAPIService.java b/src/main/java/com/plivo/api/PlivoAPIService.java index 8390f366..2331ec02 100644 --- a/src/main/java/com/plivo/api/PlivoAPIService.java +++ b/src/main/java/com/plivo/api/PlivoAPIService.java @@ -41,6 +41,7 @@ import com.plivo.api.models.profile.*; import com.plivo.api.models.token.TokenCreateResponse; import com.plivo.api.models.token.TokenCreator; +import com.plivo.api.models.tollfree_verification.*; import com.plivo.api.models.verify.*; import okhttp3.RequestBody; import okhttp3.ResponseBody; @@ -758,4 +759,28 @@ Call callStreamGetSpecific(@Path("authId") String @DELETE("Account/{authId}/VerifiedCallerId/{phoneNumber}") Call deleteVerifiedCallerID(@Path("authId") String authId, @Path("phoneNumber") String phoneNumber); + + // TollfreeVerification Request + // Get + @GET("Account/{authId}/TollfreeVerification/{uuid}/") + Call tollfreeVerificationGet(@Path("authId") String authId, @Path("uuid") String uuid); + + // Create + @POST("Account/{authId}/TollfreeVerification/") + Call tollfreeVerificationCreate(@Path("authId") String authId, + @Body TollfreeVerificationCreator tollfreeVerificationCreator); + + // Update + @POST("Account/{authId}/TollfreeVerification/{uuid}/") + Call tollfreeVerificationUpdate(@Path("authId") String authId, @Path("uuid") String uuid, + @Body TollfreeVerificationUpdater tollfreeVerificationUpdater); + + // List + @GET("Account/{authId}/TollfreeVerification/") + Call> tollfreeVerificationList(@Path("authId") String authId, + @QueryMap Map tollfreeVerificationLister); + + // Delete + @DELETE("Account/{authId}/TollfreeVerification/{uuid}/") + Call tollfreeVerificationDelete(@Path("authId") String authId, @Path("uuid") String uuid); } diff --git a/src/main/java/com/plivo/api/models/number/Number.java b/src/main/java/com/plivo/api/models/number/Number.java index 2005d368..24f679ab 100644 --- a/src/main/java/com/plivo/api/models/number/Number.java +++ b/src/main/java/com/plivo/api/models/number/Number.java @@ -27,6 +27,8 @@ public class Number extends BaseResource { private String tollFreeSmsVerification; private String renewalDate; private String cnamLookup; + private String tollFreeSmsVerificationOrderStatus; + private String tollFreeSmsVerificationId; public Boolean getActive() { return active; @@ -154,4 +156,12 @@ public String getRenewalDate() { public String getCnamLookup() { return cnamLookup; } + + public String getTollFreeSmsVerificationOrderStatus() { + return tollFreeSmsVerificationOrderStatus; + } + + public String getTollFreeSmsVerificationId() { + return tollFreeSmsVerificationId; + } } diff --git a/src/main/java/com/plivo/api/models/number/NumberLister.java b/src/main/java/com/plivo/api/models/number/NumberLister.java index b593e27c..95694ea2 100644 --- a/src/main/java/com/plivo/api/models/number/NumberLister.java +++ b/src/main/java/com/plivo/api/models/number/NumberLister.java @@ -17,6 +17,7 @@ public class NumberLister extends Lister { private String tollFreeSmsVerification; private PropertyFilter renewalDate; private String cnamLookup; + private String tollFreeSmsVerificationOrderStatus; public NumberType numberType() { return this.numberType; @@ -55,7 +56,9 @@ public PropertyFilter renewalDate() { public String cnamLookup() { return this.cnamLookup; } - + public String tollFreeSmsVerificationOrderStatus() { + return this.tollFreeSmsVerificationOrderStatus; + } public NumberLister numberType(final NumberType numberType) { this.numberType = numberType; return this; @@ -70,6 +73,12 @@ public NumberLister cnamLookup(final String cnamLookup) { this.cnamLookup = cnamLookup; return this; } + + public NumberLister tollFreeSmsVerificationOrderStatus(final String tollFreeSmsVerificationOrderStatus) { + this.tollFreeSmsVerificationOrderStatus = tollFreeSmsVerificationOrderStatus; + return this; + } + public NumberLister numberStartswith(final String numberStartswith) { this.numberStartswith = numberStartswith; return this; diff --git a/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerification.java b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerification.java new file mode 100644 index 00000000..489a68b4 --- /dev/null +++ b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerification.java @@ -0,0 +1,140 @@ +package com.plivo.api.models.tollfree_verification; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.plivo.api.models.base.BaseResource; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TollfreeVerification extends BaseResource { + private String uuid; + private String profileUuid; + private String number; + private String usecase; + private String usecaseSummary; + private String messageSample; + private String optinImageUrl; + private String optinType; + private String volume; + private String additionalInformation; + private String extraData; + private String callbackUrl; + private String callbackMethod; + private String status; + private String errorMessage; + private String created; + private String lastModified; + + public static TollfreeVerificationCreator creator(String profileUuid, String number, String usecase, String usecaseSummary, String optinImageUrl, + String messageSample, String optinType, String volume, String additionalInformation, + String extraData, String callbackUrl, String callbackMethod) { + + return new TollfreeVerificationCreator(profileUuid, number, usecase, usecaseSummary, optinImageUrl, + messageSample, optinType, volume, additionalInformation,extraData, callbackUrl, callbackMethod); + } + + public static TollfreeVerificationCreator creator(String profileUuid, String number, String usecase, String usecaseSummary, String optinImageUrl, + String messageSample, String optinType, String volume, String additionalInformation) { + + return new TollfreeVerificationCreator(profileUuid, number, usecase, usecaseSummary, optinImageUrl, + messageSample, optinType, volume, additionalInformation); + } + + public static TollfreeVerificationCreator creator() { + return new TollfreeVerificationCreator(); + } + + + public static TollfreeVerificationDeleter deleter(String uuid) { + return new TollfreeVerificationDeleter(uuid); + } + + public static TollfreeVerificationGetter getter(String uuid) { + return new TollfreeVerificationGetter(uuid); + } + + public static TollfreeVerificationLister lister() { + return new TollfreeVerificationLister(); + } + + public static TollfreeVerificationUpdater updater(String uuid) { + return new TollfreeVerificationUpdater(uuid); + } + + public TollfreeVerificationDeleter deleter() { + return new TollfreeVerificationDeleter(uuid); + } + + public TollfreeVerificationUpdater updater() { + return new TollfreeVerificationUpdater(uuid); + } + + + @Override + public String getId() { + return getUuid(); + } + + public String getUuid() { + return uuid; + } + + public String getProfileUuid() { + return profileUuid; + } + + public String getNumber() { + return number; + } + + public String getUsecase() { + return usecase; + } + + public String getUsecaseSummary() { + return usecaseSummary; + } + + public String getMessageSample() { + return messageSample; + } + + public String getOptinImageUrl() { + return optinImageUrl; + } + + public String getOptinType() { + return optinType; + } + + public String getVolume() { + return volume; + } + + public String getAdditionalInformation() { + return additionalInformation; + } + + public String getExtraData() { + return extraData; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public String getCallbackMethod() { + return callbackMethod; + } + + public String getStatus() { + return status; + } + + public String created() { + return created; + } + + public String lastModified() { + return lastModified; + } +} diff --git a/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationCreateResponse.java b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationCreateResponse.java new file mode 100644 index 00000000..91179715 --- /dev/null +++ b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationCreateResponse.java @@ -0,0 +1,15 @@ +package com.plivo.api.models.tollfree_verification; + +import com.plivo.api.models.base.BaseResponse; + +public class TollfreeVerificationCreateResponse extends BaseResponse { + private String uuid; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } +} diff --git a/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationCreator.java b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationCreator.java new file mode 100644 index 00000000..e09a7386 --- /dev/null +++ b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationCreator.java @@ -0,0 +1,175 @@ +package com.plivo.api.models.tollfree_verification; + +import com.plivo.api.models.base.Creator; +import com.plivo.api.util.Utils; +import retrofit2.Call; + +public class TollfreeVerificationCreator extends Creator { + + private String profileUuid; + private String number; + private String usecase; + private String usecaseSummary; + private String messageSample; + private String optinImageUrl; + private String optinType; + private String volume; + private String additionalInformation; + private String extraData; + private String callbackUrl; + private String callbackMethod; + + TollfreeVerificationCreator(String profileUuid, String number, String usecase, String usecaseSummary, String optinImageUrl, + String messageSample, String optinType, String volume, String additionalInformation, String extraData, String callbackUrl, String callbackMethod) { + if (!Utils.allNotNull(profileUuid, number, usecase, usecaseSummary, optinImageUrl, optinType, volume, additionalInformation)) { + throw new IllegalArgumentException("profileUuid, number, usecase, usecaseSummary, optinImageUrl, optinType, volume, additionalInformation must not be null"); + } + + this.profileUuid = profileUuid; + this.number = number; + this.usecase = usecase; + this.usecaseSummary = usecaseSummary; + this.messageSample = messageSample; + this.optinImageUrl = optinImageUrl; + this.optinType = optinType; + this.volume = volume; + this.additionalInformation = additionalInformation; + this.extraData = extraData; + this.callbackUrl = callbackUrl; + this.callbackMethod = callbackMethod; + + } + + TollfreeVerificationCreator(String profileUuid, String number, String usecase, String usecaseSummary, String optinImageUrl, + String messageSample, String optinType, String volume, String additionalInformation) { + if (!Utils.allNotNull(profileUuid, number, usecase, usecaseSummary, optinImageUrl, optinType, volume, additionalInformation)) { + throw new IllegalArgumentException("profileUuid, number, usecase, usecaseSummary, optinImageUrl, optinType, volume, additionalInformation must not be null"); + } + + this.profileUuid = profileUuid; + this.number = number; + this.usecase = usecase; + this.usecaseSummary = usecaseSummary; + this.messageSample = messageSample; + this.optinImageUrl = optinImageUrl; + this.optinType = optinType; + this.volume = volume; + this.additionalInformation = additionalInformation; + } + + TollfreeVerificationCreator() {} + + + @Override + protected Call obtainCall() { + return client().getApiService().tollfreeVerificationCreate(client().getAuthId(), this); + } + + public String profileUuid() { + return profileUuid; + } + + public TollfreeVerificationCreator profileUuid(final String profileUuid) { + this.profileUuid = profileUuid; + return this; + } + + public String number() { + return number; + } + + public TollfreeVerificationCreator number(final String number) { + this.number = number; + return this; + } + + public String usecase() { + return usecase; + } + + public TollfreeVerificationCreator usecase(final String usecase) { + this.usecase = usecase; + return this; + } + + public String callbackMethod() { + return callbackMethod; + } + + public TollfreeVerificationCreator callbackMethod(final String callbackMethod) { + this.callbackMethod = callbackMethod; + return this; + } + + public String callbackUrl() { + return callbackUrl; + } + + public TollfreeVerificationCreator callbackUrl(final String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + public String extraData() { + return extraData; + } + + public TollfreeVerificationCreator extraData(final String extraData) { + this.extraData = extraData; + return this; + } + + public String additionalInformation() { + return additionalInformation; + } + + public TollfreeVerificationCreator additionalInformation(final String additionalInformation) { + this.additionalInformation = additionalInformation; + return this; + } + + public String volume() { + return volume; + } + + public TollfreeVerificationCreator volume(final String volume) { + this.volume = volume; + return this; + } + + public String optinType() { + return optinType; + } + + public TollfreeVerificationCreator optinType(final String optinType) { + this.optinType = optinType; + return this; + } + + public String optinImageUrl() { + return optinImageUrl; + } + + public TollfreeVerificationCreator optinImageUrl(final String optinImageUrl) { + this.optinImageUrl = optinImageUrl; + return this; + } + + public String messageSample() { + return messageSample; + } + + public TollfreeVerificationCreator messageSample(final String messageSample) { + this.messageSample = messageSample; + return this; + } + + public String usecaseSummary() { + return usecaseSummary; + } + + public TollfreeVerificationCreator usecaseSummary(final String usecaseSummary) { + this.usecaseSummary = usecaseSummary; + return this; + } +} diff --git a/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationDeleter.java b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationDeleter.java new file mode 100644 index 00000000..5d254c52 --- /dev/null +++ b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationDeleter.java @@ -0,0 +1,19 @@ +package com.plivo.api.models.tollfree_verification; + +import com.plivo.api.models.base.Deleter; +import okhttp3.ResponseBody; +import retrofit2.Call; + +public class TollfreeVerificationDeleter extends Deleter { + + public TollfreeVerificationDeleter(String uuid) { + super(uuid); + } + + @Override + protected Call obtainCall() { + return client().getApiService().tollfreeVerificationDelete(client().getAuthId(), id); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationGetter.java b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationGetter.java new file mode 100644 index 00000000..58eb797a --- /dev/null +++ b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationGetter.java @@ -0,0 +1,16 @@ +package com.plivo.api.models.tollfree_verification; + +import com.plivo.api.models.base.Getter; +import retrofit2.Call; + +public class TollfreeVerificationGetter extends Getter { + + public TollfreeVerificationGetter(String id) { + super(id); + } + + @Override + protected Call obtainCall() { + return client().getApiService().tollfreeVerificationGet(client().getAuthId(), id); + } +} \ No newline at end of file diff --git a/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationLister.java b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationLister.java new file mode 100644 index 00000000..1a930236 --- /dev/null +++ b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationLister.java @@ -0,0 +1,67 @@ +package com.plivo.api.models.tollfree_verification; + +import com.plivo.api.models.base.ListResponse; +import com.plivo.api.models.base.Lister; +import com.plivo.api.util.PropertyFilter; +import retrofit2.Call; + +public class TollfreeVerificationLister extends Lister { + private String usecase; + private String status; + private PropertyFilter created; + private String number; + private String profileUuid; + + public String usecase() { + return usecase; + } + + public TollfreeVerificationLister usecase(String usecase) { + this.usecase = usecase; + return this; + } + + public String status() { + return status; + } + + public TollfreeVerificationLister status(final String status) { + this.status = status; + return this; + } + + public PropertyFilter created() { + return created; + } + + public TollfreeVerificationLister created(final PropertyFilter created) { + this.created = created; + return this; + } + + public String number() { + return number; + } + + public TollfreeVerificationLister number(final String number) { + this.number = number; + return this; + } + + public String profileUuid() { + return profileUuid; + } + + public TollfreeVerificationLister profileUuid(final String profileUuid) { + this.profileUuid = profileUuid; + return this; + } + + + + @Override + protected Call> obtainCall() { + return client().getApiService().tollfreeVerificationList(client().getAuthId(), toMap()); + } + +} \ No newline at end of file diff --git a/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationUpdateResponse.java b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationUpdateResponse.java new file mode 100644 index 00000000..e5cbed02 --- /dev/null +++ b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationUpdateResponse.java @@ -0,0 +1,7 @@ +package com.plivo.api.models.tollfree_verification; + +import com.plivo.api.models.base.BaseResponse; + +public class TollfreeVerificationUpdateResponse extends BaseResponse { + +} diff --git a/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationUpdater.java b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationUpdater.java new file mode 100644 index 00000000..bc5f5240 --- /dev/null +++ b/src/main/java/com/plivo/api/models/tollfree_verification/TollfreeVerificationUpdater.java @@ -0,0 +1,146 @@ +package com.plivo.api.models.tollfree_verification; + +import com.plivo.api.models.base.Updater; +import retrofit2.Call; + +public class TollfreeVerificationUpdater extends Updater { + private String uuid; + private String number; + private String profileuuid; + private String usecase; + private String usecaseSummary; + private String messageSample; + private String optinImageUrl; + private String optinType; + private String volume; + private String additionalInformation; + private String extraData; + private String callbackURL; + private String callbackMethod; + + public String uuid() { + return uuid; + } + + public TollfreeVerificationUpdater uuid(final String uuid) { + this.uuid = uuid; + return this; + } + + public String number() { + return number; + } + + public TollfreeVerificationUpdater number(final String number) { + this.number = number; + return this; + } + + public String profileuuid() { + return profileuuid; + } + + public TollfreeVerificationUpdater profileuuid(final String profileuuid) { + this.profileuuid = profileuuid; + return this; + } + + public String usecase() { + return usecase; + } + + public TollfreeVerificationUpdater usecase(final String usecase) { + this.usecase = usecase; + return this; + } + + public String usecaseSummary() { + return usecaseSummary; + } + + public TollfreeVerificationUpdater usecaseSummary(final String usecaseSummary) { + this.usecaseSummary = usecaseSummary; + return this; + } + + public String messageSample() { + return messageSample; + } + + public TollfreeVerificationUpdater messageSample(final String messageSample) { + this.messageSample = messageSample; + return this; + } + + public String optinImageUrl() { + return optinImageUrl; + } + + public TollfreeVerificationUpdater optinImageUrl(final String optinImageUrl) { + this.optinImageUrl = optinImageUrl; + return this; + } + + public String optinType() { + return optinType; + } + + public TollfreeVerificationUpdater optinType(final String optinType) { + this.optinType = optinType; + return this; + } + + public String volume() { + return volume; + } + + public TollfreeVerificationUpdater volume(final String volume) { + this.volume = volume; + return this; + } + + public String additionalInformation() { + return additionalInformation; + } + + public TollfreeVerificationUpdater additionalInformation(final String additionalInformation) { + this.additionalInformation = additionalInformation; + return this; + } + + public String extraData() { + return extraData; + } + + public TollfreeVerificationUpdater extraData(final String extraData) { + this.extraData = extraData; + return this; + } + + public String callbackURL() { + return callbackURL; + } + + public TollfreeVerificationUpdater callbackURL(final String callbackURL) { + this.callbackURL = callbackURL; + return this; + } + + public String callbackMethod() { + return callbackMethod; + } + + public TollfreeVerificationUpdater callbackMethod(final String callbackMethod) { + this.callbackMethod = callbackMethod; + return this; + } + + public TollfreeVerificationUpdater(String id) { + super(id); + } + + @Override + protected Call obtainCall() { + return client().getApiService().tollfreeVerificationUpdate(client().getAuthId(), id, this); + } +} \ No newline at end of file diff --git a/src/main/resources/com/plivo/api/version.txt b/src/main/resources/com/plivo/api/version.txt index fe938e52..04a88321 100644 --- a/src/main/resources/com/plivo/api/version.txt +++ b/src/main/resources/com/plivo/api/version.txt @@ -1 +1 @@ -5.33.0 +5.34.0 diff --git a/src/test/java/com/plivo/api/TollfreeVerificationTest.java b/src/test/java/com/plivo/api/TollfreeVerificationTest.java new file mode 100644 index 00000000..9b4c62bb --- /dev/null +++ b/src/test/java/com/plivo/api/TollfreeVerificationTest.java @@ -0,0 +1,134 @@ +package com.plivo.api; + +import com.plivo.api.models.tollfree_verification.TollfreeVerification; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.RecordedRequest; +import org.junit.Before; +import org.junit.Test; + +import static com.plivo.api.TestUtil.loadFixture; +import static junit.framework.TestCase.assertEquals; + +public class TollfreeVerificationTest extends BaseTest { + + private PlivoClient client; + + @Before + public void setUp() throws Exception { + super.setUp(); + client = new PlivoClient("MA123456789012345678", + "Zmxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + } + + @Test + public void tollfreeVerificationCreateShouldSucceed() throws Exception { + expectResponse("tollfreeVerificationCreateResponse.json", 201); + + TollfreeVerification.creator() + .profileUuid("fb239ee1-fb5c-4dd9-b55c-5cf10170e756") + .number("18557312530") + .usecase("FRAUD_ALERT") + .usecaseSummary("summary") + .optinImageUrl("https://wwww.optinurl.com") + .optinType("VERBAL") + .messageSample("message sample") + .volume("10") + .additionalInformation("additional information") + .extraData("extra data") + .callbackMethod("POST") + .callbackMethod("https://www.callbackurl.com") + .create(); + + assertRequest("POST", "TollfreeVerification/"); + } + + @Test + public void tollfreeVerificationCreateWithAllParamsShouldSucceed() throws Exception { + expectResponse("tollfreeVerificationCreateResponse.json", 201); + + TollfreeVerification.creator("fb239ee1-fb5c-4dd9-b55c-5cf10170e756","18557312530","FRAUD_ALERT", + "usecase summary","htts://optimimageurl.com","message sample","VERBAL", + "10","additional information","extra data","https://callbackurl.com","POST" + ).create(); + + assertRequest("POST", "TollfreeVerification/"); + } + + @Test + public void tollfreeVerificationCreateWithMandatoryParamsShouldSucceed() throws Exception { + expectResponse("tollfreeVerificationCreateResponse.json", 201); + + TollfreeVerification.creator("fb239ee1-fb5c-4dd9-b55c-5cf10170e756","18557312530","FRAUD_ALERT", + "usecase summary","htts://optimimageurl.com","message sample","VERBAL", + "10","additional information" + ).create(); + + assertRequest("POST", "TollfreeVerification/"); + } + @Test + public void tollfreeVerificationGetShouldSucceed() throws Exception { + String uuid = "uuid"; + expectResponse("tollfreeVerificationGetResponse.json", 200); + + TollfreeVerification tollfreeVerification = TollfreeVerification.getter(uuid) + .get(); + + assertEquals(tollfreeVerification.getId(), tollfreeVerification.getUuid()); + + assertRequest("GET", "TollfreeVerification/%s/", uuid); + } + + @Test + public void tollfreeVerificationListShouldSucceed() throws Exception { + String fixtureName = "tollfreeVerificationListResponse.json"; + + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody(loadFixture(fixtureName)) + ); + + TollfreeVerification.lister() + .list(); + + RecordedRequest recordedRequest = server.takeRequest(); + assertEquals("GET", recordedRequest.getMethod()); + assertEquals(String.format("/Account/%s/TollfreeVerification/", authId), recordedRequest.getPath()); + } + + @Test + public void tollfreeVerificationUpdateShouldSucceed() throws Exception { + String fixtureName = "tollfreeVerificationUpdateResponse.json"; + String uuid = "uuid"; + + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody(loadFixture(fixtureName)) + ); + + TollfreeVerification.updater(uuid) + .update(); + + RecordedRequest recordedRequest = server.takeRequest(); + assertEquals("POST", recordedRequest.getMethod()); + assertEquals(String.format("/Account/%s/TollfreeVerification/%s/", authId, uuid), + recordedRequest.getPath()); + } + + @Test + public void tollfreeVerificationDeleteShouldSucceed() throws Exception { + String uuid = "uuid"; + + server.enqueue(new MockResponse() + .setResponseCode(204) + ); + + TollfreeVerification.deleter(uuid) + .delete(); + + RecordedRequest recordedRequest = server.takeRequest(); + assertEquals("DELETE", recordedRequest.getMethod()); + assertEquals(String.format("/Account/%s/TollfreeVerification/%s/", authId, uuid), + recordedRequest.getPath()); + } + +} diff --git a/src/test/resources/com/plivo/api/tollfreeVerificationCreateResponse.json b/src/test/resources/com/plivo/api/tollfreeVerificationCreateResponse.json new file mode 100644 index 00000000..20881d75 --- /dev/null +++ b/src/test/resources/com/plivo/api/tollfreeVerificationCreateResponse.json @@ -0,0 +1,5 @@ +{ + "api_id": "99f9d6f6-3f08-11e7-9fd1-06660ad2b8e6", + "uuid": "28f736dc-680c-5ae4-6765-01732884e41e", + "message": "created" +} diff --git a/src/test/resources/com/plivo/api/tollfreeVerificationGetResponse.json b/src/test/resources/com/plivo/api/tollfreeVerificationGetResponse.json new file mode 100644 index 00000000..f8ebb5a0 --- /dev/null +++ b/src/test/resources/com/plivo/api/tollfreeVerificationGetResponse.json @@ -0,0 +1,20 @@ +{ + "additional_information": "additional update1", + "api_id": "287aca86-73e9-11ee-93b2-0242ac110006", + "callback_method": "POST", + "callback_url": "https://www.callbackurl1.com", + "created_at": "2023-10-25T06:28:45.168185Z", + "extra_data": "extra updated1", + "messaege_sample": "sample update1", + "number": "18557312530", + "optin_image_url": "https://wwww.optinurl.com", + "optin_type": "VERBAL", + "profile_uuid": "fb239ee1-fb5c-4dd9-b55c-5cf10170e756", + "status": "SUBMITTED", + "updated_at": "2023-10-26T06:06:40.052089Z", + "usecase": "FRAUD_ALERT", + "usecase_summary": "summary", + "uuid": "28f736dc-680c-5ae4-6765-01732884e41e", + "volume": "10", + "error_message": "" +} \ No newline at end of file diff --git a/src/test/resources/com/plivo/api/tollfreeVerificationListResponse.json b/src/test/resources/com/plivo/api/tollfreeVerificationListResponse.json new file mode 100644 index 00000000..7686d4b1 --- /dev/null +++ b/src/test/resources/com/plivo/api/tollfreeVerificationListResponse.json @@ -0,0 +1,50 @@ +{ + "api_id": "c25c72f8-73d5-11ee-8d5d-0242ac110006", + "meta": { + "total_count": 2, + "limit": 20, + "next": null, + "offset": 0, + "previous": null + }, + "objects": [ + { + "additional_information": "additional update1", + "callback_method": "POST", + "callback_url": "https://www.callbackurl1.com", + "created_at": "2023-10-25T06:28:45.168185Z", + "extra_data": "extra updated1", + "message_sample": "sample update1", + "number": "18557312530", + "optin_image_url": "https://wwww.updatedur1.com", + "optin_type": "VERBAL", + "profile_uuid": "fb239ee1-fb5c-4dd9-b55c-5cf10170e756", + "error_message": "", + "status": "SUBMITTED", + "updated_at": "2023-10-26T06:06:40.052089Z", + "usecase": "FRAUD_ALERT", + "usecase_summary": "summary up1", + "uuid": "aa5eab21-4931-468e-7502-2d8d18311fcc", + "volume": "10" + }, + { + "additional_information": "this is additional_information", + "callback_method": "POST", + "callback_url": "http://plivobin-prod-usw1.plivops.com/14ha4pv1", + "created_at": "2023-10-19T11:33:59.363045Z", + "extra_data": "this is extra_data", + "message_sample": "mes", + "number": "18449605287", + "optin_image_url": "https://www.aa.com,http://google.com", + "optin_type": "VERBAL", + "profile_uuid": "fb239ee1-fb5c-4dd9-b55c-5cf10170e756", + "error_message": "", + "status": "REJECTED", + "updated_at": "2023-10-19T11:33:59.362762Z", + "usecase": "2FA,FRAUD_ALERT,HIGHER_EDUCATION,PUBLIC_SERVICE_ANNOUNCEMENT", + "usecase_summary": "use ", + "uuid": "7189d4c9-78fe-4dfd-5dc4-6e68101afdb9", + "volume": "10" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/com/plivo/api/tollfreeVerificationUpdateResponse.json b/src/test/resources/com/plivo/api/tollfreeVerificationUpdateResponse.json new file mode 100644 index 00000000..88ac9f05 --- /dev/null +++ b/src/test/resources/com/plivo/api/tollfreeVerificationUpdateResponse.json @@ -0,0 +1,4 @@ +{ + "api_id": "dbf8f1b8-73c2-11ee-8d5d-0242ac110006", + "message": "Tollfree verification request for uuid 28f736dc-680c-5ae4-6765-01732884e41e updated successfully." +} \ No newline at end of file