├── .github
├── CODEOWNERS
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── ci.yml
│ ├── initiate_release.yml
│ ├── javadoc.yml
│ ├── release.yml
│ └── scheduled_test.yml
├── .gitignore
├── .versionrc.js
├── CHANGELOG.md
├── CONTRIBUTING.md
├── DOCS.md
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── SECURITY.md
├── assets
└── logo.svg
├── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties.example
├── publish.gradle
├── scripts
└── get_changelog_diff.js
├── settings.gradle
└── src
├── main
└── java
│ └── io
│ └── getstream
│ └── chat
│ └── java
│ ├── exceptions
│ └── StreamException.java
│ ├── models
│ ├── App.java
│ ├── BlockUser.java
│ ├── Blocklist.java
│ ├── Channel.java
│ ├── ChannelType.java
│ ├── Command.java
│ ├── DeleteStrategy.java
│ ├── Device.java
│ ├── Draft.java
│ ├── Event.java
│ ├── ExportUsers.java
│ ├── FilterCondition.java
│ ├── Flag.java
│ ├── Import.java
│ ├── Language.java
│ ├── LanguageDeserializer.java
│ ├── Message.java
│ ├── MessageHistory.java
│ ├── MessagePaginationParameters.java
│ ├── Moderation.java
│ ├── PaginationParameters.java
│ ├── Permission.java
│ ├── RateLimit.java
│ ├── Reaction.java
│ ├── ResourceAction.java
│ ├── Role.java
│ ├── Sort.java
│ ├── TaskStatus.java
│ ├── Thread.java
│ ├── UnreadCounts.java
│ ├── User.java
│ └── framework
│ │ ├── DefaultFileHandler.java
│ │ ├── FileHandler.java
│ │ ├── RequestObjectBuilder.java
│ │ ├── StreamRequest.java
│ │ ├── StreamResponse.java
│ │ ├── StreamResponseObject.java
│ │ ├── StreamResponseWithRateLimit.java
│ │ └── UnixTimestampDeserializer.java
│ └── services
│ ├── AppService.java
│ ├── BlockUserService.java
│ ├── BlocklistService.java
│ ├── ChannelService.java
│ ├── ChannelTypeService.java
│ ├── CommandService.java
│ ├── DeviceService.java
│ ├── DraftService.java
│ ├── EventService.java
│ ├── ExportUsersService.java
│ ├── FlagService.java
│ ├── ImportService.java
│ ├── MessageHistoryService.java
│ ├── MessageService.java
│ ├── ModerationService.java
│ ├── PermissionService.java
│ ├── ReactionService.java
│ ├── RoleService.java
│ ├── TaskStatusService.java
│ ├── ThreadService.java
│ ├── UnreadCountsService.java
│ ├── UserService.java
│ └── framework
│ ├── Client.java
│ ├── DefaultClient.java
│ ├── HttpLoggingInterceptor.java
│ ├── QueryConverterFactory.java
│ ├── StreamServiceGenerator.java
│ ├── StreamServiceHandler.java
│ └── ToJson.java
└── test
├── java
└── io
│ └── getstream
│ └── chat
│ └── java
│ ├── AppTest.java
│ ├── BasicTest.java
│ ├── BlockUserTest.java
│ ├── BlocklistTest.java
│ ├── ChannelDraftTest.java
│ ├── ChannelTest.java
│ ├── ChannelTypeTest.java
│ ├── CommandTest.java
│ ├── DeviceTest.java
│ ├── EventTest.java
│ ├── ExportUsersTest.java
│ ├── FlagTest.java
│ ├── ImportTests.java
│ ├── MessageHistoryTest.java
│ ├── MessageTest.java
│ ├── ModerationTest.java
│ ├── PermissionTest.java
│ ├── ReactionTest.java
│ ├── RoleTest.java
│ ├── TaskStatusTest.java
│ ├── ThreadTest.java
│ ├── UnreadCountsTest.java
│ └── UserTest.java
└── resources
├── upload_file.pdf
├── upload_file.txt
├── upload_image.png
└── upload_image.svg
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @ferhatelmas
2 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Submit a pull request
2 |
3 | ## CLA
4 |
5 | - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required).
6 | - [ ] The code changes follow best practices
7 | - [ ] Code changes are tested (add some information if not applicable)
8 |
9 | ## Description of the pull request
10 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on: [pull_request]
4 |
5 | concurrency:
6 | group: ${{ github.workflow }}-${{ github.head_ref }}
7 | cancel-in-progress: true
8 |
9 | jobs:
10 | ci:
11 | name: 🧪 Test & lint
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Check out code
15 | uses: actions/checkout@v3
16 | with:
17 | fetch-depth: 0
18 |
19 | - name: Test
20 | env:
21 | STREAM_KEY: ${{ secrets.STREAM_KEY }}
22 | STREAM_SECRET: ${{ secrets.STREAM_SECRET }}
23 | run: |
24 | ./gradlew spotlessCheck --no-daemon
25 | ./gradlew javadoc --no-daemon
26 | ./gradlew jacocoTestReport --no-daemon
27 |
--------------------------------------------------------------------------------
/.github/workflows/initiate_release.yml:
--------------------------------------------------------------------------------
1 | name: Create release PR
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | version:
7 | description: "The new version number. Example: 1.40.1"
8 | required: true
9 |
10 | jobs:
11 | init_release:
12 | name: 🚀 Create release PR
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v3
16 | with:
17 | fetch-depth: 0 # gives the changelog generator access to all previous commits
18 |
19 | - name: Update CHANGELOG.md, build.gradle and push release branch
20 | env:
21 | VERSION: ${{ github.event.inputs.version }}
22 | run: |
23 | npx --yes standard-version@9.3.2 --release-as "$VERSION" --skip.tag --skip.commit --tag-prefix=
24 | git config --global user.name 'github-actions'
25 | git config --global user.email 'release@getstream.io'
26 | git checkout -q -b "release-$VERSION"
27 | git commit -am "chore(release): $VERSION"
28 | git push -q -u origin "release-$VERSION"
29 |
30 | - name: Get changelog diff
31 | uses: actions/github-script@v6
32 | with:
33 | script: |
34 | const get_change_log_diff = require('./scripts/get_changelog_diff.js')
35 | core.exportVariable('CHANGELOG', get_change_log_diff())
36 |
37 | - name: Open pull request
38 | env:
39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 | run: |
41 | gh pr create \
42 | -t "Release ${{ github.event.inputs.version }}" \
43 | -b "# :rocket: ${{ github.event.inputs.version }}
44 | Make sure to use squash & merge when merging!
45 | Once this is merged, another job will kick off automatically and publish the package.
46 | # :memo: Changelog
47 | ${{ env.CHANGELOG }}"
48 |
--------------------------------------------------------------------------------
/.github/workflows/javadoc.yml:
--------------------------------------------------------------------------------
1 | name: javadoc
2 | on:
3 | push:
4 | branches:
5 | - main
6 | jobs:
7 | javadoc:
8 | runs-on: ubuntu-latest
9 | concurrency: docs-${{ github.ref }}
10 | name: 📚 Docs
11 | steps:
12 | - name: Checkout
13 | uses: actions/checkout@v3
14 | with:
15 | persist-credentials: false
16 |
17 | - name: Set up Node.js 14
18 | uses: actions/setup-node@v3
19 | with:
20 | node-version: 14
21 |
22 | - name: Generate doc
23 | run: ./gradlew --no-daemon javadoc
24 |
25 | - name: Deploy
26 | uses: JamesIves/github-pages-deploy-action@v4
27 | with:
28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 | BRANCH: gh-pages
30 | FOLDER: build/docs/javadoc/
31 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | pull_request:
5 | types: [closed]
6 | branches:
7 | - main
8 |
9 | jobs:
10 | Release:
11 | name: 🚀 Release
12 | if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v3
16 | with:
17 | fetch-depth: 0
18 |
19 | - uses: actions/github-script@v6
20 | with:
21 | script: |
22 | const get_change_log_diff = require('./scripts/get_changelog_diff.js')
23 | core.exportVariable('CHANGELOG', get_change_log_diff())
24 |
25 | // Getting the release version from the PR source branch
26 | // Source branch looks like this: release-1.0.0
27 | const version = context.payload.pull_request.head.ref.split('-')[1]
28 | core.exportVariable('VERSION', version)
29 |
30 | - name: Publish to MavenCentral
31 | run: |
32 | sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'"
33 | ./gradlew publishToSonatype --no-daemon --max-workers 1 closeAndReleaseSonatypeStagingRepository
34 | env:
35 | STREAM_KEY: ${{ secrets.STREAM_KEY }}
36 | STREAM_SECRET: ${{ secrets.STREAM_SECRET }}
37 | GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
38 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
39 | OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
40 | SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
41 | SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
42 | SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
43 | SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
44 |
45 | - name: Create release on GitHub
46 | uses: ncipollo/release-action@v1
47 | with:
48 | body: ${{ env.CHANGELOG }}
49 | tag: ${{ env.VERSION }}
50 | token: ${{ secrets.GITHUB_TOKEN }}
51 |
--------------------------------------------------------------------------------
/.github/workflows/scheduled_test.yml:
--------------------------------------------------------------------------------
1 | name: Scheduled tests
2 |
3 | on:
4 | workflow_dispatch:
5 | schedule:
6 | # Monday at 9:00 UTC
7 | - cron: "0 9 * * 1"
8 |
9 | jobs:
10 | test:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v3
14 |
15 | - name: Run tests
16 | env:
17 | STREAM_KEY: ${{ secrets.STREAM_KEY }}
18 | STREAM_SECRET: ${{ secrets.STREAM_SECRET }}
19 | run: |
20 | # Retry 3 times because tests can be flaky
21 | for _ in 1 2 3;
22 | do
23 | ./gradlew test --no-daemon && break
24 | done
25 |
26 | - name: Notify Slack if failed
27 | uses: voxmedia/github-action-slack-notify-build@v1
28 | if: failure()
29 | with:
30 | channel_id: C02RPDF7T63
31 | color: danger
32 | status: FAILED
33 | env:
34 | SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | !gradle/wrapper/gradle-wrapper.jar
16 | *.war
17 | *.nar
18 | *.ear
19 | *.zip
20 | *.tar.gz
21 | *.rar
22 |
23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
24 | hs_err_pid*
25 | /target/
26 | /build/
27 | .gradle/
28 | /local.properties
29 | /bin/
30 |
31 | .env
32 | .envrc
33 | secring.gpg
34 |
35 | .vscode/
36 | .idea/
37 | .classpath
38 | .project
39 | .settings/
40 | gradle.properties
41 |
--------------------------------------------------------------------------------
/.versionrc.js:
--------------------------------------------------------------------------------
1 | const gradleUpdater = {
2 | VERSION_REGEX: /version = '(.+)'/,
3 |
4 | readVersion: function (contents) {
5 | const version = this.VERSION_REGEX.exec(contents)[1];
6 | return version;
7 | },
8 |
9 | writeVersion: function (contents, version) {
10 | return contents.replace(this.VERSION_REGEX.exec(contents)[0], `version = '${version}'`);
11 | }
12 | }
13 |
14 | module.exports = {
15 | bumpFiles: [{ filename: './build.gradle', updater: gradleUpdater }],
16 | }
17 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM amazoncorretto:11
2 |
3 | WORKDIR /code
4 |
5 | # Copy the Gradle wrapper files
6 | COPY gradlew .
7 | COPY gradle gradle/
8 | COPY build.gradle .
9 | COPY settings.gradle .
10 |
11 | # Make gradlew executable
12 | RUN chmod +x gradlew
13 |
14 | CMD ["sh", "-c", "./gradlew :spotlessApply"]
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | build:
2 | ./gradlew build
3 |
4 | format:
5 | ./gradlew :spotlessApply
6 |
7 | test:
8 | ./gradlew test
9 |
10 | test_with_docker:
11 | docker run -t -i -w /code -v $(PWD):/code --env-file .env amazoncorretto:17 sh -c "sh ./gradlew test"
12 |
13 | format_with_docker:
14 | docker build -t stream-chat-java-formatter . && \
15 | docker run -v $(PWD):/code stream-chat-java-formatter
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Official Java SDK for [Stream Chat](https://getstream.io/chat/docs/)
2 |
3 | [](https://maven-badges.herokuapp.com/maven-central/io.getstream/stream-chat-java) [](https://github.com/GetStream/stream-chat-java/actions)
4 |
5 |
6 |
7 |
8 |
9 | Official Java API client for Stream Chat, a service for building chat applications.
10 |
11 | Explore the docs »
12 |
13 |
14 | JavaDoc
15 | ·
16 | Code Samples
17 | ·
18 | Report Bug
19 | ·
20 | Request Feature
21 |
22 |
23 | ## 📝 About Stream
24 |
25 | You can sign up for a Stream account at our [Get Started](https://getstream.io/chat/get_started/) page.
26 |
27 | You can use this library to access chat API endpoints server-side.
28 |
29 | For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries ([docs](https://getstream.io/chat/)).
30 |
31 | ## ⚙️ Installation
32 |
33 | > The Stream chat Java SDK requires Java 11+. It supports latest LTS.
34 |
35 | > The Stream chat Java SDK is compatible with Groovy, Scala, Kotlin and Clojure.
36 |
37 | ### Installation for Java
38 |
39 | #### Gradle
40 |
41 | ```gradle
42 | dependencies {
43 | implementation "io.getstream:stream-chat-java:$stream_version"
44 | }
45 | ```
46 |
47 | #### Maven
48 |
49 | ```maven
50 |
51 | io.getstream
52 | stream-chat-java
53 | $stream_version
54 |
55 | ```
56 |
57 | ### Installation for Groovy
58 |
59 | #### Gradle
60 |
61 | ```gradle
62 | dependencies {
63 | implementation 'io.getstream:stream-chat-java:$stream_version'
64 | }
65 | ```
66 |
67 | > You can see an example project at [GetStream/stream-chat-groovy-example](https://github.com/GetStream/stream-chat-groovy-example).
68 |
69 | ### Installation for Scala
70 |
71 | #### Gradle
72 |
73 | ```gradle
74 | dependencies {
75 | implementation 'io.getstream:stream-chat-java:$stream_version'
76 | }
77 | ```
78 |
79 | > You can see an example project at [GetStream/stream-chat-scala-example](https://github.com/GetStream/stream-chat-scala-example).
80 |
81 | ### Installation for Kotlin
82 |
83 | #### Gradle
84 |
85 | ```gradle
86 | dependencies {
87 | implementation("io.getstream:stream-chat-java:$stream_version")
88 | }
89 | ```
90 |
91 | > You can see an example project at [GetStream/stream-chat-kotlin-example](https://github.com/GetStream/stream-chat-kotlin-example).
92 |
93 | ### Installation for Clojure
94 |
95 | #### Leiningen
96 |
97 | ```leiningen
98 | :dependencies [[io.getstream/stream-chat-java "$stream_version"]]
99 | ```
100 |
101 | > You can see an example project at [GetStream/stream-chat-clojure-example](https://github.com/GetStream/stream-chat-clojure-example).
102 |
103 | ## 🔀 Dependencies
104 |
105 | This SDK uses lombok (code generation), retrofit (http client), jackson (json) and jjwt (jwt).
106 |
107 | > You can find the exact versions in [build.gradle](./build.gradle).
108 |
109 | ## 🥷🏿 Shadowed version
110 |
111 | If you have conflicts with our dependencies, you can use the shadowed (shaded) version of the library:
112 |
113 |
114 | io.getstream:stream-chat-java-all:1.26.2
115 |
116 |
117 | ## ✨ Getting started
118 |
119 | ### Configuration
120 |
121 | To configure the SDK you need to provide required properties
122 |
123 | | Property | ENV | Default | Required |
124 | | --------------------------- | ------------------- | ------------------------------ | -------- |
125 | | io.getstream.chat.apiKey | STREAM_KEY | - | Yes |
126 | | io.getstream.chat.apiSecret | STREAM_SECRET | - | Yes |
127 | | io.getstream.chat.timeout | STREAM_CHAT_TIMEOUT | 10000 | No |
128 | | io.getstream.chat.url | STREAM_CHAT_URL | https://chat.stream-io-api.com | No |
129 |
130 | You can also use your own CDN by creating an implementation of FileHandler and setting it this way
131 |
132 | ```java
133 | Message.fileHandlerClass = MyFileHandler.class
134 | ```
135 |
136 | All setup must be done prior to any request to the API.
137 |
138 | ## Print Chat app configuration
139 |
140 |
141 |
142 | Java |
143 |
144 | ```java
145 | System.out.println(App.get().request());
146 | ```
147 |
148 | |
Groovy |
149 |
150 | ```groovy
151 | println App.get().request()
152 | ```
153 |
154 | |
Scala |
155 |
156 | ```scala
157 | println(App.get.request)
158 | ```
159 |
160 | |
Kotlin |
161 |
162 | ```kotlin
163 | println(App.get().request())
164 | ```
165 |
166 | |
Clojure |
167 |
168 | ```clojure
169 | println (.request (App/get))
170 | ```
171 |
172 | |
173 |
174 |
175 | ## 📚 Code examples
176 |
177 | Head over to [DOCS.md](./DOCS.md) for code snippets.
178 |
179 | ## 🙋 FAQ
180 |
181 | 1. If you get this exception: `java.lang.ClassNotFoundException: io.jsonwebtoken.SignatureAlgorithm`:
182 |
183 | See [shadowed version](#-shadowed-version).
184 |
185 | ## ✍️ Contributing
186 |
187 | We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our [license file](./LICENSE) for more details.
188 |
189 | Head over to [CONTRIBUTING.md](./CONTRIBUTING.md) for some development tips.
190 |
191 | ## 🧑💻 We are hiring!
192 |
193 | We've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.
194 | Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.
195 |
196 | Check out our current openings and apply via [Stream's website](https://getstream.io/team/#jobs).
197 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Reporting a Vulnerability
2 | At Stream we are committed to the security of our Software. We appreciate your efforts in disclosing vulnerabilities responsibly and we will make every effort to acknowledge your contributions.
3 |
4 | Report security vulnerabilities at the following email address:
5 | ```
6 | [security@getstream.io](mailto:security@getstream.io)
7 | ```
8 | Alternatively it is also possible to open a new issue in the affected repository, tagging it with the `security` tag.
9 |
10 | A team member will acknowledge the vulnerability and will follow-up with more detailed information. A representative of the security team will be in touch if more information is needed.
11 |
12 | # Information to include in a report
13 | While we appreciate any information that you are willing to provide, please make sure to include the following:
14 | * Which repository is affected
15 | * Which branch, if relevant
16 | * Be as descriptive as possible, the team will replicate the vulnerability before working on a fix.
17 |
--------------------------------------------------------------------------------
/assets/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java-library'
3 | id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
4 | id 'com.diffplug.spotless' version '6.25.0'
5 | id 'org.barfuin.gradle.jacocolog' version '3.1.0'
6 | id 'com.github.johnrengelman.shadow' version '8.1.1'
7 | }
8 |
9 | group = 'io.getstream'
10 | version = '1.29.0'
11 | description = 'Stream Chat official Java SDK'
12 |
13 | java {
14 | toolchain {
15 | languageVersion = JavaLanguageVersion.of(11)
16 | }
17 |
18 | withJavadocJar()
19 | withSourcesJar()
20 | }
21 |
22 | repositories {
23 | mavenLocal()
24 | mavenCentral()
25 | maven { url "https://plugins.gradle.org/m2/" }
26 | maven { url uri('https://repo.maven.apache.org/maven2/') }
27 | }
28 |
29 | dependencies {
30 | implementation(platform("com.squareup.okhttp3:okhttp-bom:4.12.0"))
31 |
32 | // define any required OkHttp artifacts without version
33 | implementation("com.squareup.okhttp3:okhttp")
34 |
35 | implementation 'com.squareup.retrofit2:retrofit:2.9.0'
36 | implementation 'com.squareup.retrofit2:converter-jackson:2.9.0'
37 | implementation 'io.jsonwebtoken:jjwt-api:0.12.5'
38 | runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.5'
39 | runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.5'
40 | testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
41 | testImplementation 'org.apache.commons:commons-lang3:3.12.0'
42 | compileOnly 'org.projectlombok:lombok:1.18.32'
43 | annotationProcessor 'org.projectlombok:lombok:1.18.32'
44 |
45 | testCompileOnly 'org.projectlombok:lombok:1.18.32'
46 | testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
47 | }
48 |
49 | def localProperties = new Properties()
50 | def localPropertiesFile = project.rootProject.file('local.properties')
51 | if (localPropertiesFile.exists()) {
52 | localProperties.load(localPropertiesFile.newDataInputStream())
53 | }
54 |
55 | test {
56 | useJUnitPlatform()
57 |
58 | testLogging {
59 | exceptionFormat = 'full'
60 | events 'standard_out', 'standard_error', "passed", "skipped", "failed"
61 | }
62 |
63 | doFirst {
64 | // Inject local properties into tests runtime system properties
65 | localProperties.each{k, v ->
66 | systemProperty k.toString(), v.toString()
67 | }
68 | }
69 |
70 | finalizedBy jacocoTestReport
71 | }
72 |
73 | def generatedVersionDir = "${buildDir}/generated-version"
74 |
75 | sourceSets {
76 | main {
77 | output.dir(generatedVersionDir, builtBy: 'generateVersionProperties')
78 | }
79 | }
80 | spotless {
81 | java {
82 | googleJavaFormat()
83 | }
84 |
85 | groovyGradle {
86 | target '*.gradle'
87 | greclipse()
88 | }
89 | }
90 |
91 | jacocoTestReport {
92 | dependsOn test
93 | }
94 |
95 | task generateVersionProperties {
96 | doLast {
97 | def propertiesFile = file "$generatedVersionDir/version.properties"
98 | propertiesFile.parentFile.mkdirs()
99 | def properties = new Properties()
100 | properties.setProperty("version", rootProject.version.toString())
101 | propertiesFile.withWriter { properties.store(it, null) }
102 | }
103 | }
104 | processResources.dependsOn generateVersionProperties
105 |
106 | shadowJar {
107 | enableRelocation true
108 | relocationPrefix "shadowed"
109 | mergeServiceFiles()
110 | }
111 |
112 | apply from: "publish.gradle"
113 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GetStream/stream-chat-java/5c415dba32ea40e867ced2ac004dad057348b6a1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/local.properties.example:
--------------------------------------------------------------------------------
1 | ossrhUsername=
2 | ossrhPassword=
3 | signing.keyId=
4 | signing.password=
5 | signing.secretKeyRingFile=
6 | sonatypeStagingProfileId=
7 | io.getstream.chat.apiKey=
8 | io.getstream.chat.apiSecret=
9 | io.getstream.chat.url=https://chat.stream-io-api.com
10 | io.getstream.chat.timeout=10000
11 |
--------------------------------------------------------------------------------
/publish.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven-publish'
2 | apply plugin: 'signing'
3 |
4 | // Create variables with empty default values
5 | ext["ossrhUsername"] = ''
6 | ext["ossrhPassword"] = ''
7 | ext["signing.keyId"] = ''
8 | ext["signing.password"] = ''
9 | ext["signing.secretKeyRingFile"] = ''
10 | ext["sonatypeStagingProfileId"] = ''
11 |
12 | File secretPropsFile = project.rootProject.file('local.properties')
13 | if (secretPropsFile.exists()) {
14 | // Read local.properties file first if it exists
15 | Properties p = new Properties()
16 | new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
17 | p.each { name, value -> ext[name] = value }
18 | } else {
19 | // Use system environment variables
20 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
21 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
22 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
23 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
24 | ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
25 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
26 | }
27 |
28 | nexusPublishing {
29 | repositories {
30 | sonatype {
31 | stagingProfileId = sonatypeStagingProfileId
32 | username = ossrhUsername
33 | password = ossrhPassword
34 | }
35 | }
36 | }
37 |
38 | // to remove shadowed jar from the regular release publication
39 | components.java.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
40 | skip()
41 | }
42 |
43 | def configurePom(pom) {
44 | pom.with {
45 | name = "Stream Chat official Java API Client"
46 | description = "Stream Chat Java Client for backend integrations"
47 | url = 'https://github.com/getstream/stream-chat-java'
48 | licenses {
49 | license {
50 | name = 'Stream License'
51 | url = 'https://github.com/GetStream/stream-chat-java/blob/main/LICENSE'
52 | }
53 | }
54 | developers {
55 | developer {
56 | id = 'getstream-support'
57 | name = 'Stream Support'
58 | email = 'support@getstream.io'
59 | }
60 | }
61 | scm {
62 | connection = 'scm:git:github.com/getstream/stream-chat-java.git'
63 | developerConnection = 'scm:git:ssh://github.com/getstream/stream-chat-java.git'
64 | url = 'https://github.com/getstream/stream-chat-java/tree/main'
65 | }
66 | }
67 | }
68 |
69 | afterEvaluate {
70 | publishing {
71 | publications {
72 | release(MavenPublication) {
73 | from components.java
74 | artifactId 'stream-chat-java'
75 | configurePom(pom)
76 | }
77 |
78 | shadow(MavenPublication) { publication ->
79 | project.shadow.component(publication)
80 | artifactId 'stream-chat-java-all'
81 | artifact javadocJar
82 | artifact sourcesJar
83 | configurePom(pom)
84 | }
85 | }
86 | }
87 | }
88 |
89 | signing {
90 | sign publishing.publications
91 | }
92 |
93 | // Ensure that the publish tasks run after the sign tasks, otherwise gradle will complain
94 | tasks.matching { it.name.startsWith('publish') }.all { publishTask ->
95 | tasks.matching { it.name.startsWith('sign') }.all { signTask ->
96 | publishTask.mustRunAfter(signTask)
97 | }
98 | }
99 |
100 | javadoc {
101 | options.addBooleanOption('html5', true)
102 | }
103 |
--------------------------------------------------------------------------------
/scripts/get_changelog_diff.js:
--------------------------------------------------------------------------------
1 | /*
2 | Here we're trying to parse the latest changes from CHANGELOG.md file.
3 | The changelog looks like this:
4 |
5 | ## 0.0.3
6 | - Something #3
7 | ## 0.0.2
8 | - Something #2
9 | ## 0.0.1
10 | - Something #1
11 |
12 | In this case we're trying to extract "- Something #3" since that's the latest change.
13 | */
14 | module.exports = () => {
15 | const fs = require('fs')
16 |
17 | changelog = fs.readFileSync('CHANGELOG.md', 'utf8')
18 | releases = changelog.match(/## [?[0-9](.+)/g)
19 |
20 | current_release = changelog.indexOf(releases[0])
21 | previous_release = changelog.indexOf(releases[1])
22 |
23 | latest_changes = changelog.substr(current_release, previous_release - current_release)
24 |
25 | return latest_changes
26 | }
27 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file was generated by the Gradle 'init' task.
3 | */
4 |
5 | rootProject.name = 'stream-chat-java'
6 |
--------------------------------------------------------------------------------
/src/main/java/io/getstream/chat/java/exceptions/StreamException.java:
--------------------------------------------------------------------------------
1 | package io.getstream.chat.java.exceptions;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import com.fasterxml.jackson.core.JsonProcessingException;
5 | import com.fasterxml.jackson.databind.DeserializationFeature;
6 | import com.fasterxml.jackson.databind.ObjectMapper;
7 | import java.io.IOException;
8 | import java.util.Map;
9 | import lombok.Data;
10 | import lombok.Getter;
11 | import okhttp3.ResponseBody;
12 | import retrofit2.Response;
13 |
14 | public class StreamException extends Exception {
15 | private static final long serialVersionUID = 1L;
16 |
17 | @Getter private ResponseData responseData;
18 |
19 | public StreamException(String message, ResponseData responseData) {
20 | super(message);
21 | this.responseData = responseData;
22 | }
23 |
24 | public StreamException(String message, Throwable t) {
25 | super(message, t);
26 | }
27 |
28 | public StreamException(Throwable t) {
29 | super(t);
30 | }
31 |
32 | /**
33 | * Builds a StreamException to signal an issue
34 | *
35 | * @param issue the issue
36 | * @return the StreamException
37 | */
38 | public static StreamException build(String issue) {
39 | return new StreamException(issue, (Throwable) null);
40 | }
41 |
42 | /**
43 | * Builds a StreamException using the response body when Stream API request fails
44 | *
45 | * @param responseBody Stream API response body
46 | * @return the StreamException
47 | */
48 | @Deprecated
49 | public static StreamException build(ResponseBody responseBody) {
50 | ObjectMapper objectMapper = new ObjectMapper();
51 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
52 | try {
53 | String responseBodyString = responseBody.string();
54 | try {
55 | ResponseData responseData = objectMapper.readValue(responseBodyString, ResponseData.class);
56 | return new StreamException(responseData.getMessage(), responseData);
57 | } catch (JsonProcessingException e) {
58 | return new StreamException(responseBodyString, e);
59 | }
60 | } catch (IOException e) {
61 | return new StreamException(e);
62 | }
63 | }
64 |
65 | /**
66 | * Builds a StreamException based on response from the server and http code
67 | *
68 | * @param httpResponse Stream API response
69 | * @return the StreamException
70 | */
71 | public static StreamException build(Response> httpResponse) {
72 | StreamException exception;
73 |
74 | ResponseBody errorBody = httpResponse.errorBody();
75 | if (errorBody != null) {
76 | exception = StreamException.build(errorBody);
77 | } else {
78 | exception =
79 | StreamException.build(
80 | String.format("Unexpected server response code %d", httpResponse.code()));
81 | }
82 |
83 | if (exception.responseData == null) {
84 | ResponseData responseData = new ResponseData();
85 | responseData.statusCode = httpResponse.code();
86 | exception.responseData = responseData;
87 | }
88 |
89 | return exception;
90 | }
91 |
92 | /**
93 | * Builds a StreamException when an exception occurs calling the API
94 | *
95 | * @param t the underlying exception
96 | * @return the StreamException
97 | */
98 | public static StreamException build(Throwable t) {
99 | return new StreamException(t);
100 | }
101 |
102 | @Data
103 | public static class ResponseData {
104 | @JsonProperty("code")
105 | private Integer code;
106 |
107 | @JsonProperty("message")
108 | private String message;
109 |
110 | @JsonProperty("exception_fields")
111 | private Map exceptionFields;
112 |
113 | @JsonProperty("StatusCode")
114 | private Integer statusCode;
115 |
116 | @JsonProperty("duration")
117 | private String duration;
118 |
119 | @JsonProperty("more_info")
120 | private String moreInfo;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/src/main/java/io/getstream/chat/java/models/BlockUser.java:
--------------------------------------------------------------------------------
1 | package io.getstream.chat.java.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import io.getstream.chat.java.models.framework.StreamRequest;
5 | import io.getstream.chat.java.models.framework.StreamResponseObject;
6 | import io.getstream.chat.java.services.BlockUserService;
7 | import io.getstream.chat.java.services.framework.Client;
8 | import java.util.Date;
9 | import java.util.List;
10 | import lombok.*;
11 | import org.jetbrains.annotations.NotNull;
12 | import retrofit2.Call;
13 |
14 | @Data
15 | @NoArgsConstructor
16 | public class BlockUser {
17 |
18 | @Builder(
19 | builderClassName = "BlockUserRequest",
20 | builderMethodName = "",
21 | buildMethodName = "internalBuild")
22 | public static class BlockUserRequestData {
23 | @NotNull
24 | @JsonProperty("blocked_user_id")
25 | private String blockedUserID;
26 |
27 | @NotNull
28 | @JsonProperty("user_id")
29 | private String userID;
30 |
31 | public static class BlockUserRequest extends StreamRequest {
32 | @Override
33 | protected Call generateCall(Client client) {
34 | var data = this.internalBuild();
35 | return client.create(BlockUserService.class).blockUser(data);
36 | }
37 | }
38 | }
39 |
40 | @Builder(
41 | builderClassName = "UnblockUserRequest",
42 | builderMethodName = "",
43 | buildMethodName = "internalBuild")
44 | public static class UnblockUserRequestData {
45 | @NotNull
46 | @JsonProperty("blocked_user_id")
47 | private String blockedUserID;
48 |
49 | @NotNull
50 | @JsonProperty("user_id")
51 | private String userID;
52 |
53 | public static class UnblockUserRequest extends StreamRequest {
54 | @Override
55 | protected Call generateCall(Client client) {
56 | var data = this.internalBuild();
57 | return client.create(BlockUserService.class).unblockUser(data);
58 | }
59 | }
60 | }
61 |
62 | @NotNull
63 | public static BlockUserRequestData.BlockUserRequest blockUser() {
64 | return new BlockUserRequestData.BlockUserRequest();
65 | }
66 |
67 | @NotNull
68 | public static UnblockUserRequestData.UnblockUserRequest unblockUser() {
69 | return new UnblockUserRequestData.UnblockUserRequest();
70 | }
71 |
72 | @Data
73 | @EqualsAndHashCode(callSuper = true)
74 | @NoArgsConstructor
75 | public static class BlockUserResponse extends StreamResponseObject {
76 | @JsonProperty("blocked_by_user_id")
77 | private String blockedByUserID;
78 |
79 | @JsonProperty("blocked_user_id")
80 | private String blockedUserID;
81 |
82 | @JsonProperty("created_at")
83 | private Date createdAt;
84 | }
85 |
86 | @Data
87 | @EqualsAndHashCode(callSuper = true)
88 | @NoArgsConstructor
89 | public static class UnblockUserResponse extends StreamResponseObject {}
90 |
91 | @Data
92 | @EqualsAndHashCode(callSuper = true)
93 | @NoArgsConstructor
94 | public static class GetBlockedUsersResponse extends StreamResponseObject {
95 | @JsonProperty("blocks")
96 | private List blockedUsers;
97 | }
98 |
99 | @Data
100 | @NoArgsConstructor
101 | public static class BlockedUserResponse {
102 | @JsonProperty("user")
103 | private User blockedByUser;
104 |
105 | @JsonProperty("user_id")
106 | private String blockedByUserID;
107 |
108 | @JsonProperty("blocked_user")
109 | private User blockedUser;
110 |
111 | @JsonProperty("blocked_user_id")
112 | private String blockedUserID;
113 |
114 | @JsonProperty("created_at")
115 | private Date createdAt;
116 | }
117 |
118 | @Builder(
119 | builderClassName = "GetBlockedUsersRequest",
120 | builderMethodName = "",
121 | buildMethodName = "internalBuild")
122 | public static class GetBlockedUsersRequestData {
123 | @NotNull
124 | @JsonProperty("user_id")
125 | private String blockedByUserID;
126 |
127 | public static class GetBlockedUsersRequest extends StreamRequest {
128 | private String blockedByUserID;
129 |
130 | public GetBlockedUsersRequest(String blockedByUserID) {
131 | this.blockedByUserID = blockedByUserID;
132 | }
133 |
134 | @Override
135 | protected Call generateCall(Client client) {
136 | return client.create(BlockUserService.class).getBlockedUsers(blockedByUserID);
137 | }
138 | }
139 | }
140 |
141 | @NotNull
142 | public static GetBlockedUsersRequestData.GetBlockedUsersRequest getBlockedUsers(
143 | String blockedByUserID) {
144 | return new GetBlockedUsersRequestData.GetBlockedUsersRequest(blockedByUserID);
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/src/main/java/io/getstream/chat/java/models/Blocklist.java:
--------------------------------------------------------------------------------
1 | package io.getstream.chat.java.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import io.getstream.chat.java.models.Blocklist.BlocklistCreateRequestData.BlocklistCreateRequest;
5 | import io.getstream.chat.java.models.Blocklist.BlocklistUpdateRequestData.BlocklistUpdateRequest;
6 | import io.getstream.chat.java.models.framework.StreamRequest;
7 | import io.getstream.chat.java.models.framework.StreamResponseObject;
8 | import io.getstream.chat.java.services.BlocklistService;
9 | import io.getstream.chat.java.services.framework.Client;
10 | import java.util.Date;
11 | import java.util.List;
12 | import lombok.*;
13 | import org.jetbrains.annotations.NotNull;
14 | import org.jetbrains.annotations.Nullable;
15 | import retrofit2.Call;
16 |
17 | @Data
18 | @NoArgsConstructor
19 | public class Blocklist {
20 | @NotNull
21 | @JsonProperty("created_at")
22 | private Date createdAt;
23 |
24 | @NotNull
25 | @JsonProperty("updated_at")
26 | private Date updatedAt;
27 |
28 | @NotNull
29 | @JsonProperty("name")
30 | private String name;
31 |
32 | @NotNull
33 | @JsonProperty("words")
34 | private List words;
35 |
36 | @Builder(
37 | builderClassName = "BlocklistCreateRequest",
38 | builderMethodName = "",
39 | buildMethodName = "internalBuild")
40 | public static class BlocklistCreateRequestData {
41 | @Nullable
42 | @JsonProperty("name")
43 | private String name;
44 |
45 | @Nullable
46 | @JsonProperty("words")
47 | private List words;
48 |
49 | public static class BlocklistCreateRequest extends StreamRequest {
50 | @Override
51 | protected Call generateCall(Client client) {
52 | return client.create(BlocklistService.class).create(this.internalBuild());
53 | }
54 | }
55 | }
56 |
57 | @RequiredArgsConstructor
58 | public static class BlocklistGetRequest extends StreamRequest {
59 | @NotNull private String name;
60 |
61 | @Override
62 | protected Call generateCall(Client client) {
63 | return client.create(BlocklistService.class).get(name);
64 | }
65 | }
66 |
67 | @Builder(
68 | builderClassName = "BlocklistUpdateRequest",
69 | builderMethodName = "",
70 | buildMethodName = "internalBuild")
71 | public static class BlocklistUpdateRequestData {
72 | @Nullable
73 | @JsonProperty("words")
74 | private List words;
75 |
76 | public static class BlocklistUpdateRequest extends StreamRequest {
77 | @NotNull private String name;
78 |
79 | private BlocklistUpdateRequest(@NotNull String name) {
80 | this.name = name;
81 | }
82 |
83 | @Override
84 | protected Call generateCall(Client client) {
85 | return client.create(BlocklistService.class).update(name, this.internalBuild());
86 | }
87 | }
88 | }
89 |
90 | @RequiredArgsConstructor
91 | public static class BlocklistDeleteRequest extends StreamRequest {
92 | @NotNull private String name;
93 |
94 | @Override
95 | protected Call generateCall(Client client) {
96 | return client.create(BlocklistService.class).delete(name);
97 | }
98 | }
99 |
100 | public static class BlocklistListRequest extends StreamRequest {
101 | @Override
102 | protected Call generateCall(Client client) {
103 | return client.create(BlocklistService.class).list();
104 | }
105 | }
106 |
107 | @Data
108 | @NoArgsConstructor
109 | @EqualsAndHashCode(callSuper = true)
110 | public static class BlocklistGetResponse extends StreamResponseObject {
111 | @NotNull
112 | @JsonProperty("blocklist")
113 | private Blocklist blocklist;
114 | }
115 |
116 | @Data
117 | @NoArgsConstructor
118 | @EqualsAndHashCode(callSuper = true)
119 | public static class BlocklistListResponse extends StreamResponseObject {
120 | @NotNull
121 | @JsonProperty("blocklists")
122 | private List blocklists;
123 | }
124 |
125 | /**
126 | * Creates a create request
127 | *
128 | * @return the created request
129 | */
130 | @NotNull
131 | public static BlocklistCreateRequest create() {
132 | return new BlocklistCreateRequest();
133 | }
134 |
135 | /**
136 | * Creates a get request
137 | *
138 | * @param name the blocklist name
139 | * @return the created request
140 | */
141 | @NotNull
142 | public static BlocklistGetRequest get(@NotNull String name) {
143 | return new BlocklistGetRequest(name);
144 | }
145 |
146 | /**
147 | * Creates an update request
148 | *
149 | * @param name the blocklist name
150 | * @return the created request
151 | */
152 | @NotNull
153 | public static BlocklistUpdateRequest update(@NotNull String name) {
154 | return new BlocklistUpdateRequest(name);
155 | }
156 |
157 | /**
158 | * Creates a delete request
159 | *
160 | * @param name the blocklist name
161 | * @return the created request
162 | */
163 | @NotNull
164 | public static BlocklistDeleteRequest delete(@NotNull String name) {
165 | return new BlocklistDeleteRequest(name);
166 | }
167 |
168 | /**
169 | * Creates a list request
170 | *
171 | * @return the created request
172 | */
173 | @NotNull
174 | public static BlocklistListRequest list() {
175 | return new BlocklistListRequest();
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/src/main/java/io/getstream/chat/java/models/Command.java:
--------------------------------------------------------------------------------
1 | package io.getstream.chat.java.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import io.getstream.chat.java.models.Command.CommandCreateRequestData.CommandCreateRequest;
5 | import io.getstream.chat.java.models.Command.CommandUpdateRequestData.CommandUpdateRequest;
6 | import io.getstream.chat.java.models.framework.StreamRequest;
7 | import io.getstream.chat.java.models.framework.StreamResponse;
8 | import io.getstream.chat.java.models.framework.StreamResponseObject;
9 | import io.getstream.chat.java.services.CommandService;
10 | import io.getstream.chat.java.services.framework.Client;
11 | import java.util.Date;
12 | import java.util.List;
13 | import lombok.*;
14 | import org.jetbrains.annotations.NotNull;
15 | import org.jetbrains.annotations.Nullable;
16 | import retrofit2.Call;
17 |
18 | @Data
19 | @NoArgsConstructor
20 | public class Command {
21 | @NotNull
22 | @JsonProperty("created_at")
23 | private Date createdAt;
24 |
25 | @NotNull
26 | @JsonProperty("updated_at")
27 | private Date updatedAt;
28 |
29 | @NotNull
30 | @JsonProperty("name")
31 | private String name;
32 |
33 | @NotNull
34 | @JsonProperty("description")
35 | private String description;
36 |
37 | @Nullable
38 | @JsonProperty("args")
39 | private String args;
40 |
41 | @Nullable
42 | @JsonProperty("set")
43 | private String setValue;
44 |
45 | @Builder(
46 | builderClassName = "CommandCreateRequest",
47 | builderMethodName = "",
48 | buildMethodName = "internalBuild")
49 | public static class CommandCreateRequestData {
50 | @Nullable
51 | @JsonProperty("name")
52 | private String name;
53 |
54 | @Nullable
55 | @JsonProperty("description")
56 | private String description;
57 |
58 | @Nullable
59 | @JsonProperty("args")
60 | private String args;
61 |
62 | @Nullable
63 | @JsonProperty("set")
64 | private String setValue;
65 |
66 | public static class CommandCreateRequest extends StreamRequest {
67 | @Override
68 | protected Call generateCall(Client client) {
69 | return client.create(CommandService.class).create(this.internalBuild());
70 | }
71 | }
72 | }
73 |
74 | @RequiredArgsConstructor
75 | public static class CommandGetRequest extends StreamRequest {
76 | @NotNull private String name;
77 |
78 | @Override
79 | protected Call generateCall(Client client) {
80 | return client.create(CommandService.class).get(name);
81 | }
82 | }
83 |
84 | @Builder(
85 | builderClassName = "CommandUpdateRequest",
86 | builderMethodName = "",
87 | buildMethodName = "internalBuild")
88 | public static class CommandUpdateRequestData {
89 | @Nullable
90 | @JsonProperty("description")
91 | private String description;
92 |
93 | @Nullable
94 | @JsonProperty("args")
95 | private String args;
96 |
97 | @Nullable
98 | @JsonProperty("set")
99 | private String setValue;
100 |
101 | public static class CommandUpdateRequest extends StreamRequest {
102 | @NotNull private String name;
103 |
104 | private CommandUpdateRequest(@NotNull String name) {
105 | this.name = name;
106 | }
107 |
108 | @Override
109 | protected Call generateCall(Client client) {
110 | return client.create(CommandService.class).update(name, this.internalBuild());
111 | }
112 | }
113 | }
114 |
115 | @RequiredArgsConstructor
116 | public static class CommandDeleteRequest extends StreamRequest {
117 | @NotNull private String name;
118 |
119 | @Override
120 | protected Call generateCall(Client client) {
121 | return client.create(CommandService.class).delete(name);
122 | }
123 | }
124 |
125 | public static class CommandListRequest extends StreamRequest {
126 | @Override
127 | protected Call generateCall(Client client) {
128 | return client.create(CommandService.class).list();
129 | }
130 | }
131 |
132 | @Data
133 | @NoArgsConstructor
134 | @EqualsAndHashCode(callSuper = true)
135 | public static class CommandCreateResponse extends StreamResponseObject {
136 | @NotNull
137 | @JsonProperty("command")
138 | private Command command;
139 | }
140 |
141 | @Data
142 | @NoArgsConstructor
143 | @EqualsAndHashCode(callSuper = true)
144 | public static class CommandGetResponse extends Command implements StreamResponse {
145 | private RateLimit rateLimit;
146 |
147 | @NotNull
148 | @JsonProperty("duration")
149 | private String duration;
150 | }
151 |
152 | @Data
153 | @NoArgsConstructor
154 | @EqualsAndHashCode(callSuper = true)
155 | public static class CommandUpdateResponse extends StreamResponseObject {
156 | @NotNull
157 | @JsonProperty("command")
158 | private Command command;
159 | }
160 |
161 | @Data
162 | @NoArgsConstructor
163 | @EqualsAndHashCode(callSuper = true)
164 | public static class CommandDeleteResponse extends StreamResponseObject {
165 | @NotNull
166 | @JsonProperty("name")
167 | private String name;
168 | }
169 |
170 | @Data
171 | @NoArgsConstructor
172 | @EqualsAndHashCode(callSuper = true)
173 | public static class CommandListResponse extends StreamResponseObject {
174 | @NotNull
175 | @JsonProperty("commands")
176 | private List commands;
177 | }
178 |
179 | /**
180 | * Creates a create request
181 | *
182 | * @return the created request
183 | */
184 | @NotNull
185 | public static CommandCreateRequest create() {
186 | return new CommandCreateRequest();
187 | }
188 |
189 | /**
190 | * Creates a get request
191 | *
192 | * @param name the command name
193 | * @return the created request
194 | */
195 | @NotNull
196 | public static CommandGetRequest get(@NotNull String name) {
197 | return new CommandGetRequest(name);
198 | }
199 |
200 | /**
201 | * Creates an update request
202 | *
203 | * @param name the command name
204 | * @return the created request
205 | */
206 | @NotNull
207 | public static CommandUpdateRequest update(@NotNull String name) {
208 | return new CommandUpdateRequest(name);
209 | }
210 |
211 | /**
212 | * Creates a delete request
213 | *
214 | * @param name the command name
215 | * @return the created request
216 | */
217 | @NotNull
218 | public static CommandDeleteRequest delete(@NotNull String name) {
219 | return new CommandDeleteRequest(name);
220 | }
221 |
222 | /**
223 | * Creates a list request
224 | *
225 | * @return the created request
226 | */
227 | @NotNull
228 | public static CommandListRequest list() {
229 | return new CommandListRequest();
230 | }
231 | }
232 |
--------------------------------------------------------------------------------
/src/main/java/io/getstream/chat/java/models/DeleteStrategy.java:
--------------------------------------------------------------------------------
1 | package io.getstream.chat.java.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 |
5 | public enum DeleteStrategy {
6 | @JsonProperty("soft")
7 | SOFT,
8 | @JsonProperty("hard")
9 | HARD
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/io/getstream/chat/java/models/Device.java:
--------------------------------------------------------------------------------
1 | package io.getstream.chat.java.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import io.getstream.chat.java.models.App.PushProviderType;
5 | import io.getstream.chat.java.models.Device.DeviceCreateRequestData.DeviceCreateRequest;
6 | import io.getstream.chat.java.models.User.UserRequestObject;
7 | import io.getstream.chat.java.models.framework.RequestObjectBuilder;
8 | import io.getstream.chat.java.models.framework.StreamRequest;
9 | import io.getstream.chat.java.models.framework.StreamResponseObject;
10 | import io.getstream.chat.java.services.DeviceService;
11 | import io.getstream.chat.java.services.framework.Client;
12 | import java.util.Date;
13 | import java.util.List;
14 | import lombok.*;
15 | import org.jetbrains.annotations.NotNull;
16 | import org.jetbrains.annotations.Nullable;
17 | import retrofit2.Call;
18 |
19 | @Data
20 | @NoArgsConstructor
21 | public class Device {
22 | @Nullable
23 | @JsonProperty("push_provider")
24 | private PushProviderType pushProvider;
25 |
26 | @NotNull
27 | @JsonProperty("id")
28 | private String id;
29 |
30 | @Nullable
31 | @JsonProperty("push_provider_name")
32 | private String pushProviderName;
33 |
34 | @NotNull
35 | @JsonProperty("created_at")
36 | private Date createdAt;
37 |
38 | @Nullable
39 | @JsonProperty("disabled")
40 | private Boolean disabled;
41 |
42 | @Nullable
43 | @JsonProperty("disabled_reason")
44 | private String disabledReason;
45 |
46 | @NotNull
47 | @JsonProperty("user_id")
48 | private String userId;
49 |
50 | @Builder
51 | @Setter
52 | public static class DeviceRequestObject {
53 | @Nullable
54 | @JsonProperty("push_provider")
55 | private PushProviderType pushProvider;
56 |
57 | @Nullable
58 | @JsonProperty("id")
59 | private String id;
60 |
61 | @Nullable
62 | @JsonProperty("push_provider_name")
63 | private String pushProviderName;
64 |
65 | @Nullable
66 | @JsonProperty("created_at")
67 | private Date createdAt;
68 |
69 | @Nullable
70 | @JsonProperty("disabled")
71 | private Boolean disabled;
72 |
73 | @Nullable
74 | @JsonProperty("disabled_reason")
75 | private String disabledReason;
76 |
77 | @Nullable
78 | @JsonProperty("user_id")
79 | private String userId;
80 |
81 | @Nullable
82 | public static DeviceRequestObject buildFrom(@Nullable Device device) {
83 | return RequestObjectBuilder.build(DeviceRequestObject.class, device);
84 | }
85 | }
86 |
87 | @Builder(
88 | builderClassName = "DeviceCreateRequest",
89 | builderMethodName = "",
90 | buildMethodName = "internalBuild")
91 | public static class DeviceCreateRequestData {
92 | @Nullable
93 | @JsonProperty("push_provider")
94 | private PushProviderType pushProvider;
95 |
96 | @Nullable
97 | @JsonProperty("id")
98 | private String id;
99 |
100 | @Nullable
101 | @JsonProperty("push_provider_name")
102 | private String pushProviderName;
103 |
104 | @Nullable
105 | @JsonProperty("user_id")
106 | private String userId;
107 |
108 | @Nullable
109 | @JsonProperty("user")
110 | private UserRequestObject user;
111 |
112 | public static class DeviceCreateRequest extends StreamRequest {
113 | @Override
114 | protected Call generateCall(Client client) {
115 | return client.create(DeviceService.class).create(this.internalBuild());
116 | }
117 | }
118 | }
119 |
120 | @RequiredArgsConstructor
121 | public static class DeviceDeleteRequest extends StreamRequest {
122 | @NotNull private String id;
123 |
124 | @NotNull private String userId;
125 |
126 | @NotNull
127 | public DeviceDeleteRequest id(@NotNull String id) {
128 | this.id = id;
129 | return this;
130 | }
131 |
132 | @NotNull
133 | public DeviceDeleteRequest userId(@NotNull String userId) {
134 | this.userId = userId;
135 | return this;
136 | }
137 |
138 | @Override
139 | protected Call generateCall(Client client) {
140 | return client.create(DeviceService.class).delete(id, userId);
141 | }
142 | }
143 |
144 | @RequiredArgsConstructor
145 | public static class DeviceListRequest extends StreamRequest {
146 | @NotNull private String userId;
147 |
148 | @Override
149 | protected Call generateCall(Client client) {
150 | return client.create(DeviceService.class).list(userId);
151 | }
152 | }
153 |
154 | @Data
155 | @NoArgsConstructor
156 | @EqualsAndHashCode(callSuper = true)
157 | public static class DeviceListResponse extends StreamResponseObject {
158 | @NotNull
159 | @JsonProperty("devices")
160 | private List devices;
161 | }
162 |
163 | /**
164 | * Creates a create request
165 | *
166 | * @return the created request
167 | */
168 | @NotNull
169 | public static DeviceCreateRequest create() {
170 | return new DeviceCreateRequest();
171 | }
172 |
173 | /**
174 | * Creates a delete request
175 | *
176 | * @param id the device id
177 | * @param userId the user id
178 | * @return the created request
179 | */
180 | @NotNull
181 | public static DeviceDeleteRequest delete(@NotNull String id, @NotNull String userId) {
182 | return new DeviceDeleteRequest(id, userId);
183 | }
184 |
185 | /**
186 | * Creates a list request
187 | *
188 | * @param userId the user id
189 | * @return the created request
190 | */
191 | @NotNull
192 | public static DeviceListRequest list(@NotNull String userId) {
193 | return new DeviceListRequest(userId);
194 | }
195 | }
196 |
--------------------------------------------------------------------------------
/src/main/java/io/getstream/chat/java/models/ExportUsers.java:
--------------------------------------------------------------------------------
1 | package io.getstream.chat.java.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import io.getstream.chat.java.models.framework.StreamRequest;
5 | import io.getstream.chat.java.models.framework.StreamResponseObject;
6 | import io.getstream.chat.java.services.ExportUsersService;
7 | import io.getstream.chat.java.services.framework.Client;
8 | import java.util.List;
9 | import lombok.Builder;
10 | import lombok.Data;
11 | import lombok.EqualsAndHashCode;
12 | import lombok.NoArgsConstructor;
13 | import org.jetbrains.annotations.NotNull;
14 | import retrofit2.Call;
15 |
16 | @Data
17 | @NoArgsConstructor
18 | public class ExportUsers {
19 |
20 | @Builder(
21 | builderClassName = "ExportUsersRequest",
22 | builderMethodName = "",
23 | buildMethodName = "internalBuild")
24 | public static class ExportUsersRequestData {
25 | @JsonProperty("user_ids")
26 | private List userIds;
27 |
28 | public static class ExportUsersRequest extends StreamRequest {
29 | @Override
30 | protected Call generateCall(Client client) {
31 | return client.create(ExportUsersService.class).exportUsers(this.internalBuild());
32 | }
33 | }
34 | }
35 |
36 | @Data
37 | @NoArgsConstructor
38 | @EqualsAndHashCode(callSuper = true)
39 | public static class ExportUsersResponse extends StreamResponseObject {
40 | @NotNull
41 | @JsonProperty("task_id")
42 | private String taskId;
43 | }
44 |
45 | /**
46 | * Creates a export users request
47 | *
48 | * @param userIds list of user IDs to be exported
49 | * @return the created request
50 | */
51 | @NotNull
52 | public static ExportUsers.ExportUsersRequestData.ExportUsersRequest exportUsers(
53 | @NotNull List userIds) {
54 | return new ExportUsers.ExportUsersRequestData.ExportUsersRequest().userIds(userIds);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/io/getstream/chat/java/models/FilterCondition.java:
--------------------------------------------------------------------------------
1 | package io.getstream.chat.java.models;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collection;
5 | import java.util.Collections;
6 | import java.util.HashMap;
7 | import java.util.Map;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class FilterCondition {
11 | @SafeVarargs
12 | public static Map and(@NotNull Map... filters) {
13 | return Collections.singletonMap("$and", Arrays.asList(filters));
14 | }
15 |
16 | @SafeVarargs
17 | public static Map or(@NotNull Map... filters) {
18 | return Collections.singletonMap("$or", Arrays.asList(filters));
19 | }
20 |
21 | @SafeVarargs
22 | public static Map nor(@NotNull Map... filters) {
23 | return Collections.singletonMap("$nor", Arrays.asList(filters));
24 | }
25 |
26 | public static Map autocomplete(
27 | @NotNull String fieldName, @NotNull String inputString) {
28 | return Collections.singletonMap(
29 | fieldName, Collections.singletonMap("$autocomplete", inputString));
30 | }
31 |
32 | public static Map contains(
33 | @NotNull String fieldName, @NotNull String inputString) {
34 | return Collections.singletonMap(fieldName, Collections.singletonMap("$contains", inputString));
35 | }
36 |
37 | public static Map eq(@NotNull String fieldName, @NotNull Object fieldValue) {
38 | return Collections.singletonMap(fieldName, Collections.singletonMap("$eq", fieldValue));
39 | }
40 |
41 | public static Map greaterThan(
42 | @NotNull String fieldName, @NotNull Object fieldValue) {
43 | return Collections.singletonMap(fieldName, Collections.singletonMap("$gt", fieldValue));
44 | }
45 |
46 | public static Map greaterThanEquals(
47 | @NotNull String fieldName, @NotNull Object fieldValue) {
48 | return Collections.singletonMap(fieldName, Collections.singletonMap("$gte", fieldValue));
49 | }
50 |
51 | public static Map lessThan(
52 | @NotNull String fieldName, @NotNull Object fieldValue) {
53 | return Collections.singletonMap(fieldName, Collections.singletonMap("$lt", fieldValue));
54 | }
55 |
56 | public static Map lessThanEquals(
57 | @NotNull String fieldName, @NotNull Object fieldValue) {
58 | return Collections.singletonMap(fieldName, Collections.singletonMap("$lte", fieldValue));
59 | }
60 |
61 | public static Map ne(@NotNull String fieldName, @NotNull Object fieldValue) {
62 | return Collections.singletonMap(fieldName, Collections.singletonMap("$ne", fieldValue));
63 | }
64 |
65 | public static Map in(
66 | @NotNull String fieldName, @NotNull Collection