@@ -18,13 +18,15 @@ class Batch
1818 public function __construct (MailChimp $ MailChimp , $ batch_id = null )
1919 {
2020 $ this ->MailChimp = $ MailChimp ;
21- $ this ->batch_id = $ batch_id ;
21+ $ this ->batch_id = $ batch_id ;
2222 }
2323
2424 /**
2525 * Add an HTTP DELETE request operation to the batch - for deleting data
26- * @param string $id ID for the operation within the batch
26+ *
27+ * @param string $id ID for the operation within the batch
2728 * @param string $method URL of the API request method
29+ *
2830 * @return void
2931 */
3032 public function delete ($ id , $ method )
@@ -34,9 +36,11 @@ public function delete($id, $method)
3436
3537 /**
3638 * Add an HTTP GET request operation to the batch - for retrieving data
37- * @param string $id ID for the operation within the batch
39+ *
40+ * @param string $id ID for the operation within the batch
3841 * @param string $method URL of the API request method
39- * @param array $args Assoc array of arguments (usually your data)
42+ * @param array $args Assoc array of arguments (usually your data)
43+ *
4044 * @return void
4145 */
4246 public function get ($ id , $ method , $ args = array ())
@@ -46,9 +50,11 @@ public function get($id, $method, $args = array())
4650
4751 /**
4852 * Add an HTTP PATCH request operation to the batch - for performing partial updates
49- * @param string $id ID for the operation within the batch
53+ *
54+ * @param string $id ID for the operation within the batch
5055 * @param string $method URL of the API request method
51- * @param array $args Assoc array of arguments (usually your data)
56+ * @param array $args Assoc array of arguments (usually your data)
57+ *
5258 * @return void
5359 */
5460 public function patch ($ id , $ method , $ args = array ())
@@ -58,9 +64,11 @@ public function patch($id, $method, $args = array())
5864
5965 /**
6066 * Add an HTTP POST request operation to the batch - for creating and updating items
61- * @param string $id ID for the operation within the batch
67+ *
68+ * @param string $id ID for the operation within the batch
6269 * @param string $method URL of the API request method
63- * @param array $args Assoc array of arguments (usually your data)
70+ * @param array $args Assoc array of arguments (usually your data)
71+ *
6472 * @return void
6573 */
6674 public function post ($ id , $ method , $ args = array ())
@@ -70,9 +78,11 @@ public function post($id, $method, $args = array())
7078
7179 /**
7280 * Add an HTTP PUT request operation to the batch - for creating new items
73- * @param string $id ID for the operation within the batch
81+ *
82+ * @param string $id ID for the operation within the batch
7483 * @param string $method URL of the API request method
75- * @param array $args Assoc array of arguments (usually your data)
84+ * @param array $args Assoc array of arguments (usually your data)
85+ *
7686 * @return void
7787 */
7888 public function put ($ id , $ method , $ args = array ())
@@ -82,7 +92,9 @@ public function put($id, $method, $args = array())
8292
8393 /**
8494 * Execute the batch request
95+ *
8596 * @param int $timeout Request timeout in seconds (optional)
97+ *
8698 * @return array|false Assoc array of API response, decoded from JSON
8799 */
88100 public function execute ($ timeout = 10 )
@@ -101,7 +113,9 @@ public function execute($timeout = 10)
101113 /**
102114 * Check the status of a batch request. If the current instance of the Batch object
103115 * was used to make the request, the batch_id is already known and is therefore optional.
116+ *
104117 * @param string $batch_id ID of the batch about which to enquire
118+ *
105119 * @return array|false Assoc array of API response, decoded from JSON
106120 */
107121 public function check_status ($ batch_id = null )
@@ -115,7 +129,8 @@ public function check_status($batch_id = null)
115129
116130 /**
117131 * Get operations
118- * @return array
132+ *
133+ * @return array
119134 */
120135 public function get_operations ()
121136 {
@@ -124,26 +139,28 @@ public function get_operations()
124139
125140 /**
126141 * Add an operation to the internal queue.
142+ *
127143 * @param string $http_verb GET, POST, PUT, PATCH or DELETE
128- * @param string $id ID for the operation within the batch
129- * @param string $method URL of the API request method
130- * @param array $args Assoc array of arguments (usually your data)
144+ * @param string $id ID for the operation within the batch
145+ * @param string $method URL of the API request method
146+ * @param array $args Assoc array of arguments (usually your data)
147+ *
131148 * @return void
132149 */
133150 private function queueOperation ($ http_verb , $ id , $ method , $ args = null )
134151 {
135152 $ operation = array (
136153 'operation_id ' => $ id ,
137- 'method ' => $ http_verb ,
138- 'path ' => $ method ,
154+ 'method ' => $ http_verb ,
155+ 'path ' => $ method ,
139156 );
140157
141158 if ($ args ) {
142- if ($ http_verb == 'GET ' ) {
143- $ key = 'params ' ;
159+ if ($ http_verb == 'GET ' ) {
160+ $ key = 'params ' ;
144161 $ operation [$ key ] = $ args ;
145162 } else {
146- $ key = 'body ' ;
163+ $ key = 'body ' ;
147164 $ operation [$ key ] = json_encode ($ args );
148165 }
149166 }
0 commit comments