88use MRussell \Http \Request \JSON ;
99use MRussell \Http \Request \RequestInterface ;
1010use MRussell \Http \Response \ResponseInterface ;
11+ use MRussell \REST \Endpoint \Data \EndpointData ;
1112use MRussell \REST \Endpoint \JSON \ModelEndpoint ;
1213use Sugarcrm \REST \Endpoint \Data \FilterData ;
1314use Sugarcrm \REST \Endpoint \SugarEndpointInterface ;
1415
16+ /**
17+ * SugarBean Endpoint acts as a base for any given Module API
18+ * - Provides action based interface for accessing stock and custom actions
19+ * @package Sugarcrm\REST\Endpoint\Abstracts
20+ * @method $this filterLink(string $link_name = '',string $count = '')
21+ * @method $this massLink(string $link_name)
22+ * @method $this createLink(string $link_name)
23+ * @method $this unlink(string $link_name,string $record_id)
24+ * @method $this favorite()
25+ * @method $this unfavorite()
26+ * @method $this subscribe()
27+ * @method $this unsubscribe()
28+ * @method $this audit()
29+ * @method $this file()
30+ * @method $this downloadFile(string $field)
31+ */
1532abstract class AbstractSugarBeanEndpoint extends ModelEndpoint implements SugarEndpointInterface
1633{
1734 const MODEL_ACTION_VAR = 'action ' ;
@@ -56,10 +73,10 @@ abstract class AbstractSugarBeanEndpoint extends ModelEndpoint implements SugarE
5673 * @inheritdoc
5774 */
5875 protected static $ _DEFAULT_PROPERTIES = array (
59- ' auth ' => TRUE ,
60- ' data ' => array (
61- ' required ' => array (),
62- ' defaults ' => array ()
76+ self :: PROPERTY_AUTH => TRUE ,
77+ self :: PROPERTY_DATA => array (
78+ EndpointData:: DATA_PROPERTY_REQUIRED => array (),
79+ EndpointData:: DATA_PROPERTY_DEFAULTS => array ()
6380 )
6481 );
6582
@@ -81,7 +98,7 @@ abstract class AbstractSugarBeanEndpoint extends ModelEndpoint implements SugarE
8198 self ::BEAN_ACTION_UNLINK => JSON ::HTTP_DELETE ,
8299 self ::BEAN_ACTION_CREATE_RELATED => JSON ::HTTP_POST ,
83100 self ::BEAN_ACTION_FOLLOW => JSON ::HTTP_POST ,
84- self ::BEAN_ACTION_UNFOLLOW => JSON ::HTTP_PUT ,
101+ self ::BEAN_ACTION_UNFOLLOW => JSON ::HTTP_DELETE ,
85102 self ::BEAN_ACTION_AUDIT => JSON ::HTTP_GET ,
86103 self ::BEAN_ACTION_FILE => JSON ::HTTP_GET ,
87104 self ::BEAN_ACTION_DOWNLOAD_FILE => JSON ::HTTP_GET ,
@@ -305,6 +322,24 @@ protected function updateModel()
305322 }
306323 }
307324
325+ /**
326+ * System friendly name for subscribing to a record
327+ * @return self
328+ */
329+ public function follow ()
330+ {
331+ return $ this ->subscribe ();
332+ }
333+
334+ /**
335+ * System friendly name for unsubscribing to a record
336+ * @return self
337+ */
338+ public function unfollow ()
339+ {
340+ return $ this ->unsubscribe ();
341+ }
342+
308343 /**
309344 * Human friendly method name for Link action
310345 * @param string $linkName - Relationship Link Name
@@ -398,6 +433,7 @@ public function attachFile($fileField,$filePath,$deleteOnFail = false,$mimeType
398433 }
399434
400435 /**
436+ * Overloading tempFile dynamic method to provide more functionality
401437 * @param $fileField
402438 * @param $filePath
403439 * @param bool $deleteOnFail
0 commit comments