Interface CpqClientUtil
- All Known Implementing Classes:
DefaultCpqClientUtil
public interface CpqClientUtil
Provides re-use utility methods for interacting with CPQClient.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcheckContentType(String action, String expectedContentType, com.hybris.charon.RawResponse<?> rawResponse) CPQ may return in some error situations with HTTP 200/OK and issue and error page, instead of returning a JSON response.voidcheckHTTPStatusCode(String action, int expectedStatusCode, com.hybris.charon.RawResponse<?> rawResponse) CPQ may return in some error situations with HTTP 200/OK and issue and error page, instead of returning the expected HTTP 201/CREATED or 204/NO_CONTENT.
Use this method to detect such situations and terminate gracefully, instead of running in parse errors while trying to parse unexpected content.
In case you actually expect HTTP 200/OK, you should check the content type on top usingcheckContentType(String, String, RawResponse)<T> TtoResponse(rx.Observable<T> response) Resolves a response observable, assuming there is only exactly one element.
-
Method Details
-
checkHTTPStatusCode
void checkHTTPStatusCode(String action, int expectedStatusCode, com.hybris.charon.RawResponse<?> rawResponse) CPQ may return in some error situations with HTTP 200/OK and issue and error page, instead of returning the expected HTTP 201/CREATED or 204/NO_CONTENT.
Use this method to detect such situations and terminate gracefully, instead of running in parse errors while trying to parse unexpected content.
In case you actually expect HTTP 200/OK, you should check the content type on top usingcheckContentType(String, String, RawResponse)- Parameters:
action- log friendly string, indicating the triggering actionexpectedStatusCode- expected status HTTP coderawResponse- response containing the actual HTTP status code
-
toResponse
<T> T toResponse(rx.Observable<T> response) Resolves a response observable, assuming there is only exactly one element.- Parameters:
response- observable to resolve- Returns:
- actual response
-
checkContentType
void checkContentType(String action, String expectedContentType, com.hybris.charon.RawResponse<?> rawResponse) CPQ may return in some error situations with HTTP 200/OK and issue and error page, instead of returning a JSON response.- Parameters:
action- log friendly string, indicating the triggering actionexpectedContentType- expected content typerawResponse- response containing the actual content type
-