diff --git a/assets/img/mastercard.png b/assets/img/mastercard.png new file mode 100644 index 0000000..7868543 Binary files /dev/null and b/assets/img/mastercard.png differ diff --git a/src/TestController.php b/src/TestController.php index 8c2d7c1..5b71275 100755 --- a/src/TestController.php +++ b/src/TestController.php @@ -7,6 +7,119 @@ /** * Class for the exercise. */ -class TestController extends EUFFetcher { + +class TestController extends EUFFetcher +{ + +public function RetrieveCountries() +{ + $json = $this->api->apiGetRequest("getCountries", null); + + $array = json_decode($json, true); + + return $array['CountryName']; +} + +public function RetrieveCountryRecords() +{ + $json = $this->api->apiGetRequest("getCountries", null); + + $array = json_decode($json, true); + + return $array; +} + +public function RetrieveUniversities($countryID) +{ + $params['CountryID'] = $countryID; + + $json = $this->api->apiGetRequest("getInstitutions", $params); + + $array = json_decode($json, true); + + return array_column($array, 'NameInLatinCharacterSet'); +} + +private function NationalFlag($cid) +{ + $flagmap['2'] = "aw"; + $flagmap['1'] = "at"; + $flagmap['3'] = "be"; + $flagmap['4'] = "bg"; + $flagmap['18'] = "hr"; + $flagmap['6'] = "cy"; + $flagmap['39'] = "cw"; + $flagmap['7'] = "cz"; + $flagmap['9'] = "dk"; + $flagmap['10'] = "ee"; + $flagmap['12'] = "fi"; + $flagmap['27'] = "mk"; + $flagmap['13'] = "fr"; + $flagmap['15'] = "gi"; + $flagmap['17'] = "gr"; + $flagmap['16'] = "gl"; + $flagmap['19'] = "hu"; + $flagmap['21'] = "is"; + $flagmap['20'] = "ir"; + $flagmap['22'] = "it"; + $flagmap['26'] = "lv"; + $flagmap['23'] = "li"; + $flagmap['24'] = "lt"; + $flagmap['25'] = "lu"; + $flagmap['28'] = "mt"; + $flagmap['30'] = "nl"; + $flagmap['29'] = "nc"; + $flagmap['31'] = "no"; + $flagmap['32'] = "pl"; + $flagmap['33'] = "pt"; + $flagmap['34'] = "ro"; + $flagmap['40'] = "sb"; + $flagmap['37'] = "sk"; + $flagmap['36'] = "si"; + $flagmap['11'] = "es"; + $flagmap['35'] = "se"; + $flagmap['5'] = "ch"; + $flagmap['38'] = "tr"; + $flagmap['14'] = "gb"; + $flagmap['8'] = "de"; + + return $flagmap[$cid] ?? 'xx'; +} + +public function render() +{ + $html = '
'; + + $crecords = $this->RetrieveCountryRecords(); + + foreach($crecords as $record) + { + $country = $record['CountryName']; + $cid = $record['ID']; + $universities = $this->RetrieveUniversities($cid); + $flag = $this->NationalFlag($cid); + + $html .= '
'; + $html .= ''; + + foreach($universities as $univ) + { + $html .= '
'; + $html .= '
'; + $html .= $univ; + $html .='
'; + } + } + + $html .= '
'; + + return $html; +} } diff --git a/templates/card.twig b/templates/card.twig index 3351171..babd388 100644 --- a/templates/card.twig +++ b/templates/card.twig @@ -1,5 +1,21 @@ -
- - I want to be a card... - +
+ Revolut MasterCard + Revolut +
+ Sample footer +
+ + \ No newline at end of file