View Javadoc
1   /*
2    * Copyright 2022 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.apiclient.webflux;
18  
19  import java.net.URI;
20  import java.util.function.BiConsumer;
21  import java.util.function.BiFunction;
22  import javax.validation.Valid;
23  import javax.validation.constraints.NotNull;
24  import org.immutables.value.Value;
25  import org.immutables.value.Value.Style.ImplementationVisibility;
26  import org.reactivestreams.Publisher;
27  import org.springframework.http.HttpHeaders;
28  import org.springframework.util.MultiValueMap;
29  import org.springframework.web.reactive.function.client.WebClient;
30  import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec;
31  import org.springframework.web.reactive.function.client.WebClient.RequestHeadersUriSpec;
32  import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
33  import org.springframework.web.util.UriBuilder;
34  
35  /**
36   * The reactive contract.
37   *
38   * @author Christian Bremer
39   */
40  @Value.Immutable
41  @Value.Style(visibility = ImplementationVisibility.PACKAGE)
42  @Valid
43  public interface ReactiveContract {
44  
45    /**
46     * Builder.
47     *
48     * @return the immutable reactive contract . builder
49     */
50    static ImmutableReactiveContract.Builder builder() {
51      return ImmutableReactiveContract.builder();
52    }
53  
54    /**
55     * Gets cookies consumer.
56     *
57     * @return the cookies consumer
58     */
59    @NotNull
60    BiConsumer<Invocation, MultiValueMap<String, String>> getCookiesConsumer();
61  
62    /**
63     * Gets headers consumer.
64     *
65     * @return the headers consumer
66     */
67    @NotNull
68    BiConsumer<Invocation, HttpHeaders> getHeadersConsumer();
69  
70    /**
71     * Gets request uri function.
72     *
73     * @return the request uri function
74     */
75    @NotNull
76    BiFunction<Invocation, UriBuilder, URI> getRequestUriFunction();
77  
78    /**
79     * Gets request uri spec function.
80     *
81     * @return the request uri spec function
82     */
83    @NotNull
84    BiFunction<Invocation, WebClient, RequestHeadersUriSpec<?>> getRequestUriSpecFunction();
85  
86    /**
87     * Gets request body inserter function.
88     *
89     * @return the request body inserter function
90     */
91    @NotNull
92    BiFunction<Invocation, RequestBodyUriSpec, RequestHeadersUriSpec<?>>
93    getRequestBodyInserterFunction();
94  
95    /**
96     * Gets response function.
97     *
98     * @return the response function
99     */
100   @NotNull
101   BiFunction<Invocation, ResponseSpec, Publisher<?>> getResponseFunction();
102 
103 }