Browse code

removed Telnyx Plivo Twilio Flowroute appinfo/info.xml appinfo/signature.json README.md lib/Controller/AuthorApiController.php

DoubleBastionAdmin authored on 20/08/2022 16:26:33
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,162 +0,0 @@
1
-<?php
2
-
3
-namespace Plivo\Tests;
4
-
5
-
6
-use GuzzleHttp\Client;
7
-
8
-
9
-use Plivo\Authentication\BasicAuth;
10
-use Plivo\Http\PlivoRequest;
11
-use Plivo\Http\PlivoResponse;
12
-use Plivo\HttpClients\PlivoHttpClientInterface;
13
-
14
-
15
-/**
16
- * Class TestClient
17
- * @package Plivo\Tests
18
- *
19
- * @method null mock(PlivoResponse $response)
20
- */
21
-class TestClient implements PlivoHttpClientInterface
22
-{
23
-    /**
24
-     * @var array
25
-     */
26
-    private $requests = [];
27
-    /**
28
-     * @var null
29
-     */
30
-    private $response = null;
31
-
32
-    /**
33
-     * @var Client
34
-     */
35
-    protected $guzzleClient;
36
-    /**
37
-     * @var string
38
-     */
39
-    protected $authId;
40
-    /**
41
-     * @var string
42
-     */
43
-    protected $authToken;
44
-
45
-    /**
46
-     * @param \GuzzleHttp\Client|null The Guzzle client.
47
-     * @param \Plivo\Authentication\BasicAuth|null Authentication details.
48
-     * @param \GuzzleHttp\Client|null Handler.
49
-     */
50
-    public function __construct(Client $guzzleClient = null, BasicAuth $basicAuth = null)
51
-    {
52
-        if (!is_null($basicAuth)) {
53
-            $this->authId = $basicAuth->getAuthId();
54
-            $this->authToken = $basicAuth->getAuthToken();
55
-        }
56
-        $this->guzzleClient = $guzzleClient ?: new Client();
57
-
58
-    }
59
-
60
-    /**
61
-     * @param $name
62
-     * @param $arguments
63
-     * @return mixed
64
-     */
65
-    public function __call($name, $arguments) {
66
-        $method = $name.'Response';
67
-        if (method_exists($this, $method)) {
68
-            return call_user_func_array([$this, $method], $arguments);
69
-        }
70
-    }
71
-
72
-    /**
73
-     * @param string $url
74
-     * @param string $method
75
-     * @param string $body
76
-     * @param array $headers
77
-     * @param null $timeout
78
-     * @param mixed $request
79
-     * @return null|PlivoResponse
80
-     */
81
-    public function send_request($url, $method, $body, $headers = [], $timeout = null, $request)
82
-    {
83
-        //$headers["Authorization"] = "Basic " . base64_encode("$this->authId:$this->authToken");
84
-
85
-        $request->setHeaders($headers);
86
-
87
-        array_push($this->requests, $request);
88
-
89
-        if ($this->response == null) {
90
-            return new PlivoResponse(null, 404, null);
91
-        } else {
92
-            return $this->response;
93
-        }
94
-    }
95
-
96
-    /**
97
-     * @return mixed
98
-     */
99
-    public function lastRequest()
100
-    {
101
-        return $this->requests[count($this->requests)-1];
102
-    }
103
-
104
-    /**
105
-     * @param $response PlivoResponse
106
-     */
107
-    protected function mockResponse($response) {
108
-        $this->response = $response;
109
-    }
110
-
111
-    /**
112
-     * @param $request PlivoRequest
113
-     */
114
-    public function assertRequest($request) {
115
-        if ($this->hasRequest($request)) {
116
-            return;
117
-        }
118
-
119
-        $message = "Failed asserting that the following request exists: \n";
120
-        $message .= ' - ' . $this->printRequest($request);
121
-        $message .= "\n" . str_repeat('-', 3) . "\n";
122
-        $message .= "Candidate Requests:\n";
123
-        foreach ($this->requests as $candidate) {
124
-            $message .= ' + ' . $this->printRequest($candidate) . "\n";
125
-        }
126
-
127
-        throw new \PHPUnit_Framework_ExpectationFailedException($message);
128
-    }
129
-
130
-    /**
131
-     * @param PlivoRequest $request
132
-     * @return bool
133
-     */
134
-    public function hasRequest($request) {
135
-        for ($i = 0; $i < count($this->requests); $i++) {
136
-            $c = $this->requests[$i];
137
-            if (strtolower($request->method) === strtolower($c->method) &&
138
-                $request->endpoint === $c->endpoint &&
139
-                $request->params === $c->params &&
140
-                $request->headers === $c->headers) {
141
-                return true;
142
-            }
143
-        }
144
-
145
-        return false;
146
-    }
147
-
148
-    /**
149
-     * @param $request
150
-     * @return string
151
-     */
152
-    protected function printRequest($request) {
153
-        $url = $request->endpoint;
154
-        if (($request->method !== 'POST') && (count($request->params) !== 0)) {
155
-            $url .= '?' . http_build_query($request->params);
156
-        }
157
-        $data = count($request->postParams) !== 0
158
-            ? '-d ' . json_encode($request->params)
159
-            : '';
160
-        return implode(' ', [strtoupper($request->method), $url, $data]);
161
-    }
162
-}
163 0
\ No newline at end of file
Browse code

