diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..3e4d7c2 --- /dev/null +++ b/readme.md @@ -0,0 +1,133 @@ +# Telegram Gateway API SDK + +This library allows you to verify phone numbers of users and send authorization codes through [Telegram Gateway](https://core.telegram.org/gateway). + +![](https://core.telegram.org/file/400780400656/3/9iBg_m8EjJs.349165/64ba1e8722d15e124d) + +## Contents +- [Requirements](#requirements) +- [Installation](#installation) +- [Example](#example) +- [License](#license) + + +## Requirements +| Technology | Version | +|------------|-----| +| JDK | 21+ | +| Kotlin | 1.9+ | +| Coroutines | 1.8.0+ | + + +## Installation +1) Download by one of two options: +- 1.1 Clone source code: +```shell +git clone https://github.com/p-vorobyev/telegram-gateway-sdk.git +``` + +    or + +- 1.2 Download artifact from GitHub Packages: + +       **Gradle**: + +       Specify repository in `build.gradle.kts` with your GitHub login and personal token. + +```kotlin +repositories { + mavenCentral() + maven { + url = uri("https://maven.pkg.github.com/p-vorobyev/*") + credentials { + username = "GITHUB_LOGIN" + password = "GITHUB_TOKEN" + } + } +} +``` + +       **Maven**: + +       Specify `github` server with your credentials in `settings.xml` for Apache Maven. See GitHub [docs](https://docs.github.com/ru/enterprise-cloud@latest/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) how to generate personal token. + +```xml + + + + + github + GITHUB_LOGIN + GITHUB_TOKEN + + + + +``` + +       Add repository to `pom.xml` of your project. + +```xml + + + github + https://maven.pkg.github.com/p-vorobyev/* + + +``` + +3) Add dependency to your project: + +       **Gradle**: + +```kotlin +implementation("dev.voroby:telegram-gateway-sdk:1.0.0") +``` + +       **Maven**: + +```xml + + dev.voroby + telegram-gateway-sdk + 1.0.0 + +``` + + +## Example +Create `TelegramGateway` instance: + +```kotlin +val protocol = Protocol.createHttpProtocol() +val telegramGateway = TelegramGateway.create( + accessToken = "your_token", + protocol = protocol +) +``` +Available methods([documentation](https://core.telegram.org/gateway/api)): +```kotlin +interface TelegramGateway : AutoCloseable { + + suspend fun checkSendAbility(request: CheckSendAbility.Request): Either + + suspend fun checkVerificationStatus(request: CheckVerificationStatus.Request): Either + + suspend fun sendVerificationMessage(request: SendVerificationMessage.Request): Either +} +``` +Let's check the ability to send a verification message to the specified phone number: +```kotlin +telegramGateway.use { tg -> + val request = CheckSendAbility.Request("phone_number_in_international_format") + val response: Either = tg.checkSendAbility(request) + response.onRight { println(it.toString()) } +} +``` + + +## License +[MIT License](https://github.com/p-vorobyev/telegram-gateway-sdk/blob/master/LICENSE) \ No newline at end of file