| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,61 +0,0 @@ |
| 1 |
-<?php |
|
| 2 |
- |
|
| 3 |
-namespace Telnyx\ApiOperations; |
|
| 4 |
- |
|
| 5 |
-/** |
|
| 6 |
- * Trait for resources that need to make API requests. |
|
| 7 |
- * |
|
| 8 |
- * This trait should only be applied to classes that derive from TelnyxObject. |
|
| 9 |
- */ |
|
| 10 |
-trait Request |
|
| 11 |
-{
|
|
| 12 |
- /** |
|
| 13 |
- * @param array|null|mixed $params The list of parameters to validate |
|
| 14 |
- * |
|
| 15 |
- * @throws \Telnyx\Error\Api if $params exists and is not an array |
|
| 16 |
- */ |
|
| 17 |
- protected static function _validateParams($params = null) |
|
| 18 |
- {
|
|
| 19 |
- if ($params && !is_array($params)) {
|
|
| 20 |
- $message = "You must pass an array as the first argument to Telnyx API " |
|
| 21 |
- . "method calls. (HINT: an example call to create a charge " |
|
| 22 |
- . "would be: \"Telnyx\\Charge::create(['amount' => 100, " |
|
| 23 |
- . "'currency' => 'usd', 'source' => 'tok_1234'])\")"; |
|
| 24 |
- throw new \Telnyx\Error\Api($message); |
|
| 25 |
- } |
|
| 26 |
- } |
|
| 27 |
- |
|
| 28 |
- /** |
|
| 29 |
- * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 30 |
- * @param string $url URL for the request |
|
| 31 |
- * @param array $params list of parameters for the request |
|
| 32 |
- * @param array|string|null $options |
|
| 33 |
- * |
|
| 34 |
- * @return array tuple containing (the JSON response, $options) |
|
| 35 |
- */ |
|
| 36 |
- protected function _request($method, $url, $params = [], $options = null) |
|
| 37 |
- {
|
|
| 38 |
- $opts = $this->_opts->merge($options); |
|
| 39 |
- list($resp, $options) = static::_staticRequest($method, $url, $params, $opts); |
|
| 40 |
- $this->setLastResponse($resp); |
|
| 41 |
- return [$resp->json, $options]; |
|
| 42 |
- } |
|
| 43 |
- |
|
| 44 |
- /** |
|
| 45 |
- * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 46 |
- * @param string $url URL for the request |
|
| 47 |
- * @param array $params list of parameters for the request |
|
| 48 |
- * @param array|string|null $options |
|
| 49 |
- * |
|
| 50 |
- * @return array tuple containing (the JSON response, $options) |
|
| 51 |
- */ |
|
| 52 |
- protected static function _staticRequest($method, $url, $params, $options) |
|
| 53 |
- {
|
|
| 54 |
- $opts = \Telnyx\Util\RequestOptions::parse($options); |
|
| 55 |
- $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl(); |
|
| 56 |
- $requestor = new \Telnyx\ApiRequestor($opts->apiKey, $baseUrl); |
|
| 57 |
- list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers); |
|
| 58 |
- $opts->discardNonPersistentHeaders(); |
|
| 59 |
- return [$response, $opts]; |
|
| 60 |
- } |
|
| 61 |
-} |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,61 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace Telnyx\ApiOperations; |
|
| 4 |
+ |
|
| 5 |
+/** |
|
| 6 |
+ * Trait for resources that need to make API requests. |
|
| 7 |
+ * |
|
| 8 |
+ * This trait should only be applied to classes that derive from TelnyxObject. |
|
| 9 |
+ */ |
|
| 10 |
+trait Request |
|
| 11 |
+{
|
|
| 12 |
+ /** |
|
| 13 |
+ * @param array|null|mixed $params The list of parameters to validate |
|
| 14 |
+ * |
|
| 15 |
+ * @throws \Telnyx\Error\Api if $params exists and is not an array |
|
| 16 |
+ */ |
|
| 17 |
+ protected static function _validateParams($params = null) |
|
| 18 |
+ {
|
|
| 19 |
+ if ($params && !is_array($params)) {
|
|
| 20 |
+ $message = "You must pass an array as the first argument to Telnyx API " |
|
| 21 |
+ . "method calls. (HINT: an example call to create a charge " |
|
| 22 |
+ . "would be: \"Telnyx\\Charge::create(['amount' => 100, " |
|
| 23 |
+ . "'currency' => 'usd', 'source' => 'tok_1234'])\")"; |
|
| 24 |
+ throw new \Telnyx\Error\Api($message); |
|
| 25 |
+ } |
|
| 26 |
+ } |
|
| 27 |
+ |
|
| 28 |
+ /** |
|
| 29 |
+ * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 30 |
+ * @param string $url URL for the request |
|
| 31 |
+ * @param array $params list of parameters for the request |
|
| 32 |
+ * @param array|string|null $options |
|
| 33 |
+ * |
|
| 34 |
+ * @return array tuple containing (the JSON response, $options) |
|
| 35 |
+ */ |
|
| 36 |
+ protected function _request($method, $url, $params = [], $options = null) |
|
| 37 |
+ {
|
|
| 38 |
+ $opts = $this->_opts->merge($options); |
|
| 39 |
+ list($resp, $options) = static::_staticRequest($method, $url, $params, $opts); |
|
| 40 |
+ $this->setLastResponse($resp); |
|
| 41 |
+ return [$resp->json, $options]; |
|
| 42 |
+ } |
|
| 43 |
+ |
|
| 44 |
+ /** |
|
| 45 |
+ * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 46 |
+ * @param string $url URL for the request |
|
| 47 |
+ * @param array $params list of parameters for the request |
|
| 48 |
+ * @param array|string|null $options |
|
| 49 |
+ * |
|
| 50 |
+ * @return array tuple containing (the JSON response, $options) |
|
| 51 |
+ */ |
|
| 52 |
+ protected static function _staticRequest($method, $url, $params, $options) |
|
| 53 |
+ {
|
|
| 54 |
+ $opts = \Telnyx\Util\RequestOptions::parse($options); |
|
| 55 |
+ $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl(); |
|
| 56 |
+ $requestor = new \Telnyx\ApiRequestor($opts->apiKey, $baseUrl); |
|
| 57 |
+ list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers); |
|
| 58 |
+ $opts->discardNonPersistentHeaders(); |
|
| 59 |
+ return [$response, $opts]; |
|
| 60 |
+ } |
|
| 61 |
+} |
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,61 +0,0 @@ |
| 1 |
-<?php |
|
| 2 |
- |
|
| 3 |
-namespace Telnyx\ApiOperations; |
|
| 4 |
- |
|
| 5 |
-/** |
|
| 6 |
- * Trait for resources that need to make API requests. |
|
| 7 |
- * |
|
| 8 |
- * This trait should only be applied to classes that derive from TelnyxObject. |
|
| 9 |
- */ |
|
| 10 |
-trait Request |
|
| 11 |
-{
|
|
| 12 |
- /** |
|
| 13 |
- * @param array|null|mixed $params The list of parameters to validate |
|
| 14 |
- * |
|
| 15 |
- * @throws \Telnyx\Error\Api if $params exists and is not an array |
|
| 16 |
- */ |
|
| 17 |
- protected static function _validateParams($params = null) |
|
| 18 |
- {
|
|
| 19 |
- if ($params && !is_array($params)) {
|
|
| 20 |
- $message = "You must pass an array as the first argument to Telnyx API " |
|
| 21 |
- . "method calls. (HINT: an example call to create a charge " |
|
| 22 |
- . "would be: \"Telnyx\\Charge::create(['amount' => 100, " |
|
| 23 |
- . "'currency' => 'usd', 'source' => 'tok_1234'])\")"; |
|
| 24 |
- throw new \Telnyx\Error\Api($message); |
|
| 25 |
- } |
|
| 26 |
- } |
|
| 27 |
- |
|
| 28 |
- /** |
|
| 29 |
- * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 30 |
- * @param string $url URL for the request |
|
| 31 |
- * @param array $params list of parameters for the request |
|
| 32 |
- * @param array|string|null $options |
|
| 33 |
- * |
|
| 34 |
- * @return array tuple containing (the JSON response, $options) |
|
| 35 |
- */ |
|
| 36 |
- protected function _request($method, $url, $params = [], $options = null) |
|
| 37 |
- {
|
|
| 38 |
- $opts = $this->_opts->merge($options); |
|
| 39 |
- list($resp, $options) = static::_staticRequest($method, $url, $params, $opts); |
|
| 40 |
- $this->setLastResponse($resp); |
|
| 41 |
- return [$resp->json, $options]; |
|
| 42 |
- } |
|
| 43 |
- |
|
| 44 |
- /** |
|
| 45 |
- * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 46 |
- * @param string $url URL for the request |
|
| 47 |
- * @param array $params list of parameters for the request |
|
| 48 |
- * @param array|string|null $options |
|
| 49 |
- * |
|
| 50 |
- * @return array tuple containing (the JSON response, $options) |
|
| 51 |
- */ |
|
| 52 |
- protected static function _staticRequest($method, $url, $params, $options) |
|
| 53 |
- {
|
|
| 54 |
- $opts = \Telnyx\Util\RequestOptions::parse($options); |
|
| 55 |
- $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl(); |
|
| 56 |
- $requestor = new \Telnyx\ApiRequestor($opts->apiKey, $baseUrl); |
|
| 57 |
- list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers); |
|
| 58 |
- $opts->discardNonPersistentHeaders(); |
|
| 59 |
- return [$response, $opts]; |
|
| 60 |
- } |
|
| 61 |
-} |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,61 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace Telnyx\ApiOperations; |
|
| 4 |
+ |
|
| 5 |
+/** |
|
| 6 |
+ * Trait for resources that need to make API requests. |
|
| 7 |
+ * |
|
| 8 |
+ * This trait should only be applied to classes that derive from TelnyxObject. |
|
| 9 |
+ */ |
|
| 10 |
+trait Request |
|
| 11 |
+{
|
|
| 12 |
+ /** |
|
| 13 |
+ * @param array|null|mixed $params The list of parameters to validate |
|
| 14 |
+ * |
|
| 15 |
+ * @throws \Telnyx\Error\Api if $params exists and is not an array |
|
| 16 |
+ */ |
|
| 17 |
+ protected static function _validateParams($params = null) |
|
| 18 |
+ {
|
|
| 19 |
+ if ($params && !is_array($params)) {
|
|
| 20 |
+ $message = "You must pass an array as the first argument to Telnyx API " |
|
| 21 |
+ . "method calls. (HINT: an example call to create a charge " |
|
| 22 |
+ . "would be: \"Telnyx\\Charge::create(['amount' => 100, " |
|
| 23 |
+ . "'currency' => 'usd', 'source' => 'tok_1234'])\")"; |
|
| 24 |
+ throw new \Telnyx\Error\Api($message); |
|
| 25 |
+ } |
|
| 26 |
+ } |
|
| 27 |
+ |
|
| 28 |
+ /** |
|
| 29 |
+ * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 30 |
+ * @param string $url URL for the request |
|
| 31 |
+ * @param array $params list of parameters for the request |
|
| 32 |
+ * @param array|string|null $options |
|
| 33 |
+ * |
|
| 34 |
+ * @return array tuple containing (the JSON response, $options) |
|
| 35 |
+ */ |
|
| 36 |
+ protected function _request($method, $url, $params = [], $options = null) |
|
| 37 |
+ {
|
|
| 38 |
+ $opts = $this->_opts->merge($options); |
|
| 39 |
+ list($resp, $options) = static::_staticRequest($method, $url, $params, $opts); |
|
| 40 |
+ $this->setLastResponse($resp); |
|
| 41 |
+ return [$resp->json, $options]; |
|
| 42 |
+ } |
|
| 43 |
+ |
|
| 44 |
+ /** |
|
| 45 |
+ * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 46 |
+ * @param string $url URL for the request |
|
| 47 |
+ * @param array $params list of parameters for the request |
|
| 48 |
+ * @param array|string|null $options |
|
| 49 |
+ * |
|
| 50 |
+ * @return array tuple containing (the JSON response, $options) |
|
| 51 |
+ */ |
|
| 52 |
+ protected static function _staticRequest($method, $url, $params, $options) |
|
| 53 |
+ {
|
|
| 54 |
+ $opts = \Telnyx\Util\RequestOptions::parse($options); |
|
| 55 |
+ $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl(); |
|
| 56 |
+ $requestor = new \Telnyx\ApiRequestor($opts->apiKey, $baseUrl); |
|
| 57 |
+ list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers); |
|
| 58 |
+ $opts->discardNonPersistentHeaders(); |
|
| 59 |
+ return [$response, $opts]; |
|
| 60 |
+ } |
|
| 61 |
+} |
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,61 +0,0 @@ |
| 1 |
-<?php |
|
| 2 |
- |
|
| 3 |
-namespace Telnyx\ApiOperations; |
|
| 4 |
- |
|
| 5 |
-/** |
|
| 6 |
- * Trait for resources that need to make API requests. |
|
| 7 |
- * |
|
| 8 |
- * This trait should only be applied to classes that derive from TelnyxObject. |
|
| 9 |
- */ |
|
| 10 |
-trait Request |
|
| 11 |
-{
|
|
| 12 |
- /** |
|
| 13 |
- * @param array|null|mixed $params The list of parameters to validate |
|
| 14 |
- * |
|
| 15 |
- * @throws \Telnyx\Error\Api if $params exists and is not an array |
|
| 16 |
- */ |
|
| 17 |
- protected static function _validateParams($params = null) |
|
| 18 |
- {
|
|
| 19 |
- if ($params && !is_array($params)) {
|
|
| 20 |
- $message = "You must pass an array as the first argument to Telnyx API " |
|
| 21 |
- . "method calls. (HINT: an example call to create a charge " |
|
| 22 |
- . "would be: \"Telnyx\\Charge::create(['amount' => 100, " |
|
| 23 |
- . "'currency' => 'usd', 'source' => 'tok_1234'])\")"; |
|
| 24 |
- throw new \Telnyx\Error\Api($message); |
|
| 25 |
- } |
|
| 26 |
- } |
|
| 27 |
- |
|
| 28 |
- /** |
|
| 29 |
- * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 30 |
- * @param string $url URL for the request |
|
| 31 |
- * @param array $params list of parameters for the request |
|
| 32 |
- * @param array|string|null $options |
|
| 33 |
- * |
|
| 34 |
- * @return array tuple containing (the JSON response, $options) |
|
| 35 |
- */ |
|
| 36 |
- protected function _request($method, $url, $params = [], $options = null) |
|
| 37 |
- {
|
|
| 38 |
- $opts = $this->_opts->merge($options); |
|
| 39 |
- list($resp, $options) = static::_staticRequest($method, $url, $params, $opts); |
|
| 40 |
- $this->setLastResponse($resp); |
|
| 41 |
- return [$resp->json, $options]; |
|
| 42 |
- } |
|
| 43 |
- |
|
| 44 |
- /** |
|
| 45 |
- * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 46 |
- * @param string $url URL for the request |
|
| 47 |
- * @param array $params list of parameters for the request |
|
| 48 |
- * @param array|string|null $options |
|
| 49 |
- * |
|
| 50 |
- * @return array tuple containing (the JSON response, $options) |
|
| 51 |
- */ |
|
| 52 |
- protected static function _staticRequest($method, $url, $params, $options) |
|
| 53 |
- {
|
|
| 54 |
- $opts = \Telnyx\Util\RequestOptions::parse($options); |
|
| 55 |
- $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl(); |
|
| 56 |
- $requestor = new \Telnyx\ApiRequestor($opts->apiKey, $baseUrl); |
|
| 57 |
- list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers); |
|
| 58 |
- $opts->discardNonPersistentHeaders(); |
|
| 59 |
- return [$response, $opts]; |
|
| 60 |
- } |
|
| 61 |
-} |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,61 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace Telnyx\ApiOperations; |
|
| 4 |
+ |
|
| 5 |
+/** |
|
| 6 |
+ * Trait for resources that need to make API requests. |
|
| 7 |
+ * |
|
| 8 |
+ * This trait should only be applied to classes that derive from TelnyxObject. |
|
| 9 |
+ */ |
|
| 10 |
+trait Request |
|
| 11 |
+{
|
|
| 12 |
+ /** |
|
| 13 |
+ * @param array|null|mixed $params The list of parameters to validate |
|
| 14 |
+ * |
|
| 15 |
+ * @throws \Telnyx\Error\Api if $params exists and is not an array |
|
| 16 |
+ */ |
|
| 17 |
+ protected static function _validateParams($params = null) |
|
| 18 |
+ {
|
|
| 19 |
+ if ($params && !is_array($params)) {
|
|
| 20 |
+ $message = "You must pass an array as the first argument to Telnyx API " |
|
| 21 |
+ . "method calls. (HINT: an example call to create a charge " |
|
| 22 |
+ . "would be: \"Telnyx\\Charge::create(['amount' => 100, " |
|
| 23 |
+ . "'currency' => 'usd', 'source' => 'tok_1234'])\")"; |
|
| 24 |
+ throw new \Telnyx\Error\Api($message); |
|
| 25 |
+ } |
|
| 26 |
+ } |
|
| 27 |
+ |
|
| 28 |
+ /** |
|
| 29 |
+ * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 30 |
+ * @param string $url URL for the request |
|
| 31 |
+ * @param array $params list of parameters for the request |
|
| 32 |
+ * @param array|string|null $options |
|
| 33 |
+ * |
|
| 34 |
+ * @return array tuple containing (the JSON response, $options) |
|
| 35 |
+ */ |
|
| 36 |
+ protected function _request($method, $url, $params = [], $options = null) |
|
| 37 |
+ {
|
|
| 38 |
+ $opts = $this->_opts->merge($options); |
|
| 39 |
+ list($resp, $options) = static::_staticRequest($method, $url, $params, $opts); |
|
| 40 |
+ $this->setLastResponse($resp); |
|
| 41 |
+ return [$resp->json, $options]; |
|
| 42 |
+ } |
|
| 43 |
+ |
|
| 44 |
+ /** |
|
| 45 |
+ * @param string $method HTTP method ('get', 'post', etc.)
|
|
| 46 |
+ * @param string $url URL for the request |
|
| 47 |
+ * @param array $params list of parameters for the request |
|
| 48 |
+ * @param array|string|null $options |
|
| 49 |
+ * |
|
| 50 |
+ * @return array tuple containing (the JSON response, $options) |
|
| 51 |
+ */ |
|
| 52 |
+ protected static function _staticRequest($method, $url, $params, $options) |
|
| 53 |
+ {
|
|
| 54 |
+ $opts = \Telnyx\Util\RequestOptions::parse($options); |
|
| 55 |
+ $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl(); |
|
| 56 |
+ $requestor = new \Telnyx\ApiRequestor($opts->apiKey, $baseUrl); |
|
| 57 |
+ list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers); |
|
| 58 |
+ $opts->discardNonPersistentHeaders(); |
|
| 59 |
+ return [$response, $opts]; |
|
| 60 |
+ } |
|
| 61 |
+} |