Skip to content

Commit bc00988

Browse files
authored
Merge pull request #1 from reloop-labs/cursor/v2
Rewrite Java SDK for Node parity at 2.0.0.
2 parents 1dec8ed + 74e782f commit bc00988

50 files changed

Lines changed: 4812 additions & 933 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
## 2.0.0
4+
5+
Breaking rewrite for Node SDK parity (version aligned with Node/Python/Go `2.0.0`):
6+
7+
- Typed params/responses (Jackson POJOs) instead of untyped maps for mail/contacts
8+
- `ReloopValidationException` for invalid client input (no HTTP); `ReloopApiException` for HTTP/network
9+
- Facade: `client.apiKey` (was `apiKeys`), `mail`, `domain`, `contacts`, `webhook`, `inbox`
10+
- Typed Contacts with nested `properties`, `groups`, `channels`
11+
- Full Webhook CRUD + pause/enable/disable/trigger/deliveries + local HMAC `WebhookVerify`
12+
- Full Inbox: `mailboxes`, `messages`, `threads`
13+
- Removed: API key `pause`, domain `getNameservers` / `forwardDns`
14+
- Paths aligned with Node (`/api/mail/v1/send`, `/api/api-key/v1/`, `/api/domain/v1/`, …)
15+
- JUnit 5 + JDK `HttpServer` tests with surface locks
16+
17+
## 0.1.0
18+
19+
Initial thin client for mail, domain, API keys, and map-based contacts.

‎CONTRIBUTING.md‎

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Contributing to the Reloop Java SDK
22

3-
Maven artifact: **`sh.reloop:reloop-java`**.
3+
Maven artifact: **`sh.reloop:reloop-java`** (version aligned with Node/Python/Go at **2.0.0**).
44

55
**License:** [Apache License 2.0](./LICENSE) with additional use restrictions from Reloop Labs.
66

