github.com/Ingenico-ePayments/connect-sdk-go@v0.0.0-20240318153750-1f8cd329b9c9/communicator/Connection.go (about)

     1  package communicator
     2  
     3  import (
     4  	"net/url"
     5  	"time"
     6  
     7  	"github.com/Ingenico-ePayments/connect-sdk-go/communicator/communication"
     8  	"github.com/Ingenico-ePayments/connect-sdk-go/logging"
     9  )
    10  
    11  // Connection represents a pooled connection to the Ingenico ePayments platform server.
    12  // Instead of setting up a new HTTP connection for each request, this
    13  // connection uses a pool of HTTP connections.
    14  // Thread-safe
    15  type Connection interface {
    16  
    17  	// CloseIdleConnections closes all HTTP connections that have been idle for the specified time. This should also include
    18  	// all expired HTTP connections.
    19  	// timespan represents the time spent idle
    20  	CloseIdleConnections(time time.Duration)
    21  
    22  	// CloseExpiredConnections closes all expired HTTP connections.
    23  	CloseExpiredConnections()
    24  
    25  	//IMPLEMENTATION Connection INTERFACE
    26  
    27  	// Get sends a GET request to the Ingenico ePayments platform and calls the given response handler with the response.
    28  	Get(resourceURI url.URL, requestHeaders []communication.Header, respHandler communication.ResponseHandler) (interface{}, error)
    29  
    30  	// Delete sends a DELETE request to the Ingenico ePayments platform and calls the given response handler with the response.
    31  	Delete(resourceURI url.URL, requestHeaders []communication.Header, respHandler communication.ResponseHandler) (interface{}, error)
    32  
    33  	// Post sends a POST request to the Ingenico ePayments platform and calls the given response handler with the response.
    34  	Post(resourceURI url.URL, requestHeaders []communication.Header, body string, respHandler communication.ResponseHandler) (interface{}, error)
    35  
    36  	// PostMultipart sends a multipart/form-data POST request to the Ingenico ePayments platform and calls the given response handler with the response.
    37  	PostMultipart(resourceURI url.URL, requestHeaders []communication.Header, body *communication.MultipartFormDataObject, respHandler communication.ResponseHandler) (interface{}, error)
    38  
    39  	// Put sends a PUT request to the Ingenico ePayments platform and calls the given response handler with the response.
    40  	Put(resourceURI url.URL, requestHeaders []communication.Header, body string, respHandler communication.ResponseHandler) (interface{}, error)
    41  
    42  	// PutMultipart sends a multipart/form-data PUT request to the Ingenico ePayments platform and calls the given response handler with the response.
    43  	PutMultipart(resourceURI url.URL, requestHeaders []communication.Header, body *communication.MultipartFormDataObject, respHandler communication.ResponseHandler) (interface{}, error)
    44  
    45  	//IMPLEMENTATION logging.Capable INTERFACE
    46  
    47  	// EnableLogging turns on logging using the given communicator logger.
    48  	EnableLogging(communicatorLogger logging.CommunicatorLogger)
    49  
    50  	// DisableLogging turns off logging.
    51  	DisableLogging()
    52  
    53  	//IMPLEMENTATION io.Closer INTERFACE
    54  
    55  	// Close closes the connection of the Communicator
    56  	Close() error
    57  }