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 Psr\Http\Message\RequestInterface;
25 use Psr\Http\Message\ResponseInterface;
26
27 /**
28 * HTTP transport connector interface used to authenticate and make HTTP requests
29 * against the Klarna APIs.
30 *
31 * The HTTP communication is handled by
32 * {@link http://guzzle.readthedocs.org/en/guzzle4/ Guzzle}.
33 */
34 interface ConnectorInterface
35 {
36 /**
37 * API base URL for Europe.
38 */
39 const EU_BASE_URL = 'https://api.klarna.com';
40
41 /**
42 * Testing API base URL for Europe.
43 */
44 const EU_TEST_BASE_URL = 'https://api.playground.klarna.com';
45
46 /**
47 * API base URL for North America.
48 */
49 const NA_BASE_URL = 'https://api-na.klarna.com';
50
51 /**
52 * Testing API base URL for North America.
53 */
54 const NA_TEST_BASE_URL = 'https://api-na.playground.klarna.com';
55
56 /**
57 * Sends HTTP GET request to specified path.
58 *
59 * @param string $path URL path.
60 * @param array $headers HTTP request headers
61 * @return ApiResponse Processed response
62 *
63 * @throws RuntimeException if HTTP transport failed to execute a call
64 */
65 public function get($path, $headers = []);
66
67 /**
68 * Sends HTTP POST request to specified path.
69 *
70 * @param string $path URL path.
71 * @param string $data Data to be sent to API server in a payload. Example: json-encoded string
72 * @param array $headers HTTP request headers
73 * @return ApiResponse Processed response
74 *
75 * @throws RuntimeException if HTTP transport failed to execute a call
76 */
77 public function post($path, $data = null, $headers = []);
78
79 /**
80 * Sends HTTP PUT request to specified path.
81 *
82 * @param string $path URL path.
83 * @param string $data Data to be sent to API server in a payload. Example: json-encoded string
84 * @param array $headers HTTP request headers
85 * @return ApiResponse Processed response
86 *
87 * @throws RuntimeException if HTTP transport failed to execute a call
88 */
89 public function put($path, $data = null, $headers = []);
90
91 /**
92 * Sends HTTP PATCH request to specified path.
93 *
94 * @param string $path URL path.
95 * @param string $data Data to be sent to API server in a payload. Example: json-encoded string
96 * @param array $headers HTTP request headers
97 * @return ApiResponse Processed response
98 *
99 * @throws RuntimeException if HTTP transport failed to execute a call
100 */
101 public function patch($path, $data = null, $headers = []);
102
103 /**
104 * Sends HTTP DELETE request to specified path.
105 *
106 * @param string $path URL path.
107 * @param string $data Data to be sent to API server in a payload. Example: json-encoded string
108 * @param array $headers HTTP request headers
109 * @return ApiResponse Processed response
110 *
111 * @throws RuntimeException if HTTP transport failed to execute a call
112 */
113 public function delete($path, $data = null, $headers = []);
114 }
115