77
**API reference:** [reloop.sh/docs](https://reloop.sh/docs)
88

9-
Port new endpoints from the [Node.js SDK](https://github.com/reloop-labs/reloop-node) reference.
9+
Port new endpoints from the [Node.js SDK](https://github.com/reloop-labs/reloop-node) — Node wins on paths, bodies, and validation messages.
1010

1111
---
1212

@@ -15,10 +15,10 @@ Port new endpoints from the [Node.js SDK](https://github.com/reloop-labs/reloop-
1515
```bash
1616
git clone git@github.com:reloop-labs/reloop-java.git
1717
cd reloop-java
18-
mvn verify
18+
mvn test
1919
```
2020

21-
Requires **JDK 17+**.
21+
Requires **JDK 17+**. Runtime deps: Jackson only (plus JDK `HttpClient`).
2222

2323
---
2424

@@ -27,11 +27,15 @@ Requires **JDK 17+**.
2727
```
2828
src/main/java/sh/reloop/
2929
ReloopClient.java
30-
services/ # MailService, DomainService, …
31-
models/Models.java # Records with @JsonProperty
30+
Version.java
31+
exceptions/ # ReloopValidationException, ReloopApiException, WebhookSignatureException
32+
validation/ # Validators
33+
models/ # Mail, ApiKey, Domain, Contact, Webhook, Inbox POJOs
34+
services/ # Mail, ApiKey, Domain, Contacts*, Webhook*, Inbox*
3235
src/test/java/sh/reloop/
33-
services/ # Route tests (RecordingReloopClient)
34-
pom.xml # version
36+
test/TestHttpServer.java
37+
*Test.java # HttpServer route + surface-lock tests
38+
pom.xml # version 2.0.0
3539
```
3640

3741
---
@@ -40,31 +44,24 @@ pom.xml # version
4044

4145
| Topic | Rule |
4246
|-------|------|
43-
| Domain params | Records with `@JsonProperty("snake_case")` |
44-
| Mail send | `Map<String, Object>` with snake_case keys |
45-
| Contacts | `RequestParameters.forRequest()` for camelCase |
46-
| Tests | `RecordingReloopClient`; assert method, path, body type |
47+
| Errors | `ReloopValidationException` (no HTTP) / `ReloopApiException` (HTTP/network) |
48+
| Wire JSON | Match Node (`@JsonProperty` for snake_case vs camelCase) |
49+
| Validation | Fail before HTTP; tests assert **0** requests |
50+
| Tests | JDK `HttpServer`: method, path, `x-api-key`, body; surface-lock method sets |
51+
| Endpoints | Do not invent — copy from Node `paths.ts` |
52+
| Version | Same semver as Node/Python/Go |
4753

4854
---
4955

5056
## Pull request checklist
5157

52-
- [ ] `mvn verify` passes
53-
- [ ] Version in `pom.xml` bumped only for releases
58+
- [ ] `mvn test` passes
59+
- [ ] New ops have happy path + API error + validation (0 HTTP) + surface test
60+
- [ ] `pom.xml` / `Version.VERSION` updated only when releasing
5461

5562
---
5663

5764
## Releasing
5865

59-
Version: **`pom.xml`** → `<version>`.
60-
61-
```bash
62-
git commit -am "chore: release v1.9.0"
63-
git push origin main
64-
git tag v1.9.0
65-
git push origin v1.9.0
66-
```
67-
68-
[`.github/workflows/release.yml`](./.github/workflows/release.yml) attaches source zip + JARs to GitHub Releases.
69-
70-
Publish: [`.github/workflows/publish.yml`](./.github/workflows/publish.yml) (GitHub Packages).
66+
1. Set `pom.xml` `<version>` and `Version.VERSION` to the same value (match other SDKs)
67+
2. Tag and publish via existing GitHub Actions / Central publishing plugins

‎README.md‎

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,85 @@
11
# Reloop Java SDK
22

3-
## Before you send
3+
Official Java client for the [Reloop](https://reloop.sh) API.
44

5-
You need two things:
5+
## Before you send
66

77
1. **API key** — create one in your Reloop account
88
2. **Verified domain** — add and verify a sending domain; use it in the `from` address
99

10-
For setup details and the full API reference, see [reloop.sh/docs](https://reloop.sh/docs).
10+
Full API reference: [reloop.sh/docs](https://reloop.sh/docs)
1111

12-
## Send email
12+
## Install
1313

1414
```xml
1515
<dependency>
1616
<groupId>sh.reloop</groupId>
1717
<artifactId>reloop-java</artifactId>
18-
<version>0.1.0</version>
18+
<version>2.0.0</version>
1919
</dependency>
2020
```
2121

22+
## Quick start
23+
2224
```java
2325
import sh.reloop.ReloopClient;
24-
import sh.reloop.models.Models.SendMailResponse;
26+
import sh.reloop.exceptions.ReloopApiException;
27+
import sh.reloop.exceptions.ReloopValidationException;
28+
import sh.reloop.models.MailModels.SendMailParams;
29+
import sh.reloop.models.MailModels.SendMailResponse;
2530

26-
import java.util.HashMap;
27-
import java.util.Map;
31+
public class Example {
32+
public static void main(String[] args) {
33+
ReloopClient client = new ReloopClient("rl_your_api_key_here");
2834

29-
ReloopClient reloop = new ReloopClient("rl_your_api_key_here");
35+
SendMailParams params = new SendMailParams();
36+
params.from = "Reloop <hello@your-verified-domain.com>";
37+
params.to = "user@example.com";
38+
params.subject = "Welcome to Reloop";
39+
params.html = "<p>Thanks for signing up.</p>";
40+
params.text = "Thanks for signing up.";
3041

31-
Map<String, Object> params = new HashMap<>();
32-
params.put("from", "Reloop <hello@your-verified-domain.com>");
33-
params.put("to", "user@example.com");
34-
params.put("subject", "Welcome to Reloop");
35-
params.put("html", "<p>Thanks for signing up.</p>");
36-
params.put("text", "Thanks for signing up.");
42+
try {
43+
SendMailResponse result = client.mail.send(params);
44+
System.out.println(result.messageId + " " + result.id);
45+
} catch (ReloopValidationException e) {
46+
System.err.println("invalid request (" + e.getField() + "): " + e.getMessage());
47+
} catch (ReloopApiException e) {
48+
System.err.println("API error " + e.getStatus() + ": " + e.getMessage());
49+
}
50+
}
51+
}
52+
```
3753

38-
SendMailResponse result = reloop.mail.send(params);
54+
## Services
3955

40-
System.out.println(result.messageId() + " " + result.id());
56+
```java
57+
client.apiKey; // create, list, get, update, delete, rotate, enable, disable
58+
client.mail; // send
59+
client.domain; // create, list, get, update, delete, verify
60+
client.contacts; // CRUD + .properties, .groups, .channels
61+
client.webhook; // CRUD, pause/enable/disable, trigger, deliveries + verify
62+
client.inbox; // .mailboxes, .messages, .threads
4163
```
4264

43-
More examples and optional fields: [reloop.sh/docs](https://reloop.sh/docs)
65+
## Errors
66+
67+
| Kind | Type | When |
68+
|------|------|------|
69+
| Bad client args | `ReloopValidationException` | Invalid params — **no HTTP call** |
70+
| HTTP / network | `ReloopApiException` | Non-2xx response or transport failure |
71+
| Webhook HMAC | `WebhookSignatureException` | Local signature verification failed |
72+
73+
Idiomatic Java exceptions — the Java equivalent of Node/Python Result objects and Go `(T, error)`.
74+
75+
## Webhook verification
76+
77+
```java
78+
import sh.reloop.services.WebhookVerify;
79+
80+
var event = WebhookVerify.constructEvent(payload, signature, secret, 300);
81+
// or client.webhook.verify(params)
82+
```
4483

4584
## License
4685

‎pom.xml‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>sh.reloop</groupId>
88
<artifactId>reloop-java</artifactId>
9-
<version>0.1.0</version>
9+
<version>2.0.0</version>
1010

1111
<name>reloop-java</name>
1212
<description>Java SDK for Reloop</description>
@@ -69,6 +69,15 @@
6969
<artifactId>maven-surefire-plugin</artifactId>
7070
<version>3.2.5</version>
7171
</plugin>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-compiler-plugin</artifactId>
75+
<version>3.11.0</version>
76+
<configuration>
77+
<source>17</source>
78+
<target>17</target>
79+
</configuration>
80+
</plugin>
7281
<plugin>
7382
<groupId>org.apache.maven.plugins</groupId>
7483
<artifactId>maven-source-plugin</artifactId>
@@ -86,6 +95,9 @@
8695
<groupId>org.apache.maven.plugins</groupId>
8796
<artifactId>maven-javadoc-plugin</artifactId>
8897
<version>3.6.3</version>
98+
<configuration>
99+
<doclint>none</doclint>
100+
</configuration>
89101
<executions>
90102
<execution>
91103
<id>attach-javadocs</id>

0 commit comments

Comments
 (0)