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 * API base URL for Oceania.
58 */
59 const OC_BASE_URL = 'https://api-oc.klarna.com';
60
61 /**
62 * Testing API base URL for Oceania.
63 */
64 const OC_TEST_BASE_URL = 'https://api-oc.playground.klarna.com';
65
66 /**
67 * Sends HTTP GET request to specified path.
68 *
69 * @param string $path URL path.
70 * @param array $headers HTTP request headers
71 * @return ApiResponse Processed response
72 *
73 * @throws RuntimeException if HTTP transport failed to execute a call
74 */
75 public function get($path, $headers = []);
76
77 /**
78 * Sends HTTP POST request to specified path.
79 *
80 * @param string $path URL path.
81 * @param string $data Data to be sent to API server in a payload. Example: json-encoded string
82 * @param array $headers HTTP request headers
83 * @return ApiResponse Processed response
84 *
85 * @throws RuntimeException if HTTP transport failed to execute a call
86 */
87 public function post($path, $data = null, $headers = []);
88
89 /**
90 * Sends HTTP PUT request to specified path.
91 *
92 * @param string $path URL path.
93 * @param string $data Data to be sent to API server in a payload. Example: json-encoded string
94 * @param array $headers HTTP request headers
95 * @return ApiResponse Processed response
96 *
97 * @throws RuntimeException if HTTP transport failed to execute a call
98 */
99 public function put($path, $data = null, $headers = []);
100
101 /**
102 * Sends HTTP PATCH request to specified path.
103 *
104 * @param string $path URL path.
105 * @param string $data Data to be sent to API server in a payload. Example: json-encoded string
106 * @param array $headers HTTP request headers
107 * @return ApiResponse Processed response
108 *
109 * @throws RuntimeException if HTTP transport failed to execute a call
110 */
111 public function patch($path, $data = null, $headers = []);
112
113 /**
114 * Sends HTTP DELETE request to specified path.
115 *
116 * @param string $path URL path.
117 * @param string $data Data to be sent to API server in a payload. Example: json-encoded string
118 * @param array $headers HTTP request headers
119 * @return ApiResponse Processed response
120 *
121 * @throws RuntimeException if HTTP transport failed to execute a call
122 */
123 public function delete($path, $data = null, $headers = []);
124 }
125