@@ -19,8 +19,7 @@ class ZohoModule
1919 * @param ZCRMRestClient $rest
2020 * @param $module_api_name
2121 */
22- public function __construct ($ rest , $ module_api_name )
23- {
22+ public function __construct ($ rest , $ module_api_name ) {
2423 $ this ->rest = $ rest ;
2524 $ this ->module_api_name = $ module_api_name ;
2625 $ this ->moduleIns = $ this ->getModuleInstance ();
@@ -31,8 +30,7 @@ public function __construct($rest, $module_api_name)
3130 *
3231 * @return ZCRMModule[]
3332 */
34- public function getAllModules ()
35- {
33+ public function getAllModules () {
3634 return $ this ->rest ->getAllModules ()->getData ();
3735 }
3836
@@ -41,29 +39,28 @@ public function getAllModules()
4139 *
4240 * @return ZCRMModule|object
4341 */
44- public function getModule ()
45- {
42+ public function getModule () {
4643 return $ this ->rest ->getModule ($ this ->module_api_name )->getData ();
4744 }
4845
4946 /**
5047 * get record instance
5148 *
5249 * @param $record_id
50+ *
5351 * @return ZCRMRecord
5452 */
55- public function getRecordInstance ($ record_id = null )
56- {
57- return $ this -> rest -> getRecordInstance ( $ this -> module_api_name , $ record_id );
53+ public function getRecordInstance ($ record_id = null ) {
54+ return $ this -> rest -> getRecordInstance ( $ this -> module_api_name ,
55+ $ record_id );
5856 }
5957
6058 /**
6159 * get dummy module object
6260 *
6361 * @return ZCRMModule
6462 */
65- public function getModuleInstance ()
66- {
63+ public function getModuleInstance () {
6764 return $ this ->rest ->getModuleInstance ($ this ->module_api_name );
6865 }
6966
@@ -72,133 +69,158 @@ public function getModuleInstance()
7269 *
7370 * @return ZCRMRecord[]
7471 */
75- public function getRecords ()
76- {
72+ public function getRecords () {
7773 return $ this ->moduleIns ->getRecords ()->getData ();
7874 }
7975
8076 /**
8177 * get the record object of given module api name and record id
8278 *
8379 * @param string $record_id
80+ *
8481 * @return object|ZCRMRecord
8582 */
86- public function getRecord ($ record_id )
87- {
83+ public function getRecord ($ record_id ) {
8884 return $ this ->moduleIns ->getRecord ($ record_id )->getData ();
8985 }
9086
9187 /**
9288 * get module records
9389 *
94- * @param string $word //word to be searched
95- * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
96- * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
90+ * @param string $word //word to be searched
91+ * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
92+ * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
93+ *
9794 * @return ZCRMRecord[]
9895 */
99- public function searchRecordsByWord ($ word = '' , $ page = 1 , $ perPage = 200 )
100- {
96+ public function searchRecordsByWord ($ word = '' , $ page = 1 , $ perPage = 200 ) {
10197 $ param_map = ["page " => $ page , "per_page " => $ perPage ];
102- return $ this ->moduleIns ->searchRecordsByWord ($ word , $ param_map )->getData ();
98+
99+ return $ this ->moduleIns ->searchRecordsByWord ($ word , $ param_map )
100+ ->getData ();
103101 }
104102
105103 /**
106104 * get module records
107105 *
108- * @param string $phone //phone to be searched
109- * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
110- * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
106+ * @param string $phone //phone to be searched
107+ * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
108+ * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
109+ *
111110 * @return ZCRMRecord[]
112111 */
113- public function searchRecordsByPhone ($ phone = '' , $ page = 1 , $ perPage = 200 )
114- {
112+ public function searchRecordsByPhone (
113+ $ phone = '' ,
114+ $ page = 1 ,
115+ $ perPage = 200
116+ ) {
115117 $ param_map = ["page " => $ page , "per_page " => $ perPage ];
116- return $ this ->moduleIns ->searchRecordsByPhone ($ phone , $ param_map )->getData ();
118+
119+ return $ this ->moduleIns ->searchRecordsByPhone ($ phone , $ param_map )
120+ ->getData ();
117121 }
118122
119123 /**
120124 * get module records
121125 *
122- * @param string $email //email to be searched
123- * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
124- * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
126+ * @param string $email //email to be searched
127+ * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
128+ * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
129+ *
125130 * @return ZCRMRecord[]
126131 */
127- public function searchRecordsByEmail ($ email = '' , $ page = 1 , $ perPage = 200 )
128- {
132+ public function searchRecordsByEmail (
133+ $ email = '' ,
134+ $ page = 1 ,
135+ $ perPage = 200
136+ ) {
129137 $ param_map = ["page " => $ page , "per_page " => $ perPage ];
130- return $ this ->moduleIns ->searchRecordsByEmail ($ email , $ param_map )->getData ();
138+
139+ return $ this ->moduleIns ->searchRecordsByEmail ($ email , $ param_map )
140+ ->getData ();
131141 }
132142
133143 /**
134144 * get module records
135145 *
136- * @param string $criteria //criteria to search for
137- * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
138- * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
146+ * @param string $criteria //criteria to search for
147+ * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
148+ * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
149+ *
139150 * @return ZCRMRecord[]
140151 */
141- public function searchRecordsByCriteria ($ criteria , $ page = 1 , $ perPage = 200 )
142- {
152+ public function searchRecordsByCriteria (
153+ $ criteria ,
154+ $ page = 1 ,
155+ $ perPage = 200
156+ ) {
143157 $ param_map = ["page " => $ page , "per_page " => $ perPage ];
144- return $ this ->moduleIns ->searchRecordsByCriteria ($ criteria , $ param_map )->getData ();
158+
159+ return $ this ->moduleIns ->searchRecordsByCriteria ($ criteria , $ param_map )
160+ ->getData ();
145161 }
146162
147163 /**
148164 * Add new entities to a module.
149165 *
150166 * @param ZCRMRecord $record
167+ * @param string|null $trigger array of triggers
168+ *
151169 * @return ZCRMRecord[]
152170 */
153- public function insert ($ record )
154- {
171+ public function insert ($ record , string $ trigger = null ) {
155172 $ records = [];
156173
157174 array_push ($ records , $ record );
158- return $ this ->moduleIns ->createRecords ($ records )->getData ();
175+
176+ return $ this ->moduleIns ->createRecords ($ records , $ trigger )->getData ();
159177 }
160178
161179 /**
162180 * create record instance that contains the array keys and values
163181 *
164182 * @param array $args
183+ * @param string|null $trigger array of triggers
184+ *
165185 * @return object
166186 */
167- public function create ($ args = [])
168- {
187+ public function create (array $ args = [], string $ trigger = null ) {
169188 $ record = $ this ->getRecordInstance ();
170189
171- foreach ($ args as $ key => $ value ) {
190+ foreach ($ args as $ key => $ value ) {
172191 $ record ->setFieldValue ($ key , $ value );
173192 }
174193
175- return $ record ->create ()->getData ();
194+ return $ record ->create ($ trigger )->getData ();
176195 }
177196
178197 /**
179198 * update existing entities in the module.
180199 *
181200 * @param ZCRMRecord $record
201+ * @param string $trigger array of triggers
202+ *
182203 * @return ZCRMRecord[]
183204 */
184- public function update ($ record )
185- {
205+ public function update ($ record , $ trigger = null ) {
186206 $ records = [];
187207
188208 array_push ($ records , $ record );
189- return $ this ->moduleIns ->updateRecords ($ records )->getData ();
209+
210+ return $ this ->moduleIns ->updateRecords ($ records , $ trigger )->getData ();
190211 }
191212
192213 /**
193214 * @param CriteriaBuilder $builder
194- * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
195- * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
215+ * @param int $page //to get the list of records from the respective pages. Default value for page is 1.
216+ * @param int $perPage //To get the list of records available per page. Default value for per page is 200.
217+ *
196218 * @return ZCRMRecord[]
197219 */
198- public function search ($ builder , $ page = 1 , $ perPage = 200 )
199- {
200- if ($ builder ->toString () !== "" ) {
201- return $ this -> searchRecordsByCriteria ( $ builder -> toString (), $ page , $ perPage );
220+ public function search ($ builder , $ page = 1 , $ perPage = 200 ) {
221+ if ( $ builder -> toString () !== "" ) {
222+ return $ this -> searchRecordsByCriteria ($ builder ->toString (), $ page ,
223+ $ perPage );
202224 }
203225
204226 return null ;
0 commit comments