Overview
  • Namespace
  • Class

Namespaces

  • Klarna
    • Rest
      • Checkout
      • OrderManagement
      • Transport
        • Exception

Interfaces

  • Klarna\Rest\Transport\Exception\ConnectorException
 1 <?php
 2 /**
 3  * Copyright 2014 Klarna AB
 4  *
 5  * Licensed under the Apache License, Version 2.0 (the "License");
 6  * you may not use this file except in compliance with the License.
 7  * You may obtain a copy of the License at
 8  *
 9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * File containing the Connector interface.
18  */
19 
20 namespace Klarna\Rest\Transport;
21 
22 use GuzzleHttp\ClientInterface;
23 use GuzzleHttp\Exception\RequestException;
24 use Klarna\Rest\Transport\Exception\ConnectorException;
25 use Psr\Http\Message\RequestInterface;
26 use Psr\Http\Message\ResponseInterface;
27 
28 /**
29  * HTTP transport connector interface used to authenticate and make HTTP requests
30  * against the Klarna APIs.
31  *
32  * The HTTP communication is handled by
33  * {@link http://guzzle.readthedocs.org/en/guzzle4/ Guzzle}.
34  */
35 interface ConnectorInterface
36 {
37     /**
38      * API base URL for Europe.
39      */
40     const EU_BASE_URL = 'https://api.klarna.com';
41 
42     /**
43      * Testing API base URL for Europe.
44      */
45     const EU_TEST_BASE_URL = 'https://api.playground.klarna.com';
46 
47     /**
48      * API base URL for North America.
49      */
50     const NA_BASE_URL = 'https://api-na.klarna.com';
51 
52     /**
53      * Testing API base URL for North America.
54      */
55     const NA_TEST_BASE_URL = 'https://api-na.playground.klarna.com';
56 
57     /**
58      * Creates a request object.
59      *
60      * @param string $url URL
61      * @param string $method HTTP method
62      * @param array $headers
63      * @param string $body
64      * @return RequestInterface
65      *
66      */
67     public function createRequest($url, $method = 'GET', array $headers = [], $body = '');
68 
69     /**
70      * Sends the request.
71      *
72      * @param RequestInterface $request Request to send
73      *
74      * @throws ConnectorException If the API returned an error response
75      * @throws RequestException   When an error is encountered
76      * @throws \LogicException    When the adapter does not populate a response
77      *
78      * @return ResponseInterface
79      */
80     public function send(RequestInterface $request);
81 
82     /**
83      * Gets the HTTP transport client.
84      *
85      * @return ClientInterface
86      */
87     public function getClient();
88 
89     /**
90      * Gets the user agent.
91      *
92      * @return UserAgentInterface
93      */
94     public function getUserAgent();
95 }
96 
API documentation generated by ApiGen