@Override public HttpRequestIntent httpRequestIntent() { return HttpRequestIntent.of(HttpMethod.GET, "/"); } });
@Override public HttpRequestIntent httpRequestIntent() { return HttpRequestIntent.of(HttpMethod.GET, "/"); } });
@Override public HttpRequestIntent httpRequestIntent() { return HttpRequestIntent.of(HttpMethod.DELETE, String.format("/api-clients/%s", id)); } }
@Override public HttpRequestIntent httpRequestIntent() { return HttpRequestIntent.of(HttpMethod.DELETE, String.format("/api-clients/%s", id)); } }
@Override public HttpRequestIntent httpRequestIntent() { return HttpRequestIntent.of(POST, "/customers/email-token", SphereJsonUtils.toJsonString(this)); } }
@Override public final HttpRequestIntent httpRequestIntent() { final String additions = queryParametersToString(true); return HttpRequestIntent.of(HttpMethod.GET, endpoint + (additions.length() > 1 ? additions : "")); }
@Override public HttpRequestIntent httpRequestIntent() { final String additions = queryParametersToString(true); return HttpRequestIntent.of(HttpMethod.GET, endpoint + (additions.length() > 1 ? additions : "")); }
@Override public HttpRequestIntent httpRequestIntent() { return HttpRequestIntent.of(POST, "/customers/email-token", SphereJsonUtils.toJsonString(this)); } }
@Override public HttpRequestIntent httpRequestIntent() { final String path = format("/products/%s/images?variant=%d%s&staged=%s", productId, variantId, filename.map(s -> "&filename="+s).orElse(""), productUpdateScope.isOnlyStaged().toString()); return HttpRequestIntent.of(HttpMethod.POST, path, img, contentType); }
@Override public HttpRequestIntent httpRequestIntent() { return HttpRequestIntent.of(POST, "/customers/email-token", SphereJsonUtils.toJsonString(this)); } }
public static JsonNodeSphereRequest of(final HttpMethod httpMethod, final String path, @Nullable final JsonNode body) { final HttpRequestIntent httpRequestIntent = Optional.ofNullable(body) .map(b -> HttpRequestIntent.of(httpMethod, path, SphereJsonUtils.toJsonString(b))) .orElseGet(() -> HttpRequestIntent.of(httpMethod, path)); return of(httpRequestIntent); } }
@Override public HttpRequestIntent httpRequestIntent() { return HttpRequestIntent.of(POST, "/customers/email-token", JsonUtils.toJson(this)); } }
@Override public HttpRequestIntent httpRequestIntent() { return HttpRequestIntent.of(POST, "/product-discounts/matching",SphereJsonUtils.toJsonString(MatchingProductDiscountGet.this)); }
@Override public HttpRequestIntent httpRequestIntent() { final String baseEndpointWithoutId = endpoint.endpoint(); if (!baseEndpointWithoutId.startsWith("/")) { throw new RuntimeException("By convention the paths start with a slash, see baseEndpointWithoutId()"); } return HttpRequestIntent.of(HttpMethod.DELETE, baseEndpointWithoutId + "/" + versioned.getId() + "?version=" + versioned.getVersion()); }
@Override public HttpRequestIntent httpRequestIntent() { final String additions = queryParametersToString(true); return HttpRequestIntent.of(httpMethod(), endpoint + (additions.length() > 1 ? additions : ""), httpBody()); }
@Override public HttpRequestIntent httpRequestIntent() { if (!endpoint.endpoint().startsWith("/")) { throw new RuntimeException("By convention the paths start with a slash, see baseEndpointWithoutId()"); } final String queryParameters = additionalQueryParameters().toStringWithOptionalQuestionMark(); final String path = endpoint.endpoint() + "/" + identifierToSearchFor + queryParameters; return HttpRequestIntent.of(HttpMethod.GET, path); }
@Override public HttpRequestIntent httpRequestIntent() { final String additions = queryParametersToString(true); return HttpRequestIntent.of(HttpMethod.POST, endpoint, HttpHeaders.of(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded"), StringHttpRequestBody.of(additions)); }
@Override public HttpRequestIntent httpRequestIntent() { if (!baseEndpointWithoutId.startsWith("/")) { throw new RuntimeException("By convention the paths start with a slash, see baseEndpointWithoutId()"); } final String path = baseEndpointWithoutId + "/" + getVersioned().getId(); return HttpRequestIntent.of(HttpMethod.POST, path, toJson(new UpdateCommandBody<>(getVersioned().getVersion(), getUpdateActions()))); }
@Test public void invalidJsonInHttpRequestIntent() throws Throwable { final HttpHeaders headers = VrapHeaders.disableValidation("request", "response"); executing(() -> TestSphereRequest.of(HttpRequestIntent.of(POST, "/categories", "{invalidJson :)").withHeaders(headers))) .resultsInA(ErrorResponseException.class, InvalidJsonInputError.class); }