Created repository.

DoubleBastionAdmin authored on 01/03/2022 23:47:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,162 @@
1
+<?php
2
+
3
+namespace Plivo\Tests;
4
+
5
+
6
+use GuzzleHttp\Client;
7
+
8
+
9
+use Plivo\Authentication\BasicAuth;
10
+use Plivo\Http\PlivoRequest;
11
+use Plivo\Http\PlivoResponse;
12
+use Plivo\HttpClients\PlivoHttpClientInterface;
13
+
14
+
15
+/**
16
+ * Class TestClient
17
+ * @package Plivo\Tests
18
+ *
19
+ * @method null mock(PlivoResponse $response)
20
+ */
21
+class TestClient implements PlivoHttpClientInterface
22
+{
23
+    /**
24
+     * @var array
25
+     */
26
+    private $requests = [];
27
+    /**
28
+     * @var null
29
+     */
30
+    private $response = null;
31
+
32
+    /**
33
+     * @var Client
34
+     */
35
+    protected $guzzleClient;
36
+    /**
37
+     * @var string
38
+     */
39
+    protected $authId;
40
+    /**
41
+     * @var string
42
+     */
43
+    protected $authToken;
44
+
45
+    /**
46
+     * @param \GuzzleHttp\Client|null The Guzzle client.
47
+     * @param \Plivo\Authentication\BasicAuth|null Authentication details.
48
+     * @param \GuzzleHttp\Client|null Handler.
49
+     */
50
+    public function __construct(Client $guzzleClient = null, BasicAuth $basicAuth = null)
51
+    {
52
+        if (!is_null($basicAuth)) {
53
+            $this->authId = $basicAuth->getAuthId();
54
+            $this->authToken = $basicAuth->getAuthToken();
55
+        }
56
+        $this->guzzleClient = $guzzleClient ?: new Client();
57
+
58
+    }
59
+
60
+    /**
61
+     * @param $name
62
+     * @param $arguments
63
+     * @return mixed
64
+     */
65
+    public function __call($name, $arguments) {
66
+        $method = $name.'Response';
67
+        if (method_exists($this, $method)) {
68
+            return call_user_func_array([$this, $method], $arguments);
69
+        }
70
+    }
71
+
72
+    /**
73
+     * @param string $url
74
+     * @param string $method
75
+     * @param string $body
76
+     * @param array $headers
77
+     * @param null $timeout
78
+     * @param mixed $request
79
+     * @return null|PlivoResponse
80
+     */
81
+    public function send_request($url, $method, $body, $headers = [], $timeout = null, $request)
82
+    {
83
+        //$headers["Authorization"] = "Basic " . base64_encode("$this->authId:$this->authToken");
84
+
85
+        $request->setHeaders($headers);
86
+
87
+        array_push($this->requests, $request);
88
+
89
+        if ($this->response == null) {
90
+            return new PlivoResponse(null, 404, null);
91
+        } else {
92
+            return $this->response;
93
+        }
94
+    }
95
+
96
+    /**
97
+     * @return mixed
98
+     */
99
+    public function lastRequest()
100
+    {
101
+        return $this->requests[count($this->requests)-1];
102
+    }
103
+
104
+    /**
105
+     * @param $response PlivoResponse
106
+     */
107
+    protected function mockResponse($response) {
108
+        $this->response = $response;
109
+    }
110
+
111
+    /**
112
+     * @param $request PlivoRequest
113
+     */
114
+    public function assertRequest($request) {
115
+        if ($this->hasRequest($request)) {
116
+            return;
117
+        }
118
+
119
+        $message = "Failed asserting that the following request exists: \n";
120
+        $message .= ' - ' . $this->printRequest($request);
121
+        $message .= "\n" . str_repeat('-', 3) . "\n";
122
+        $message .= "Candidate Requests:\n";
123
+        foreach ($this->requests as $candidate) {
124
+            $message .= ' + ' . $this->printRequest($candidate) . "\n";
125
+        }
126
+
127
+        throw new \PHPUnit_Framework_ExpectationFailedException($message);
128
+    }
129
+
130
+    /**
131
+     * @param PlivoRequest $request
132
+     * @return bool
133
+     */
134
+    public function hasRequest($request) {
135
+        for ($i = 0; $i < count($this->requests); $i++) {
136
+            $c = $this->requests[$i];
137
+            if (strtolower($request->method) === strtolower($c->method) &&
138
+                $request->endpoint === $c->endpoint &&
139
+                $request->params === $c->params &&
140
+                $request->headers === $c->headers) {
141
+                return true;
142
+            }
143
+        }
144
+
145
+        return false;
146
+    }
147
+
148
+    /**
149
+     * @param $request
150
+     * @return string
151
+     */
152
+    protected function printRequest($request) {
153
+        $url = $request->endpoint;
154
+        if (($request->method !== 'POST') && (count($request->params) !== 0)) {
155
+            $url .= '?' . http_build_query($request->params);
156
+        }
157
+        $data = count($request->postParams) !== 0
158
+            ? '-d ' . json_encode($request->params)
159
+            : '';
160
+        return implode(' ', [strtoupper($request->method), $url, $data]);
161
+    }
162
+}
0 163
\ No newline at end of file