= RestfulClient
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Setup the Restful Client with Basic-Auth:Make a Request and then digest the Response:Maven Setup:

For example:

----

RestfulClientConfig clientConfig = new RestfulClientConfig();
clientConfig.setRestfulBase("http://localhost:8080/helloworld/restful/");
clientConfig.setUseBasicAuth(true); // default = false
clientConfig.setRestfulAuthUser("sven");
clientConfig.setRestfulAuthPassword("pass");
clientConfig.setUseRequestDebugLogging(true); // default = false

RestfulClient client = RestfulClient.ofConfig(clientConfig);
----

----
 _Builder request = client.request(
                "services/myService/actions/lookupMyObjectById/invoke",
                SuppressionType.RO);

Entity args = client.arguments()
        .addActionParameter("id", "12345")
        .build();

Response response = request.post(args);

Try digest = client.digest(response, MyObject.class);_ 

if(digest.isSuccess()) {
    System.out.println("result: "+ digest.getValue().orElseThrow().get$$instanceId());
} else {
    digest.getFailure().get().printStackTrace();
}
----

----
 _org.glassfish.jersey.extjersey-spring52.35_ 
----

== API

[source,java]
.RestfulClient.java
----
class RestfulClient {
  RestfulClient ofConfig(RestfulClientConfig clientConfig)
  void init(RestfulClientConfig clientConfig)
  RestfulClientConfig getConfig()
  Client getJaxRsClient()
  Builder request(String path, SuppressionType... suppressionTypes)
  Builder request(String path, EnumSet<SuppressionType> suppressionTypes)
  ActionParameterListBuilder arguments()
  Try<T> digest(Response response, Class<T> entityType)
  Try<Can<T>> digestList(Response response, Class<T> entityType, GenericType<List<T>> genericType)
}
----

