| @@ 145-170 (lines=26) @@ | ||
| 142 | * @param boolean $publish Whether to publish the changes to the world. |
|
| 143 | * @throws \Exception |
|
| 144 | */ |
|
| 145 | public function update($experimentId, $experiment, $overrideChanges, $publish) |
|
| 146 | { |
|
| 147 | if (!is_int($experimentId)) { |
|
| 148 | throw new \Exception("Expected argument of type Experiment"); |
|
| 149 | } |
|
| 150 | ||
| 151 | if ($experimentId<0) { |
|
| 152 | throw new \Exception("Expected positive experiment ID argument"); |
|
| 153 | } |
|
| 154 | ||
| 155 | if (!($experiment instanceOf Experiment)) { |
|
| 156 | throw new \Exception("Expected argument of type Experiment"); |
|
| 157 | } |
|
| 158 | ||
| 159 | $queryParams = array( |
|
| 160 | 'override_changes' => $overrideChanges, |
|
| 161 | 'publish' => $publish |
|
| 162 | ); |
|
| 163 | ||
| 164 | $postData = $experiment->toArray(); |
|
| 165 | ||
| 166 | $response = $this->client->sendApiRequest("/experiments/$experimentId", $queryParams, 'PATCH', |
|
| 167 | $postData, array(200)); |
|
| 168 | ||
| 169 | return new Experiment($response); |
|
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * Delete Experiment by ID |
|
| @@ 113-135 (lines=23) @@ | ||
| 110 | * @return Project Updated project. |
|
| 111 | * @throws \Exception |
|
| 112 | */ |
|
| 113 | public function update($projectId, $project) |
|
| 114 | { |
|
| 115 | if (!is_int($projectId)) { |
|
| 116 | throw new \Exception("Integer project ID expected, while got '$projectId'"); |
|
| 117 | } |
|
| 118 | ||
| 119 | if ($projectId<0) { |
|
| 120 | throw new \Exception("A positive project ID expected"); |
|
| 121 | } |
|
| 122 | ||
| 123 | if (!($project instanceOf Project)) { |
|
| 124 | throw new \Exception("Expected argument of type Project"); |
|
| 125 | } |
|
| 126 | ||
| 127 | $postData = $project->toArray(); |
|
| 128 | ||
| 129 | $response = $this->client->sendApiRequest("/projects/$projectId", array(), |
|
| 130 | 'PATCH', $postData, array(200)); |
|
| 131 | ||
| 132 | $project = new Project($response); |
|
| 133 | ||
| 134 | return $project; |
|
| 135 | } |
|
| 136 | } |
|
| 137 | ||
| 138 | ||