-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEVEXP-462 numbers snippets #6
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4ec2838
ci: Enable multiple Snippets compilation for same package with same c…
JPPortier 9bd054d
feature: RentAny snippet
JPPortier 2a12786
feature: RentAndConfigure snippet
JPPortier bf42f8c
feature (Numbers/RentAndConfig): Add a dedicated update request to ed…
JPPortier dd9b3a7
refactor (Numbers/rent): 'RentAndConfig' renamed to 'Rent' for simpli…
JPPortier c1bb1e2
feature (Numbers/update): Add 'active number update' snippet
JPPortier 32835e2
PR comment
JPPortier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
|
||
(cd snippets && mvn clean spotless:apply compile) | ||
(cd snippets && mvn clean spotless:apply) | ||
(cd snippets && ./compile.sh) | ||
|
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,14 @@ | ||
#!/bin/sh | ||
|
||
SNIPPETS=`find . -type f -regex '.*Snippet\.java$'` | ||
|
||
echo "Compiling snippets:" | ||
for snippet in $SNIPPETS | ||
do | ||
echo " - Snippet: $snippet" | ||
mvn compile -Dsnippet="$(dirname $snippet)" | ||
if [ $? -ne 0 ] | ||
then | ||
exit $? | ||
fi | ||
done |
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 @@ | ||
package numbers; | ||
|
||
import com.sinch.sdk.domains.numbers.AvailableNumberService; | ||
import com.sinch.sdk.domains.numbers.NumbersService; | ||
import com.sinch.sdk.domains.numbers.models.ActiveNumber; | ||
import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters; | ||
import com.sinch.sdk.domains.numbers.models.requests.RentSMSConfigurationRequestParameters; | ||
import java.util.logging.Logger; | ||
|
||
public class Snippet { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(Snippet.class.getName()); | ||
|
||
static void execute(NumbersService numbersService) { | ||
|
||
AvailableNumberService availableNumbersService = numbersService.available(); | ||
|
||
String servicePlanId = "YOUR_service_plan_id"; | ||
String phoneNumber = "YOUR_phone_number"; | ||
asein-sinch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
ActiveNumber response = | ||
availableNumbersService.rent( | ||
phoneNumber, | ||
AvailableNumberRentRequestParameters.builder() | ||
.setSmsConfiguration( | ||
RentSMSConfigurationRequestParameters.builder() | ||
.setServicePlanId(servicePlanId) | ||
.build()) | ||
.build()); | ||
|
||
LOGGER.info(String.format("Rented number: %s", response)); | ||
} | ||
} |
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,41 @@ | ||
package numbers; | ||
|
||
import com.sinch.sdk.domains.numbers.AvailableNumberService; | ||
import com.sinch.sdk.domains.numbers.NumbersService; | ||
import com.sinch.sdk.domains.numbers.models.ActiveNumber; | ||
import com.sinch.sdk.domains.numbers.models.Capability; | ||
import com.sinch.sdk.domains.numbers.models.NumberType; | ||
import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters; | ||
import com.sinch.sdk.domains.numbers.models.requests.RentSMSConfigurationRequestParameters; | ||
import java.util.Collections; | ||
import java.util.logging.Logger; | ||
|
||
public class Snippet { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(Snippet.class.getName()); | ||
|
||
static void execute(NumbersService numbersService) { | ||
|
||
AvailableNumberService availableNumbersService = numbersService.available(); | ||
|
||
String servicePlanId = "YOUR_service_plan_id"; | ||
String regionCode = "YOUR_region_code"; | ||
|
||
Capability capability = Capability.SMS; | ||
NumberType numberType = NumberType.LOCAL; | ||
|
||
ActiveNumber response = | ||
availableNumbersService.rentAny( | ||
AvailableNumberRentAnyRequestParameters.builder() | ||
.setCapabilities(Collections.singletonList(capability)) | ||
.setType(numberType) | ||
.setRegionCode(regionCode) | ||
.setSmsConfiguration( | ||
RentSMSConfigurationRequestParameters.builder() | ||
.setServicePlanId(servicePlanId) | ||
.build()) | ||
.build()); | ||
|
||
LOGGER.info(String.format("Rented number: %s", response)); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the name of the folder, I would have expected another action to configure the rented number. For instance, you are also providing the SMS config in the
rent_any
snippet.Maybe you can add a second request (
update
) to set the Voice config ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done; but will sync with doc.
Seems snippet become more than a simple snippet.
We could imagine something like:
rentAny
snippet: from this PR highlighting rent and configuration for SMS with a single requestrent
snippet: the 1st part of this snippet source to rent an available number returned by "list available"update
snippet: the 2nd part of this snippet source to perform an update onto an already rented numberWill check with doc (@alex-sberna )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
According to last sync: