Skip to content

Commit 663a19a

Browse files
authored
Merge pull request #343 from EasyPost/webhook_params
test: extra webhook params
1 parent 33fbbad commit 663a19a

19 files changed

Lines changed: 360 additions & 241 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,8 @@ jobs:
1717
- uses: actions/setup-java@v4
1818
with:
1919
distribution: "zulu"
20-
java-version: "23" # Always use the latest JDK for building
21-
- name: Load Maven dependencies cache
22-
uses: actions/cache@v3
23-
with:
24-
path: ~/.m2/repository
25-
key: ${{ runner.os }}-maven-build${{ matrix.javaversion }}-${{ hashFiles('**/pom.xml') }}
26-
restore-keys: |
27-
${{ runner.os }}-maven-
20+
java-version: "21" # Always use the latest stable JDK for building
21+
cache: "maven"
2822
- name: Install dependencies
2923
run: make install
3024
- name: Build Library
@@ -35,22 +29,16 @@ jobs:
3529
distribution: "zulu"
3630
java-version: ${{ matrix.javaversion }}
3731
- name: Run test with Java ${{ matrix.javaversion }}
38-
run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 make test
32+
run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 make test-ci
3933
coverage:
4034
runs-on: ubuntu-latest
4135
steps:
4236
- uses: actions/checkout@v4
4337
- uses: actions/setup-java@v4
4438
with:
4539
distribution: "zulu"
46-
java-version: "23" # Always use the latest JDK for building
47-
- name: Load Maven dependencies cache
48-
uses: actions/cache@v3
49-
with:
50-
path: ~/.m2/repository
51-
key: ${{ runner.os }}-maven-build-coverage-${{ hashFiles('**/pom.xml') }}
52-
restore-keys: |
53-
${{ runner.os }}-maven-
40+
java-version: "21" # Always use the latest stable JDK for building
41+
cache: "maven"
5442
- name: Install dependencies
5543
run: make install
5644
- name: Test coverage
@@ -77,16 +65,10 @@ jobs:
7765
- uses: actions/setup-java@v4
7866
with:
7967
distribution: "zulu"
80-
java-version: "23" # Always use the latest JDK for building
68+
java-version: "21" # Always use the latest stable JDK for building
69+
cache: "maven"
8170
- name: Install checkstyle and style guide
8271
run: make install-checkstyle
83-
- name: Load Maven dependencies and CVE database cache
84-
uses: actions/cache@v3
85-
with:
86-
path: ~/.m2/repository # The CVE database is included in the Maven repository folder
87-
key: ${{ runner.os }}-maven-security-${{ hashFiles('**/pom.xml') }}
88-
restore-keys: |
89-
${{ runner.os }}-maven-
9072
- name: Lint
9173
run: make lint
9274
- name: Upload Test results
@@ -102,14 +84,8 @@ jobs:
10284
- uses: actions/setup-java@v4
10385
with:
10486
distribution: "zulu"
105-
java-version: "23" # Always use the latest JDK for building
106-
- name: Load Maven dependencies cache
107-
uses: actions/cache@v3
108-
with:
109-
path: ~/.m2/repository
110-
key: ${{ runner.os }}-maven-build-coverage-${{ hashFiles('**/pom.xml') }}
111-
restore-keys: |
112-
${{ runner.os }}-maven-
87+
java-version: "21" # Always use the latest stable JDK for building
88+
cache: "maven"
11389
- name: Install Dependencies
11490
run: make install
11591
- name: Generate Docs

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ on:
2525

2626
jobs:
2727
release:
28-
runs-on: ubuntu-20.04
28+
runs-on: ubuntu-latest
2929
steps:
3030
- name: Checkout repository
3131
uses: actions/checkout@v4
3232
with:
3333
fetch-depth: 0
3434

3535
- name: Install JDK
36-
uses: actions/setup-java@v3
36+
uses: actions/setup-java@v4
3737
with:
3838
distribution: "zulu"
39-
java-version: "22" # Always use the latest JDK
39+
java-version: "21" # Always use the latest stable JDK for building
4040
server-id: "ossrh"
4141
# define environmental variable names
4242
server-username: MAVEN_USERNAME

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## Next Release
4+
5+
- Adds `WebhookCustomHeader` model, allowing `custom_headers` to be passed when creating/updating a webhook
6+
- Corrects payload wrapping for updating a webhook
7+
- Bumps dependencies
8+
39
## v7.4.4 (2025-01-03)
410

