Completed
Push — master ( f011eb...9572b6 )
by Sergey
03:28
created
src/Adapters/GuzzleHttpAdapter.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -8,115 +8,115 @@
 block discarded – undo
8 8
 
9 9
 class GuzzleHttpAdapter implements HttpInterface
10 10
 {
11
-    /**
12
-     * @var ClientInterface
13
-     */
14
-    protected $client;
15
-
16
-    /**
17
-     * @param ClientInterface $client
18
-     */
19
-    public function __construct(ClientInterface $client)
20
-    {
21
-        $this->client = $client;
22
-    }
23
-
24
-    /**
25
-     * @param string $uri
26
-     * @param array $params
27
-     * @param array $headers
28
-     * @return string
29
-     */
30
-    public function get($uri, $params = [], $headers = [])
31
-    {
32
-        if (!empty($params)) {
33
-            $uri .= '?' . http_build_query($params);
34
-        }
35
-
36
-        $response = $this
37
-            ->client
38
-            ->get($uri, ['headers' => $headers]);
39
-
40
-        return $this->parseResponse($response);
41
-    }
42
-
43
-    /**
44
-     * @param string $uri
45
-     * @param array $body
46
-     * @param array $headers
47
-     * @return string
48
-     */
49
-    public function post($uri, $body = [], $headers = [])
50
-    {
51
-        $response = $this
52
-            ->client
53
-            ->post(
54
-                $uri, [
55
-                    'headers'     => $headers,
56
-                    'form_params' => $body,
57
-                ]
58
-            );
59
-
60
-        return $this->parseResponse($response);
61
-    }
62
-
63
-    /**
64
-     * @param string $uri
65
-     * @param array $body
66
-     * @param array $headers
67
-     * @return mixed
68
-     */
69
-    public function put($uri, $body = [], $headers = [])
70
-    {
71
-        $response = $this
72
-            ->client
73
-            ->put(
74
-                $uri, [
75
-                    'headers'     => $headers,
76
-                    'form_params' => $body,
77
-                ]
78
-            );
79
-
80
-        return $this->parseResponse($response);
81
-    }
82
-
83
-    /**
84
-     * @param string $uri
85
-     * @param array $body
86
-     * @param array $headers
87
-     * @return mixed
88
-     */
89
-    public function delete($uri, $body = [], $headers = [])
90
-    {
91
-        $response = $this
92
-            ->client
93
-            ->delete($uri, [
94
-                'headers'     => $headers,
95
-                'form_params' => $body,
96
-            ]);
97
-
98
-        return $this->parseResponse($response);
99
-    }
100
-
101
-    /**
102
-     * @param string $url
103
-     * @return $this
104
-     */
105
-    public function setBaseUrl($url)
106
-    {
107
-        $this->client->setBaseUrl($url);
108
-        return $this;
109
-    }
110
-
111
-    /**
112
-     * @param ResponseInterface $response
113
-     * @return array|null
114
-     */
115
-    protected function parseResponse(ResponseInterface $response)
116
-    {
117
-        $responseContents = $response->getBody()->getContents();
118
-
119
-        return json_decode($responseContents, true);
120
-    }
11
+	/**
12
+	 * @var ClientInterface
13
+	 */
14
+	protected $client;
15
+
16
+	/**
17
+	 * @param ClientInterface $client
18
+	 */
19
+	public function __construct(ClientInterface $client)
20
+	{
21
+		$this->client = $client;
22
+	}
23
+
24
+	/**
25
+	 * @param string $uri
26
+	 * @param array $params
27
+	 * @param array $headers
28
+	 * @return string
29
+	 */
30
+	public function get($uri, $params = [], $headers = [])
31
+	{
32
+		if (!empty($params)) {
33
+			$uri .= '?' . http_build_query($params);
34
+		}
35
+
36
+		$response = $this
37
+			->client
38
+			->get($uri, ['headers' => $headers]);
39
+
40
+		return $this->parseResponse($response);
41
+	}
42
+
43
+	/**
44
+	 * @param string $uri
45
+	 * @param array $body
46
+	 * @param array $headers
47
+	 * @return string
48
+	 */
49
+	public function post($uri, $body = [], $headers = [])
50
+	{
51
+		$response = $this
52
+			->client
53
+			->post(
54
+				$uri, [
55
+					'headers'     => $headers,
56
+					'form_params' => $body,
57
+				]
58
+			);
59
+
60
+		return $this->parseResponse($response);
61
+	}
62
+
63
+	/**
64
+	 * @param string $uri
65
+	 * @param array $body
66
+	 * @param array $headers
67
+	 * @return mixed
68
+	 */
69
+	public function put($uri, $body = [], $headers = [])
70
+	{
71
+		$response = $this
72
+			->client
73
+			->put(
74
+				$uri, [
75
+					'headers'     => $headers,
76
+					'form_params' => $body,
77
+				]
78
+			);
79
+
80
+		return $this->parseResponse($response);
81
+	}
82
+
83
+	/**
84
+	 * @param string $uri
85
+	 * @param array $body
86
+	 * @param array $headers
87
+	 * @return mixed
88
+	 */
89
+	public function delete($uri, $body = [], $headers = [])
90
+	{
91
+		$response = $this
92
+			->client
93
+			->delete($uri, [
94
+				'headers'     => $headers,
95
+				'form_params' => $body,
96
+			]);
97
+
98
+		return $this->parseResponse($response);
99
+	}
100
+
101
+	/**
102
+	 * @param string $url
103
+	 * @return $this
104
+	 */
105
+	public function setBaseUrl($url)
106
+	{
107
+		$this->client->setBaseUrl($url);
108
+		return $this;
109
+	}
110
+
111
+	/**
112
+	 * @param ResponseInterface $response
113
+	 * @return array|null
114
+	 */
115
+	protected function parseResponse(ResponseInterface $response)
116
+	{
117
+		$responseContents = $response->getBody()->getContents();
118
+
119
+		return json_decode($responseContents, true);
120
+	}
121 121
 
122 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/Endpoints/Traits/CrudEndpoint.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -5,49 +5,49 @@
 block discarded – undo
5 5
 trait CrudEndpoint
6 6
 {
7 7
 
8
-    /**
9
-     * @param array $attributes
10
-     * @return array
11
-     */
12
-    public function create(array $attributes)
13
-    {
14
-        return $this
15
-            ->getHttp()
16
-            ->post(
17
-                $this->makeRequestUrl(),
18
-                $attributes,
19
-                $this->getHeaders()
20
-            );
21
-    }
8
+	/**
9
+	 * @param array $attributes
10
+	 * @return array
11
+	 */
12
+	public function create(array $attributes)
13
+	{
14
+		return $this
15
+			->getHttp()
16
+			->post(
17
+				$this->makeRequestUrl(),
18
+				$attributes,
19
+				$this->getHeaders()
20
+			);
21
+	}
22 22
 
23
-    /**
24
-     * @param string $itemId
25
-     * @param array $attributes
26
-     * @return mixed
27
-     */
28
-    public function update($itemId, array $attributes)
29
-    {
30
-        return $this
31
-            ->getHttp()
32
-            ->put(
33
-                $this->makeRequestUrl($itemId),
34
-                $attributes,
35
-                $this->getHeaders()
36
-            );
37
-    }
23
+	/**
24
+	 * @param string $itemId
25
+	 * @param array $attributes
26
+	 * @return mixed
27
+	 */
28
+	public function update($itemId, array $attributes)
29
+	{
30
+		return $this
31
+			->getHttp()
32
+			->put(
33
+				$this->makeRequestUrl($itemId),
34
+				$attributes,
35
+				$this->getHeaders()
36
+			);
37
+	}
38 38
 
39
-    /**
40
-     * @param string $itemId
41
-     * @return mixed
42
-     */
43
-    public function delete($itemId)
44
-    {
45
-        return $this
46
-            ->getHttp()
47
-            ->delete(
48
-                $this->makeRequestUrl($itemId),
49
-                [],
50
-                $this->getHeaders()
51
-            );
52
-    }
39
+	/**
40
+	 * @param string $itemId
41
+	 * @return mixed
42
+	 */
43
+	public function delete($itemId)
44
+	{
45
+		return $this
46
+			->getHttp()
47
+			->delete(
48
+				$this->makeRequestUrl($itemId),
49
+				[],
50
+				$this->getHeaders()
51
+			);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
src/Api/Endpoints/Widgets.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -8,28 +8,28 @@
 block discarded – undo
8 8
 class Widgets extends Endpoint
9 9
 {
10 10
 
11
-    use BelongsToOrganization, CrudEndpoint;
11
+	use BelongsToOrganization, CrudEndpoint;
12 12
 
13
-    /**
14
-     * @var string
15
-     */
16
-    protected $endpoint = 'widgets';
13
+	/**
14
+	 * @var string
15
+	 */
16
+	protected $endpoint = 'widgets';
17 17
 
18
-    /**
19
-     * @param string $itemId
20
-     * @param string|null $collectionId
21
-     * @return mixed
22
-     */
23
-    public function delete($itemId, $collectionId = null)
24
-    {
25
-        $attributes = $collectionId ? ['collectionId' => $collectionId] : [];
18
+	/**
19
+	 * @param string $itemId
20
+	 * @param string|null $collectionId
21
+	 * @return mixed
22
+	 */
23
+	public function delete($itemId, $collectionId = null)
24
+	{
25
+		$attributes = $collectionId ? ['collectionId' => $collectionId] : [];
26 26
 
27
-        return $this
28
-            ->getHttp()
29
-            ->delete(
30
-                $this->makeRequestUrl($itemId),
31
-                $attributes,
32
-                $this->getHeaders()
33
-            );
34
-    }
27
+		return $this
28
+			->getHttp()
29
+			->delete(
30
+				$this->makeRequestUrl($itemId),
31
+				$attributes,
32
+				$this->getHeaders()
33
+			);
34
+	}
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
src/Contracts/HttpInterface.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -4,41 +4,41 @@
 block discarded – undo
4 4
 
5 5
 interface HttpInterface
6 6
 {
7
-    /**
8
-     * @param $uri
9
-     * @param array $params
10
-     * @param array $headers
11
-     * @return array
12
-     */
13
-    public function get($uri, $params = [], $headers = []);
7
+	/**
8
+	 * @param $uri
9
+	 * @param array $params
10
+	 * @param array $headers
11
+	 * @return array
12
+	 */
13
+	public function get($uri, $params = [], $headers = []);
14 14
 
15
-    /**
16
-     * @param string $uri
17
-     * @param array $body
18
-     * @param array $headers
19
-     * @return array
20
-     */
21
-    public function post($uri, $body = [], $headers = []);
15
+	/**
16
+	 * @param string $uri
17
+	 * @param array $body
18
+	 * @param array $headers
19
+	 * @return array
20
+	 */
21
+	public function post($uri, $body = [], $headers = []);
22 22
 
23
-    /**
24
-     * @param string $uri
25
-     * @param array $body
26
-     * @param array $headers
27
-     * @return mixed
28
-     */
29
-    public function put($uri, $body = [], $headers = []);
23
+	/**
24
+	 * @param string $uri
25
+	 * @param array $body
26
+	 * @param array $headers
27
+	 * @return mixed
28
+	 */
29
+	public function put($uri, $body = [], $headers = []);
30 30
 
31
-    /**
32
-     * @param string $uri
33
-     * @param array $body
34
-     * @param array $headers
35
-     * @return mixed
36
-     */
37
-    public function delete($uri, $body = [], $headers = []);
31
+	/**
32
+	 * @param string $uri
33
+	 * @param array $body
34
+	 * @param array $headers
35
+	 * @return mixed
36
+	 */
37
+	public function delete($uri, $body = [], $headers = []);
38 38
 
39
-    /**
40
-     * @param string $url
41
-     * @return $this
42
-     */
43
-    public function setBaseUrl($url);
39
+	/**
40
+	 * @param string $url
41
+	 * @return $this
42
+	 */
43
+	public function setBaseUrl($url);
44 44
 }
45 45
\ No newline at end of file
Please login to merge, or discard this patch.