= 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:

For example:

----

RestfulClientConfig clientConfig = RestfulClientConfig.builder();
.restfulBase("http://localhost:8080/helloworld/restful/")
.useBasicAuth(true) // default = false
.restfulAuthUser("sven")
.restfulAuthPassword("pass")
.useRequestDebugLogging(true) // default = false
.build();

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

----
 _Builder request = client.request("services/myService/actions/lookupMyObjectById/invoke")
    .accept(RestfulClientMediaType.SIMPLE_JSON.mediaTypeFor(MyObject.class, EnumSet.of(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();
}
----

== API

[source,java]
.RestfulClient.java
----
class RestfulClient {
  RestfulClient ofConfig(RestfulClientConfig clientConfig)
  RestfulClient ofConfig(RestfulClientConfig clientConfig, UnaryOperator<ClientBuilder> configRefiner)
  RestfulClientConfig getConfig()
  Client getJaxRsClient()
  void close()
  Builder request(String path)
  ActionParameterListBuilder arguments()
  Try<T> digest(Response response, Class<T> entityType)
  Try<Can<T>> digestList(Response response, Class<T> entityType, GenericType<List<T>> genericType)
  Try<T> digestValue(Response response, ValueSemanticsProvider<T> valSemantics)     // <.>
  URI uri(String path)     // <.>
}
----

<.> xref:#digestValue_Response_ValueSemanticsProvider[digestValue(Response, ValueSemanticsProvider)]
+
--
For transport of _ValueDecomposition_ over REST.
--
<.> xref:#uri_String[uri(String)]
+
--
Returns an _URI_ constructed from this client's base path plus given relative _path_ .
--

== Members

[#digestValue_Response_ValueSemanticsProvider]
=== digestValue(Response, ValueSemanticsProvider)

For transport of _ValueDecomposition_ over REST.

[#uri_String]
=== uri(String)

Returns an _URI_ constructed from this client's base path plus given relative _path_ .
