public
|
#
__construct( GuzzleHttp\ClientInterface $client, string $merchantId, string $sharedSecret, Klarna\Rest\Transport\UserAgentInterface $userAgent = null )
Constructs a connector instance.
Constructs a connector instance.
Example usage:
$client = new \GuzzleHttp\Client(['base_url' => 'https://api.klarna.com']); $connector = new \Klarna\Transport\Connector($client, '0', 'sharedSecret');
Parameters
- $client
- HTTP transport client
- $merchantId
- Merchant ID
- $sharedSecret
- Shared secret
- $userAgent
- HTTP user agent to identify the client
|
public
Klarna\Rest\Transport\ApiResponse
|
#
get( string $path, array $headers = [] )
Sends HTTP GET request to specified path.
Sends HTTP GET request to specified path.
Parameters
- $path
- URL path.
- $headers
- HTTP request headers
Returns
Throws
RuntimeException if HTTP transport failed to execute a call
Implementation of
|
public
Klarna\Rest\Transport\ApiResponse
|
#
post( string $path, string $data = null, array $headers = [] )
Sends HTTP POST request to specified path.
Sends HTTP POST request to specified path.
Parameters
- $path
- URL path.
- $data
- Data to be sent to API server in a payload. Example: json-encoded string
- $headers
- HTTP request headers
Returns
Throws
RuntimeException if HTTP transport failed to execute a call
Implementation of
|
public
Klarna\Rest\Transport\ApiResponse
|
#
put( string $path, string $data = null, array $headers = [] )
Sends HTTP PUT request to specified path.
Sends HTTP PUT request to specified path.
Parameters
- $path
- URL path.
- $data
- Data to be sent to API server in a payload. Example: json-encoded string
- $headers
- HTTP request headers
Returns
Throws
RuntimeException if HTTP transport failed to execute a call
Implementation of
|
public
Klarna\Rest\Transport\ApiResponse
|
#
patch( string $path, string $data = null, array $headers = [] )
Sends HTTP PATCH request to specified path.
Sends HTTP PATCH request to specified path.
Parameters
- $path
- URL path.
- $data
- Data to be sent to API server in a payload. Example: json-encoded string
- $headers
- HTTP request headers
Returns
Throws
RuntimeException if HTTP transport failed to execute a call
Implementation of
|
public
Klarna\Rest\Transport\ApiResponse
|
#
delete( string $path, string $data = null, array $headers = [] )
Sends HTTP DELETE request to specified path.
Sends HTTP DELETE request to specified path.
Parameters
- $path
- URL path.
- $data
- Data to be sent to API server in a payload. Example: json-encoded string
- $headers
- HTTP request headers
Returns
Throws
RuntimeException if HTTP transport failed to execute a call
Implementation of
|
protected
Klarna\Rest\Transport\ApiResponse
|
#
getApiResponse( Psr\Http\Message\ResponseInterface $response )
Converts ResponseInterface to ApiResponse.
Converts ResponseInterface to ApiResponse.
Parameters
Returns
|
public
Psr\Http\Message\RequestInterface
|
#
createRequest( string $url, string $method = 'GET', array $headers = [], $body = null )
Deprecated
No longer used and not recommended. Use direct get, post, put, delete and patch methods instead.
Creates a request object.
Parameters
- $url
- URL
- $method
- HTTP method
- $headers
- $body
Returns
Psr\Http\Message\RequestInterface
|
public
Psr\Http\Message\ResponseInterface
|
#
send( Psr\Http\Message\RequestInterface $request, array $options = [] )
Deprecated
No longer used and not recommended. Use direct get, post, put, delete and patch methods instead.
Sends the request.
Parameters
- $request
- Request to send
- $options
- Request options
Returns
Psr\Http\Message\ResponseInterface
Throws
GuzzleHttp\Exception\RequestException When an error is encountered
RuntimeException When the adapter does not populate a response
|
public
GuzzleHttp\ClientInterface
|
#
getClient( )
Gets the HTTP transport client.
Gets the HTTP transport client.
Returns
GuzzleHttp\ClientInterface
|
public
Klarna\Rest\Transport\UserAgentInterface
|
|
public static
Klarna\Rest\Transport\GuzzleConnector
|
#
create( string $merchantId, string $sharedSecret, string $baseUrl = self::EU_BASE_URL, Klarna\Rest\Transport\UserAgentInterface $userAgent = null )
Factory method to create a connector instance.
Factory method to create a connector instance.
Parameters
- $merchantId
- Merchant ID
- $sharedSecret
- Shared secret
- $baseUrl
- Base URL for HTTP requests
- $userAgent
- HTTP user agent to identify the client
Returns
|