Skip to content

Commit 648e2e6

Browse files
docs: add raw response readme documentation (#297)
1 parent 22e538b commit 648e2e6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,36 @@ CompletableFuture<Customer> customer = client.customers().create(params);
159159

160160
The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.
161161

162+
## Raw responses
163+
164+
The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body.
165+
166+
To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:
167+
168+
```java
169+
import com.withorb.api.core.http.Headers;
170+
import com.withorb.api.core.http.HttpResponseFor;
171+
import com.withorb.api.models.Customer;
172+
import com.withorb.api.models.CustomerCreateParams;
173+
174+
CustomerCreateParams params = CustomerCreateParams.builder()
175+
.email("example-customer@withorb.com")
176+
.name("My Customer")
177+
.build();
178+
HttpResponseFor<Customer> customer = client.customers().withRawResponse().create(params);
179+
180+
int statusCode = customer.statusCode();
181+
Headers headers = customer.headers();
182+
```
183+
184+
You can still deserialize the response into an instance of a Java class if needed:
185+
186+
```java
187+
import com.withorb.api.models.Customer;
188+
189+
Customer parsedCustomer = customer.parse();
190+
```
191+
162192
## Error handling
163193

164194
The SDK throws custom unchecked exception types:

0 commit comments

Comments
 (0)