Documentation
¶
Index ¶
- Variables
- type Authenticator
- type BodyHandler
- type BodyHandlerFunc
- type Communicator
- func (c *Communicator) Close() error
- func (c *Communicator) CloseExpiredConnections()
- func (c *Communicator) CloseIdleConnections(duration time.Duration)
- func (c *Communicator) Delete(relativePath string, requestHeaders []communication.Header, ...) error
- func (c *Communicator) DeleteWithHandler(relativePath string, requestHeaders []communication.Header, ...) error
- func (c *Communicator) DisableLogging()
- func (c *Communicator) EnableLogging(logger logging.CommunicatorLogger)
- func (c *Communicator) Get(relativePath string, requestHeaders []communication.Header, ...) error
- func (c *Communicator) GetWithHandler(relativePath string, requestHeaders []communication.Header, ...) error
- func (c *Communicator) Marshaller() Marshaller
- func (c *Communicator) Post(relativePath string, requestHeaders []communication.Header, ...) error
- func (c *Communicator) PostWithHandler(relativePath string, requestHeaders []communication.Header, ...) error
- func (c *Communicator) Put(relativePath string, requestHeaders []communication.Header, ...) error
- func (c *Communicator) PutWithHandler(relativePath string, requestHeaders []communication.Header, ...) error
- func (c *Communicator) Session() *Session
- func (c *Communicator) SetBodyObfuscator(bodyObfuscator obfuscation.BodyObfuscator)
- func (c *Communicator) SetHeaderObfuscator(headerObfuscator obfuscation.HeaderObfuscator)
- type Connection
- type Marshaller
- type MetaDataProvider
- type MetaDataProviderBuilder
- type MultipartFormDataRequest
- type ParamRequest
- type RequestParam
- type RequestParams
- type Session
- type SessionBuilder
- func (s *SessionBuilder) Build() (*Session, error)
- func (s *SessionBuilder) WithAPIEndpoint(endpoint *url.URL) *SessionBuilder
- func (s *SessionBuilder) WithAuthenticator(auth Authenticator) *SessionBuilder
- func (s *SessionBuilder) WithConnection(connection Connection) *SessionBuilder
- func (s *SessionBuilder) WithMetaDataProvider(provider *MetaDataProvider) *SessionBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilSession occurs when the given session is nil ErrNilSession = errors.New("session is nil") // ErrNilMarshaller occurs when the given marshaller is nil ErrNilMarshaller = errors.New("marshaller is nil") )
var ( // ErrNilEndpoint occurs when the given endpoint is nil ErrNilEndpoint = errors.New("apiEndpoint is required") // ErrPathEndpoint occurs when the endpoint contains a path ErrPathEndpoint = errors.New("apiEndpoint should not contain a path") // ErrUserInfo occurs when the endpoint contains any userinfo ErrUserInfo = errors.New("apiEndpoint should not contain user info, query or fragment") // ErrNilConnection occurs when a nil connection is supplied ErrNilConnection = errors.New("connection is required") // ErrNilAuthenticator occurs when a nil authenticator is supplied ErrNilAuthenticator = errors.New("authenticator is required") // ErrNilMetaDataProvider occurs when a nil metaDataProvider is supplied ErrNilMetaDataProvider = errors.New("metaDataProvider is required") )
var ( // ErrNoName occurs when the given name is empty ErrNoName = errors.New("name is required") )
var ( // ErrProhibitedHeader occurs when the header name is prohibited ErrProhibitedHeader = errors.New("header is prohibited") )
var ProhibitedHeaders = []string{serverMetaInfoHeader, "X-GCS-Idempotence-Key",
"Date", "Content-Type", "Authorization"}
ProhibitedHeaders are the headers that can't be included in the server requests
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface { // CreateSimpleAuthenticationSignature creates a signature for the simple security model. // It returns the simple authentication signature. // Note that the list of Request headers may not be modified and may not contain headers with // the same name. CreateSimpleAuthenticationSignature(httpMethod string, resourceURI url.URL, requestHeaders []communication.Header) (string, error) }
Authenticator is the interface used to sign requests to the Ingenico ePayments platform. Thread-safe.
type BodyHandler ¶
type BodyHandler interface {
Handle(headers []communication.Header, reader io.Reader) error
}
BodyHandler is a handler for an incoming body stream
type BodyHandlerFunc ¶
type BodyHandlerFunc func(headers []communication.Header, reader io.Reader) error
BodyHandlerFunc is a handler function for an incoming body stream
func (BodyHandlerFunc) Handle ¶
func (f BodyHandlerFunc) Handle(headers []communication.Header, reader io.Reader) error
Handle calls f(statusCode, headers, reader)
type Communicator ¶
type Communicator struct {
// contains filtered or unexported fields
}
A Communicator is used to communicate with the Ingenico ePayments platform web services. It contains all the logic to transform a request object to a HTTP request and a HTTP response to a response object. It is also thread safe.
func NewCommunicator ¶
func NewCommunicator(session *Session, marshaller Marshaller) (*Communicator, error)
NewCommunicator creates a communicator with the given session and marshaller
func (*Communicator) Close ¶
func (c *Communicator) Close() error
Close closes the connection of the Communicator
func (*Communicator) CloseExpiredConnections ¶
func (c *Communicator) CloseExpiredConnections()
CloseExpiredConnections is a utility method that delegates the call to this communicator's session's connection. Also see Connection.CloseExpiredConnections
func (*Communicator) CloseIdleConnections ¶
func (c *Communicator) CloseIdleConnections(duration time.Duration)
CloseIdleConnections is a utility method that delegates the call to this communicator's session's connection. The duration argument is a specification of how long the connection has to be Idle. Also see Connection.CloseIdleConnections
func (*Communicator) Delete ¶
func (c *Communicator) Delete(relativePath string, requestHeaders []communication.Header, requestParameters ParamRequest, context communication.CallContext, expectedObject interface{}) error
Delete corresponds to the HTTP Delete method
relativePath is the Path to call, relative to the base URI requestHeaders is an optimal list of request headers requestParameters is an optional set of request parameters. If not used set to nil context is an optional Call context which can be used expectedObject is a reference to the expected response object
Possibly returns an error
func (*Communicator) DeleteWithHandler ¶
func (c *Communicator) DeleteWithHandler(relativePath string, requestHeaders []communication.Header, requestParameters ParamRequest, context communication.CallContext, bodyHandler BodyHandler) error
DeleteWithHandler corresponds to the HTTP Delete method
relativePath is the Path to call, relative to the base URI requestHeaders is an optimal list of request headers requestParameters is an optional set of request parameters. If not used set to nil context is an optional Call context which can be used expectedObject is a reference to the expected response object bodyHandler is a BodyHandler that handles the body stream
Possibly returns an error
func (*Communicator) DisableLogging ¶
func (c *Communicator) DisableLogging()
DisableLogging turns off logging.
func (*Communicator) EnableLogging ¶
func (c *Communicator) EnableLogging(logger logging.CommunicatorLogger)
EnableLogging turns on logging using the given communicator logger.
func (*Communicator) Get ¶
func (c *Communicator) Get(relativePath string, requestHeaders []communication.Header, requestParameters ParamRequest, context communication.CallContext, expectedObject interface{}) error
Get corresponds to the HTTP Get method
relativePath is the Path to call, relative to the base URI requestHeaders is an optimal list of request headers requestParameters is an optional set of request parameters. If not used set to nil context is an optional Call context which can be used expectedObject is a reference to the expected response object
Possibly returns an error
func (*Communicator) GetWithHandler ¶
func (c *Communicator) GetWithHandler(relativePath string, requestHeaders []communication.Header, requestParameters ParamRequest, context communication.CallContext, bodyHandler BodyHandler) error
GetWithHandler corresponds to the HTTP Get method
relativePath is the Path to call, relative to the base URI requestHeaders is an optimal list of request headers requestParameters is an optional set of request parameters. If not used set to nil context is an optional Call context which can be used expectedObject is a reference to the expected response object bodyHandler is a BodyHandler that handles the body stream
Possibly returns an error
func (*Communicator) Marshaller ¶
func (c *Communicator) Marshaller() Marshaller
Marshaller returns the marshaller of this Communicator
func (*Communicator) Post ¶
func (c *Communicator) Post(relativePath string, requestHeaders []communication.Header, requestParameters ParamRequest, requestBody interface{}, context communication.CallContext, expectedResponse interface{}) error
Post corresponds to the HTTP Post method
relativePath is the Path to call, relative to the base URI requestHeaders is an optimal list of request headers requestParameters is an optional set of request parameters. If not used set it to nil requestBody is the body of the request. If not used set to nil context is an optional Call context which can be used. If not used set it to nil expectedObject is a reference to the expected response object
Possibly returns an error
func (*Communicator) PostWithHandler ¶
func (c *Communicator) PostWithHandler(relativePath string, requestHeaders []communication.Header, requestParameters ParamRequest, requestBody interface{}, context communication.CallContext, bodyHandler BodyHandler) error
PostWithHandler corresponds to the HTTP Post method
relativePath is the Path to call, relative to the base URI requestHeaders is an optimal list of request headers requestParameters is an optional set of request parameters. If not used set it to nil requestBody is the body of the request. If not used set to nil context is an optional Call context which can be used. If not used set it to nil expectedObject is a reference to the expected response object bodyHandler is a BodybodyHandler that handles the body stream
Possibly returns an error
func (*Communicator) Put ¶
func (c *Communicator) Put(relativePath string, requestHeaders []communication.Header, requestParameters ParamRequest, requestBody interface{}, context communication.CallContext, expectedObject interface{}) error
Put corresponds to the HTTP Put method
relativePath is the Path to call, relative to the base URI requestHeaders is an optimal list of request headers requestParameters is an optional set of request parameters. If not used set it to nil requestBody is the body of the request. If not used set to nil context is an optional Call context which can be used. If not used set it to nil expectedObject is a reference to the expected response object
Possibly returns an error
func (*Communicator) PutWithHandler ¶
func (c *Communicator) PutWithHandler(relativePath string, requestHeaders []communication.Header, requestParameters ParamRequest, requestBody interface{}, context communication.CallContext, bodyHandler BodyHandler) error
PutWithHandler corresponds to the HTTP Put method
relativePath is the Path to call, relative to the base URI requestHeaders is an optimal list of request headers requestParameters is an optional set of request parameters. If not used set it to nil requestBody is the body of the request. If not used set to nil context is an optional Call context which can be used. If not used set it to nil expectedObject is a reference to the expected response object bodyHandler is a BodyHandler that handles the body stream
Possibly returns an error
func (*Communicator) Session ¶
func (c *Communicator) Session() *Session
Session returns the session of this Communicator
func (*Communicator) SetBodyObfuscator ¶
func (c *Communicator) SetBodyObfuscator(bodyObfuscator obfuscation.BodyObfuscator)
SetBodyObfuscator sets the body obfuscator to use.
func (*Communicator) SetHeaderObfuscator ¶
func (c *Communicator) SetHeaderObfuscator(headerObfuscator obfuscation.HeaderObfuscator)
SetHeaderObfuscator sets the header obfuscator to use.
type Connection ¶
type Connection interface { // CloseIdleConnections closes all HTTP connections that have been idle for the specified time. This should also include // all expired HTTP connections. // timespan represents the time spent idle CloseIdleConnections(time time.Duration) // CloseExpiredConnections closes all expired HTTP connections. CloseExpiredConnections() // Get sends a GET request to the Ingenico ePayments platform and calls the given response handler with the response. Get(resourceURI url.URL, requestHeaders []communication.Header, respHandler communication.ResponseHandler) (interface{}, error) // Delete sends a DELETE request to the Ingenico ePayments platform and calls the given response handler with the response. Delete(resourceURI url.URL, requestHeaders []communication.Header, respHandler communication.ResponseHandler) (interface{}, error) // Post sends a POST request to the Ingenico ePayments platform and calls the given response handler with the response. Post(resourceURI url.URL, requestHeaders []communication.Header, body string, respHandler communication.ResponseHandler) (interface{}, error) // PostMultipart sends a multipart/form-data POST request to the Ingenico ePayments platform and calls the given response handler with the response. PostMultipart(resourceURI url.URL, requestHeaders []communication.Header, body *communication.MultipartFormDataObject, respHandler communication.ResponseHandler) (interface{}, error) // Put sends a PUT request to the Ingenico ePayments platform and calls the given response handler with the response. Put(resourceURI url.URL, requestHeaders []communication.Header, body string, respHandler communication.ResponseHandler) (interface{}, error) // PutMultipart sends a multipart/form-data PUT request to the Ingenico ePayments platform and calls the given response handler with the response. PutMultipart(resourceURI url.URL, requestHeaders []communication.Header, body *communication.MultipartFormDataObject, respHandler communication.ResponseHandler) (interface{}, error) // EnableLogging turns on logging using the given communicator logger. EnableLogging(communicatorLogger logging.CommunicatorLogger) // DisableLogging turns off logging. DisableLogging() // Close closes the connection of the Communicator Close() error }
Connection represents a pooled connection to the Ingenico ePayments platform server. Instead of setting up a new HTTP connection for each request, this connection uses a pool of HTTP connections. Thread-safe
type Marshaller ¶
type Marshaller interface { // Marshal converts a request object to a JSON string. Marshal(interface{}) (string, error) // Unmarshal converts a JSON string to a response object. Unmarshal(string, interface{}) error // UnmarshalFromReader converts the contents from an io.Reader to a response object. UnmarshalFromReader(io.Reader, interface{}) error }
Marshaller is the interface used to marshal and unmarshal Ingenico ePayments platform request and response objects to and from JSON. Thread-safe.
type MetaDataProvider ¶
type MetaDataProvider struct {
// contains filtered or unexported fields
}
MetaDataProvider provides meta info about the server. Thread-safe.
func NewMetaDataProviderWithBuilder ¶
func NewMetaDataProviderWithBuilder(builder MetaDataProviderBuilder) (*MetaDataProvider, error)
NewMetaDataProviderWithBuilder creates a MetaDataProvider with the given MetaDataProviderBuilder
func NewMetaDataProviderWithIntegrator ¶
func NewMetaDataProviderWithIntegrator(integrator string) (*MetaDataProvider, error)
NewMetaDataProviderWithIntegrator creates a MetaDataProvider with the given integrator
func (*MetaDataProvider) MetaDataHeaders ¶
func (m *MetaDataProvider) MetaDataHeaders() []communication.Header
MetaDataHeaders returns the server related headers containing the metadata to be associated with the request (if any). This will always contain at least an automatically generated header X-GCS-ServerMetaInfo.
type MetaDataProviderBuilder ¶
type MetaDataProviderBuilder struct { ShoppingCartExtension *metadata.ShoppingCartExtension AdditionalRequestHeaders []communication.Header // contains filtered or unexported fields }
MetaDataProviderBuilder represents a builder for a MetaDataProvider object.
func NewMetaDataProviderBuilder ¶
func NewMetaDataProviderBuilder(integrator string) *MetaDataProviderBuilder
NewMetaDataProviderBuilder creates a MetaDataProviderBuilder with the given Integrator
func (*MetaDataProviderBuilder) Build ¶
func (m *MetaDataProviderBuilder) Build() (*MetaDataProvider, error)
Build creates a fully initialized MetaDataProvider
type MultipartFormDataRequest ¶
type MultipartFormDataRequest interface { // ToMultipartFormDataObject converts this multipart/form-data request into a MultipartFormDataObject. ToMultipartFormDataObject() *communication.MultipartFormDataObject }
MultipartFormDataRequest represents a multipart/form-data request.
type ParamRequest ¶
type ParamRequest interface { // ToRequestParameters converts this set of request parameters to a slice of RequestParam ToRequestParameters() RequestParams }
ParamRequest represents a set of request parameters.
type RequestParam ¶
type RequestParam struct {
// contains filtered or unexported fields
}
RequestParam represents a single request parameter. Immutable.
func NewRequestParam ¶
func NewRequestParam(name, value string) (*RequestParam, error)
NewRequestParam creates a RequestParam with the given name and value
func (RequestParam) Name ¶
func (rp RequestParam) Name() string
Name returns the name of the RequestParam
func (RequestParam) String ¶
func (rp RequestParam) String() string
String is the implmenetation of the Stringer interface Format: 'name:value'
func (RequestParam) Value ¶
func (rp RequestParam) Value() string
Value returns the value of the RequestParam
type RequestParams ¶
type RequestParams []RequestParam
RequestParams represents a slice of RequestParam
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session Contains the components needed to communicate with the Ingenico ePayments platform. Thread-safe.
func NewSession ¶
func NewSession(apiEndpoint *url.URL, connection Connection, authenticator Authenticator, metaDataProvider *MetaDataProvider) (*Session, error)
NewSession creates a new session with the given apiEndpoint, connection and authenticator
func (*Session) APIEndpoint ¶
APIEndpoint returns the apiEndpoint of the session
func (*Session) Authenticator ¶
func (s *Session) Authenticator() Authenticator
Authenticator returns the authenticator of the session
func (*Session) Connection ¶
func (s *Session) Connection() Connection
Connection returns the connection of the session
func (*Session) MetaDataProvider ¶
func (s *Session) MetaDataProvider() *MetaDataProvider
MetaDataProvider returns the metaDataProvider of the session
type SessionBuilder ¶
type SessionBuilder struct { APIEndpoint *url.URL Connection Connection MetaDataProvider *MetaDataProvider Authenticator Authenticator }
SessionBuilder is the builder for Session objects
func NewSessionBuilder ¶
func NewSessionBuilder() (*SessionBuilder, error)
NewSessionBuilder creates a SessionBuilder object
func (*SessionBuilder) Build ¶
func (s *SessionBuilder) Build() (*Session, error)
Build creates a Session object based on the builder parameters
func (*SessionBuilder) WithAPIEndpoint ¶
func (s *SessionBuilder) WithAPIEndpoint(endpoint *url.URL) *SessionBuilder
WithAPIEndpoint sets the Ingenico ePayments platform API endpoint to be used by the Session
func (*SessionBuilder) WithAuthenticator ¶
func (s *SessionBuilder) WithAuthenticator(auth Authenticator) *SessionBuilder
WithAuthenticator sets the Authenticator to be used by the Session
func (*SessionBuilder) WithConnection ¶
func (s *SessionBuilder) WithConnection(connection Connection) *SessionBuilder
WithConnection sets the Connection to be used by the Session
func (*SessionBuilder) WithMetaDataProvider ¶
func (s *SessionBuilder) WithMetaDataProvider(provider *MetaDataProvider) *SessionBuilder
WithMetaDataProvider sets the MetaDataProvider to be used by the Session