@@ 172-200 (lines=29) @@ | ||
169 | * @return Result |
|
170 | * @throws Exception |
|
171 | */ |
|
172 | public function update($experimentId, $experiment, $overrideChanges, $publish) |
|
173 | { |
|
174 | if (!is_int($experimentId)) { |
|
175 | throw new Exception("Expected argument of type Experiment"); |
|
176 | } |
|
177 | ||
178 | if ($experimentId<0) { |
|
179 | throw new Exception("Expected positive experiment ID argument"); |
|
180 | } |
|
181 | ||
182 | if (!($experiment instanceOf Experiment)) { |
|
183 | throw new Exception("Expected argument of type Experiment"); |
|
184 | } |
|
185 | ||
186 | $queryParams = array( |
|
187 | 'override_changes' => $overrideChanges, |
|
188 | 'publish' => $publish |
|
189 | ); |
|
190 | ||
191 | $postData = $experiment->toArray(); |
|
192 | ||
193 | $result = $this->client->sendApiRequest("/experiments/$experimentId", $queryParams, 'PATCH', |
|
194 | $postData); |
|
195 | ||
196 | $experiment = new Experiment($result->getDecodedJsonData()); |
|
197 | $result->setPayload($experiment); |
|
198 | ||
199 | return $result; |
|
200 | } |
|
201 | ||
202 | /** |
|
203 | * Delete Experiment by ID |
@@ 115-140 (lines=26) @@ | ||
112 | * @return Result |
|
113 | * @throws Exception |
|
114 | */ |
|
115 | public function update($projectId, $project) |
|
116 | { |
|
117 | $projectId = (string)$projectId; |
|
118 | ||
119 | if (!preg_match('/\d+/', $projectId)) { |
|
120 | throw new Exception("A positive integer project ID expected, while got $projectId"); |
|
121 | } |
|
122 | ||
123 | if ($projectId<0) { |
|
124 | throw new Exception("A positive project ID expected"); |
|
125 | } |
|
126 | ||
127 | if (!($project instanceOf Project)) { |
|
128 | throw new Exception("Expected argument of type Project"); |
|
129 | } |
|
130 | ||
131 | $postData = $project->toArray(); |
|
132 | ||
133 | $result = $this->client->sendApiRequest("/projects/$projectId", array(), |
|
134 | 'PATCH', $postData); |
|
135 | ||
136 | $project = new Project($result->getDecodedJsonData()); |
|
137 | $result->setPayload($project); |
|
138 | ||
139 | return $result; |
|
140 | } |
|
141 | } |
|
142 | ||
143 |