Browse code

Added README.md appinfo/info.xml appinfo/signature.json lib/Controller/AuthorApiController.php and the providers directory

DoubleBastionAdmin authored on 20/08/2022 16:33:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+namespace Telnyx\ApiOperations;
4
+
5
+/**
6
+ * Trait for retrievable resources. Adds a `retrieve()` static method to the
7
+ * class.
8
+ *
9
+ * This trait should only be applied to classes that derive from TelnyxObject.
10
+ */
11
+trait Retrieve
12
+{
13
+    /**
14
+     * @param array|string $id The ID of the API resource to retrieve,
15
+     *     or an options array containing an `id` key.
16
+     * @param array|string|null $opts
17
+     *
18
+     * @return \Telnyx\TelnyxObject
19
+     */
20
+    public static function retrieve($id, $opts = null)
21
+    {
22
+        $opts = \Telnyx\Util\RequestOptions::parse($opts);
23
+        $instance = new static($id, $opts);
24
+        $instance->refresh();
25
+
26
+        // If 'id' is called something else like 'call_control_id'
27
+        $class = get_class($instance);
28
+        if (defined($class . '::OBJECT_ID')) {
29
+            $instance->reassignId(static::OBJECT_ID);
30
+        }
31
+
32
+        return $instance;
33
+    }
34
+}