Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alphasights/kotlin-twilio-extensions
Unofficial Kotlin extensions for the Twilio Java SDK
https://github.com/alphasights/kotlin-twilio-extensions
Last synced: 5 days ago
JSON representation
Unofficial Kotlin extensions for the Twilio Java SDK
- Host: GitHub
- URL: https://github.com/alphasights/kotlin-twilio-extensions
- Owner: alphasights
- License: mit
- Created: 2019-07-26T15:04:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-17T17:35:40.000Z (10 months ago)
- Last Synced: 2024-04-14T07:25:16.451Z (7 months ago)
- Language: Python
- Homepage:
- Size: 80.1 KB
- Stars: 0
- Watchers: 24
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unofficial Kotlin Extensions for the Twilio Java SDK
© 2020 AlphaSights, Ltd.
This is a library that makes the Twilio Java SDK feel more natural in Kotlin. It adds two features:
* A domain-specific language for writing TwiML responses
* Extensions to the REST request builders to accept a blockThe domain-specific language takes the Builder-heavy Twilio API:
```kotlin
val voiceResponse = VoiceResponse.Builder()
.gather(Gather.Builder()
.say(Say
.Builder("Press 1 to be connected, otherwise, hang up.")
.voice(Say.Voice.POLLY_GERAINT)
.build())
.numDigits(1)
.action("https://example.com/success")
.build()
)
.redirect("https://example.com/failure").build())
.build()
```and replaces it with something simpler:
```kotlin
val voiceResponse = return DSLTwiML.voiceResponse {
gather {
say("Press 1 to be connected, otherwise, hang up") {
voice(Say.Voice.POLLY_GERAINT)
}numDigits(1)
action("https://example.com/success")
}redirect("https://example.com/failure")
}
```Kotlin-style builder-block constructs are available for all TwiML constructs.
## Building
The build script is written in Gradle, but currently depends on Python 2.7, or 3.5 or greater being available on your system. The
Python script generates a Kotlin source file that contains the TwiML DSL, and the extensions to the TwiML builder
classes that make it work.## Adding to your project
Maven distributions are available through JitPack. To include in your Gradle project, ensure you have jitpack in your
repositories```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```and include the following build dependency:
```
dependencies {
implementation 'com.github.alphasights:kotlin-twilio-extensions:${KOTLIN_TWILIO_EXTENSIONS_VERSION}'
}
```## Disclaimers
This library is not produced or endorsed by Twilio, and is provided as-is.