From a81558308516115ad81d66e0cbeb5d05e15fe279 Mon Sep 17 00:00:00 2001 From: peterjake Date: Tue, 21 Sep 2021 16:10:49 +0800 Subject: [PATCH 1/7] IQ-3051 fix: skip clever sections with empty grade --- lib/Api/DataApi.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Api/DataApi.php b/lib/Api/DataApi.php index 3fec10e..91a2284 100644 --- a/lib/Api/DataApi.php +++ b/lib/Api/DataApi.php @@ -8181,6 +8181,15 @@ public function getSectionsWithHttpInfo($limit = null, $starting_after = null, $ } } + if ($response->getStatusCode() === 200) { + $content->data = array_filter($content->data, function ($item) { + if (!$item->data->grade && $item->data->id) { + echo "Skipping section {$item->data->id}, has empty grade.\n"; + } + return $item->data && $item->data->id && $item->data->grade; + }); + } + return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), From ddea731bc5ac088c9589db7189cf25ed6af13480 Mon Sep 17 00:00:00 2001 From: peterjake Date: Tue, 21 Sep 2021 16:14:09 +0800 Subject: [PATCH 2/7] IQ-3044 feat: log skipped classes --- lib/Api/DataApi.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/Api/DataApi.php b/lib/Api/DataApi.php index 91a2284..0a317c8 100644 --- a/lib/Api/DataApi.php +++ b/lib/Api/DataApi.php @@ -8120,11 +8120,16 @@ protected function getSectionRequest($id) * * @throws \Clever\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \Clever\Model\SectionsResponse + * @return \Clever\Model\SectionsResponse|array */ - public function getSections($limit = null, $starting_after = null, $ending_before = null) + public function getSections($limit = null, $starting_after = null, $ending_before = null, $returnSkipped = false) { - list($response) = $this->getSectionsWithHttpInfo($limit, $starting_after, $ending_before); + list($response, $statusCode, $headers, $skippedItems) = $this->getSectionsWithHttpInfo($limit, $starting_after, $ending_before); + + if ($returnSkipped) { + return [$response, $skippedItems]; + } + return $response; } @@ -8181,19 +8186,23 @@ public function getSectionsWithHttpInfo($limit = null, $starting_after = null, $ } } + $skippedItems = []; if ($response->getStatusCode() === 200) { - $content->data = array_filter($content->data, function ($item) { - if (!$item->data->grade && $item->data->id) { - echo "Skipping section {$item->data->id}, has empty grade.\n"; + $content->data = array_filter($content->data, function ($item) use (&$skippedItems) { + if (!$item->data || !$item->data->id || !$item->data->grade) { + $skippedItems[] = $item; + return false; } - return $item->data && $item->data->id && $item->data->grade; + + return true; }); } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), - $response->getHeaders() + $response->getHeaders(), + $skippedItems, ]; } catch (ApiException $e) { From a333776d9a14b29ae23354a578f3f67b8e8c4f48 Mon Sep 17 00:00:00 2001 From: peterjake Date: Tue, 21 Sep 2021 16:16:52 +0800 Subject: [PATCH 3/7] IQ-3065 fix: error event syncing classes with no grade --- lib/Api/EventsApi.php | 47 +++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/lib/Api/EventsApi.php b/lib/Api/EventsApi.php index 4fd87e3..01621bf 100644 --- a/lib/Api/EventsApi.php +++ b/lib/Api/EventsApi.php @@ -15,7 +15,7 @@ * The Clever API * * OpenAPI spec version: 2.0.0 - * + * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ @@ -110,7 +110,6 @@ public function getEventWithHttpInfo($id) $request = $this->getEventRequest($id); try { - try { $response = $this->client->send($request); } catch (RequestException $e) { @@ -151,7 +150,6 @@ public function getEventWithHttpInfo($id) $response->getStatusCode(), $response->getHeaders() ]; - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -178,7 +176,7 @@ public function getEventWithHttpInfo($id) /** * Operation getEventAsync * - * + * * * @param string $id (required) * @@ -198,7 +196,7 @@ function ($response) { /** * Operation getEventAsyncWithHttpInfo * - * + * * * @param string $id (required) * @@ -298,7 +296,6 @@ protected function getEventRequest($id) // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; @@ -310,10 +307,8 @@ protected function getEventRequest($id) } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); @@ -353,14 +348,20 @@ protected function getEventRequest($id) * @param string $ending_before ending_before (optional) * @param string $school school (optional) * @param string[] $record_type record_type (optional) + * @param bool $returnSkipped * * @throws \Clever\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Clever\Model\EventsResponse */ - public function getEvents($limit = null, $starting_after = null, $ending_before = null, $school = null, $record_type = null) + public function getEvents($limit = null, $starting_after = null, $ending_before = null, $school = null, $record_type = null, $returnSkipped = false) { - list($response) = $this->getEventsWithHttpInfo($limit, $starting_after, $ending_before, $school, $record_type); + list($response, $statusCode, $headers, $skippedItems) = $this->getEventsWithHttpInfo($limit, $starting_after, $ending_before, $school, $record_type); + + if ($returnSkipped) { + return [$response, $skippedItems]; + } + return $response; } @@ -383,7 +384,6 @@ public function getEventsWithHttpInfo($limit = null, $starting_after = null, $en $request = $this->getEventsRequest($limit, $starting_after, $ending_before, $school, $record_type); try { - try { $response = $this->client->send($request); } catch (RequestException $e) { @@ -419,12 +419,24 @@ public function getEventsWithHttpInfo($limit = null, $starting_after = null, $en } } + $skippedItems = []; + if ($response->getStatusCode() === 200) { + $content->data = array_filter($content->data, function ($item) use (&$skippedItems) { + if (substr($item->data->type, 0, 9) === 'sections.' && (!$item->data->data->object->id || !$item->data->data->object->grade)) { + $skippedItems[] = $item; + return false; + } + + return true; + }); + } + return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), - $response->getHeaders() + $response->getHeaders(), + $skippedItems, ]; - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -451,7 +463,7 @@ public function getEventsWithHttpInfo($limit = null, $starting_after = null, $en /** * Operation getEventsAsync * - * + * * * @param int $limit (optional) * @param string $starting_after (optional) @@ -475,7 +487,7 @@ function ($response) { /** * Operation getEventsAsyncWithHttpInfo * - * + * * * @param int $limit (optional) * @param string $starting_after (optional) @@ -542,7 +554,6 @@ function ($exception) { */ protected function getEventsRequest($limit = null, $starting_after = null, $ending_before = null, $school = null, $record_type = null) { - $resourcePath = '/events'; $formParams = []; $queryParams = []; @@ -592,7 +603,6 @@ protected function getEventsRequest($limit = null, $starting_after = null, $endi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; @@ -604,10 +614,8 @@ protected function getEventsRequest($limit = null, $starting_after = null, $endi } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); @@ -638,5 +646,4 @@ protected function getEventsRequest($limit = null, $starting_after = null, $endi $httpBody ); } - } From 9900e2a5d4121358c401418867f61a2000015117 Mon Sep 17 00:00:00 2001 From: peterjake Date: Tue, 21 Sep 2021 17:19:21 +0800 Subject: [PATCH 4/7] IQ-3312 - feat: update api version from v2.0 to v2.1 --- lib/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index add2878..ef50d92 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -80,7 +80,7 @@ class Configuration * * @var string */ - protected $host = 'https://api.clever.com/v2.0'; + protected $host = 'https://api.clever.com/v2.1'; /** * User agent of the HTTP request, set to "PHP-Swagger" by default From ffc51ca58e38b52f8ce000f483fe68ffd849e635 Mon Sep 17 00:00:00 2001 From: peterjake Date: Tue, 21 Sep 2021 17:19:46 +0800 Subject: [PATCH 5/7] IQ-3312 - feat: add support for extension field on sections model --- lib/Model/Section.php | 47 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/lib/Model/Section.php b/lib/Model/Section.php index 084b613..6a94090 100644 --- a/lib/Model/Section.php +++ b/lib/Model/Section.php @@ -16,7 +16,7 @@ * The Clever API * * OpenAPI spec version: 2.0.0 - * + * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ @@ -71,7 +71,8 @@ class Section implements ModelInterface, ArrayAccess 'subject' => 'string', 'teacher' => 'string', 'teachers' => 'string[]', - 'term_id' => 'string' + 'term_id' => 'string', + 'ext' => 'object', ]; /** @@ -95,7 +96,8 @@ class Section implements ModelInterface, ArrayAccess 'subject' => null, 'teacher' => null, 'teachers' => null, - 'term_id' => null + 'term_id' => null, + 'ext' => null, ]; /** @@ -140,7 +142,8 @@ public static function swaggerFormats() 'subject' => 'subject', 'teacher' => 'teacher', 'teachers' => 'teachers', - 'term_id' => 'term_id' + 'term_id' => 'term_id', + 'ext' => 'ext', ]; /** @@ -164,7 +167,8 @@ public static function swaggerFormats() 'subject' => 'setSubject', 'teacher' => 'setTeacher', 'teachers' => 'setTeachers', - 'term_id' => 'setTermId' + 'term_id' => 'setTermId', + 'ext' => 'setExt', ]; /** @@ -188,7 +192,8 @@ public static function swaggerFormats() 'subject' => 'getSubject', 'teacher' => 'getTeacher', 'teachers' => 'getTeachers', - 'term_id' => 'getTermId' + 'term_id' => 'getTermId', + 'ext' => 'getExt', ]; /** @@ -343,6 +348,7 @@ public function __construct(array $data = null) $this->container['teacher'] = isset($data['teacher']) ? $data['teacher'] : null; $this->container['teachers'] = isset($data['teachers']) ? $data['teachers'] : null; $this->container['term_id'] = isset($data['term_id']) ? $data['term_id'] : null; + $this->container['ext'] = isset($data['ext']) ? $data['ext'] : null; } /** @@ -381,7 +387,6 @@ public function listInvalidProperties() */ public function valid() { - $allowedValues = $this->getGradeAllowableValues(); if (!in_array($this->container['grade'], $allowedValues)) { return false; @@ -795,6 +800,32 @@ public function setTermId($term_id) return $this; } + + + /** + * Gets ext. + * + * @return string + */ + public function getExt() + { + return $this->container['ext']; + } + + /** + * Sets ext. + * + * @param string $ext ext + * + * @return $this + */ + public function setExt($ext) + { + $this->container['ext'] = $ext; + + return $this; + } + /** * Returns true if offset exists. False otherwise. * @@ -865,5 +896,3 @@ public function __toString() return json_encode(ObjectSerializer::sanitizeForSerialization($this)); } } - - From ab3e17a87d4203e5ed07a884aec1f8e58cc3312c Mon Sep 17 00:00:00 2001 From: peterjake Date: Thu, 23 Sep 2021 18:16:39 +0800 Subject: [PATCH 6/7] Update clever package name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2ca7947..43e47e8 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "GIT_USER_ID/GIT_REPO_ID", + "name": "clever/clever", "description": "", "keywords": [ "swagger", From 373a9952b59ce065da33a79f162c454c6c5ef9b9 Mon Sep 17 00:00:00 2001 From: peterjake Date: Thu, 23 Sep 2021 18:19:25 +0800 Subject: [PATCH 7/7] Update composer package name to sourcetoad/clever-php --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 43e47e8..c6cf524 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "clever/clever", + "name": "sourcetoad/clever-php", "description": "", "keywords": [ "swagger",