summaryrefslogtreecommitdiff
path: root/src/main/java/com/p4square/ccbapi/HTTPInterface.java
blob: 11d87ec683b0e8ceecc01a65a99c82ea458c78a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.p4square.ccbapi;

import com.p4square.ccbapi.exception.CCBException;
import com.p4square.ccbapi.exception.CCBRetryableErrorException;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.Map;

/**
 * HTTPInterface exists to separate the HTTP client implementation from the CCB client.
 *
 * The concern here is that it may not be possible or desirable to take a dependency on the
 * Apache HTTP Client library. If that case arises the CCBAPIClient and the HTTPInterface
 * implementation can be split into separate packages. For simplicity's sake I'm not doing
 * that now. But if it needs to be done at a later time the code will already be isolated.
 */
public interface HTTPInterface extends Closeable {
    /**
     * Send an HTTP POST request to the given URI.
     *
     * The form data for the request is specified in the form Map.
     *
     * @param uri The URI to request.
     * @param form Map of key/value pairs to send as form data.
     * @return The response received.
     * @throws com.p4square.ccbapi.exception.CCBRetryableErrorException
     * @throws CCBRetryableErrorException if a retryable error occurs.
     * @throws IOException If a non-retryable error occurs.
     */
    InputStream sendPostRequest(URI uri, Map<String, String> form) throws IOException;
}