511
- Fixes how params are passed to the API when buying a pickup and providing a pickup rate (closes #340)

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@ scan:
6666

6767
## test - Test the project
6868
test:
69+
mvn test -Dgpg.skip=true -Dcheckstyle.skip=true -Ddependency-check.skip=true -Djavadoc.skip=true -Djacoco.skip=true
70+
71+
## test-ci - Test the project on CI (does not rebuild the project)
72+
test-ci:
6973
mvn surefire:test
7074

7175
## update-examples-submodule - Update the examples submodule
7276
update-examples-submodule:
7377
git submodule init
7478
git submodule update --remote
7579

76-
.PHONY: help build clean coverage docs install-checkstyle install-styleguide install lint publish publish-dry release scan scan-strict test update-examples-submodule
80+
.PHONY: help build clean coverage docs install-checkstyle install-styleguide install lint publish publish-dry release scan scan-strict test test-ci update-examples-submodule

examples

Submodule examples updated 170 files

pom.xml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,32 @@
4646
<dependency>
4747
<groupId>com.google.code.gson</groupId>
4848
<artifactId>gson</artifactId>
49-
<version>2.10.1</version>
49+
<version>2.12.1</version>
50+
<scope>compile</scope>
5051
</dependency>
5152
<dependency>
5253
<groupId>com.google.errorprone</groupId>
5354
<artifactId>error_prone_core</artifactId>
54-
<version>2.32.0</version>
55+
<version>2.36.0</version>
5556
<scope>provided</scope>
5657
</dependency>
5758
<dependency>
5859
<groupId>org.junit.jupiter</groupId>
5960
<artifactId>junit-jupiter</artifactId>
60-
<version>5.9.3</version>
61+
<version>5.11.4</version>
6162
<scope>test</scope>
6263
</dependency>
6364
<dependency>
6465
<groupId>org.hamcrest</groupId>
6566
<artifactId>hamcrest</artifactId>
66-
<version>2.2</version>
67+
<version>3.0</version>
6768
<scope>test</scope>
6869
</dependency>
6970
<dependency>
7071
<groupId>org.jetbrains</groupId>
7172
<artifactId>annotations</artifactId>
72-
<version>24.0.1</version>
73+
<version>26.0.2</version>
74+
<scope>compile</scope>
7375
</dependency>
7476
<dependency>
7577
<groupId>com.easypost</groupId>
@@ -80,7 +82,7 @@
8082
<dependency>
8183
<groupId>org.projectlombok</groupId>
8284
<artifactId>lombok</artifactId>
83-
<version>1.18.30</version>
85+
<version>1.18.36</version>
8486
<scope>provided</scope>
8587
</dependency>
8688
</dependencies>
@@ -128,7 +130,7 @@
128130
<plugin>
129131
<groupId>org.jacoco</groupId>
130132
<artifactId>jacoco-maven-plugin</artifactId>
131-
<version>0.8.10</version>
133+
<version>0.8.12</version>
132134
<configuration>
133135
<excludes>
134136
<!-- Exclude all the getters in model for code coverage -->
@@ -173,7 +175,7 @@
173175
<plugin>
174176
<groupId>org.apache.maven.plugins</groupId>
175177
<artifactId>maven-source-plugin</artifactId>
176-
<version>3.2.1</version>
178+
<version>3.3.1</version>
177179
<executions>
178180
<execution>
179181
<id>attach-sources</id>
@@ -191,7 +193,7 @@
191193
<doclint>-html</doclint>
192194
<quiet>true</quiet>
193195
</configuration>
194-
<version>3.5.0</version>
196+
<version>3.11.2</version>
195197
<executions>
196198
<execution>
197199
<id>attach-javadocs</id>
@@ -204,7 +206,7 @@
204206
<plugin>
205207
<groupId>org.apache.maven.plugins</groupId>
206208
<artifactId>maven-gpg-plugin</artifactId>
207-
<version>3.1.0</version>
209+
<version>3.2.7</version>
208210
<configuration>
209211
<!-- Needed to read passphrase from settings.xml -->
210212
<gpgArguments>
@@ -233,6 +235,7 @@
233235
<compilerArgs>
234236
<arg>-XDcompilePolicy=simple</arg>
235237
<arg>-Xplugin:ErrorProne</arg>
238+
<arg>--should-stop=ifError=FLOW</arg>
236239
<arg>-Xlint:-options</arg>
237240
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
238241
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
@@ -249,20 +252,20 @@
249252
<path>
250253
<groupId>com.google.errorprone</groupId>
251254
<artifactId>error_prone_core</artifactId>
252-
<version>2.32.0</version>
255+
<version>2.36.0</version>
253256
</path>
254257
<path>
255258
<groupId>org.projectlombok</groupId>
256259
<artifactId>lombok</artifactId>
257-
<version>1.18.30</version>
260+
<version>1.18.36</version>
258261
</path>
259262
</annotationProcessorPaths>
260263
</configuration>
261264
</plugin>
262265
<plugin>
263266
<groupId>org.sonatype.plugins</groupId>
264267
<artifactId>nexus-staging-maven-plugin</artifactId>
265-
<version>1.6.13</version>
268+
<version>1.7.0</version>
266269
<extensions>true</extensions>
267270
<configuration>
268271
<serverId>ossrh</serverId>
@@ -273,7 +276,7 @@
273276
<plugin>
274277
<groupId>org.codehaus.mojo</groupId>
275278
<artifactId>templating-maven-plugin</artifactId>
276-
<version>1.0.0</version>
279+
<version>3.0.0</version>
277280
<executions>
278281
<execution>
279282
<id>filtering-java-templates</id>
@@ -286,7 +289,7 @@
286289
<plugin>
287290
<groupId>org.apache.maven.plugins</groupId>
288291
<artifactId>maven-checkstyle-plugin</artifactId>
289-
<version>3.2.2</version>
292+
<version>3.6.0</version>
290293
<configuration>
291294
<configLocation>${basedir}/easypost_java_style.xml</configLocation>
292295
<inputEncoding>UTF-8</inputEncoding>
@@ -315,7 +318,7 @@
315318
<plugin>
316319
<groupId>org.apache.maven.plugins</groupId>
317320
<artifactId>maven-enforcer-plugin</artifactId>
318-
<version>3.3.0</version>
321+
<version>3.5.0</version>
319322
<executions>
320323
<execution>
321324
<id>enforce-java</id>
@@ -335,6 +338,8 @@
335338
<plugin>
336339
<groupId>org.owasp</groupId>
337340
<artifactId>dependency-check-maven</artifactId>
341+
<!-- Can't upgrade to `v11` or newer versions as it requires Java 11 -->
342+
<!-- TODO: API key now recommended (we must upgrade to v10) to avoid rate limiting: https://github.com/dependency-check/DependencyCheck?tab=readme-ov-file#nvd-api-key-highly-recommended -->
338343
<version>8.4.0</version>
339344
<configuration>
340345
<suppressionFile>dependency-check-suppressions.xml</suppressionFile>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.easypost.model;
22

33
import java.util.Date;
4-
4+
import java.util.List;
55
import lombok.Getter;
66

77
@Getter
88
public final class Webhook extends EasyPostResource {
99
private String url;
1010
private Date disabledAt;
11+
private List<WebhookCustomHeader> customHeaders;
1112
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.easypost.model;
2+
3+
import lombok.Getter;
4+
5+
@Getter
6+
public final class WebhookCustomHeader {
7+
private String name;
8+
private String value;
9+
}

src/main/java/com/easypost/service/WebhookService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,8 @@ public Webhook update(final String id) throws EasyPostException {
108108
* @throws EasyPostException when the request fails.
109109
*/
110110
public Webhook update(final String id, final Map<String, Object> params) throws EasyPostException {
111-
Map<String, Object> wrappedParams = new HashMap<String, Object>();
112-
wrappedParams.put("webhook", params);
113-
114111
String endpoint = "webhooks/" + id;
115112

116-
return Requestor.request(RequestMethod.PUT, endpoint, wrappedParams, Webhook.class, client);
113+
return Requestor.request(RequestMethod.PUT, endpoint, params, Webhook.class, client);
117114
}
118115
}

0 commit comments

Comments
 (0)