Skip to content

Commit b52f6f9

Browse files
committed
add docs for custom URLs
1 parent 072bc60 commit b52f6f9

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Configuration.java

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
*
2424
* {@include.example example.ImportExamplesTest#instance()}
2525
*
26+
* <h3 id="custom-urls">Custom URLs</h3>
27+
*
28+
* To use custom URLs for API endpoints and authentication you have to provide the base URIs to the defaultClient method
29+
*
30+
* {@include.example example.ImportExamplesTest#customUrls()}
31+
*
2632
* <h3 id="custom-client">Custom HTTP client</h3>
2733
*
2834
* <p>The builder can be instantiated with a custom {@link io.vrap.rmf.base.client.VrapHttpClient} instance. For example a

commercetools/internal-docs/src/test/java/example/ExamplesTest.java

+32
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,38 @@ public void instance() {
7979
.build(),
8080
ServiceRegion.GCP_EUROPE_WEST1)
8181
.build("my-project");
82+
83+
// Project scoped ApiRoot config for Europe projects
84+
ProjectApiRoot projectApiRootGcpEu = ApiRootBuilder.of()
85+
.defaultClient(ClientCredentials.of()
86+
.withClientId("your-client-id")
87+
.withClientSecret("your-client-secret")
88+
.build(),
89+
ServiceRegion.valueOf("GCP_EUROPE_WEST1"))
90+
.build("my-project");
91+
}
92+
93+
public void customUrls() {
94+
// Project scoped ApiRoot config using ServiceRegion class
95+
ProjectApiRoot projectApiRoot = ApiRootBuilder.of()
96+
.defaultClient(
97+
ClientCredentials.of()
98+
.withClientId("your-client-id")
99+
.withClientSecret("your-client-secret")
100+
.build(),
101+
ServiceRegion.GCP_EUROPE_WEST1.getOAuthTokenUrl(), ServiceRegion.GCP_EUROPE_WEST1.getApiUrl())
102+
.build("my-project");
103+
104+
// Project scoped ApiRoot config using URI strings
105+
ProjectApiRoot projectApiRoot2 = ApiRootBuilder.of()
106+
.defaultClient(
107+
ClientCredentials.of()
108+
.withClientId("your-client-id")
109+
.withClientSecret("your-client-secret")
110+
.build(),
111+
"https://auth.europe-west1.gcp.commercetools.com/oauth/token",
112+
"https://api.europe-west1.gcp.commercetools.com/")
113+
.build("my-project");
82114
}
83115

84116
public void timeoutMiddleware() {

0 commit comments

Comments
 (0)