diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 886c92b..609dda4 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -17,3 +17,6 @@ parameters: # A secret key that's used to generate certain security-related tokens secret: ThisTokenIsNotSoSecretChangeIt + + # Brickset API key obtainable at http://brickset.com/tools/webservices/requestkey + brickset_apikey: ~ \ No newline at end of file diff --git a/app/config/services.yml b/app/config/services.yml index 5c76fc5..0a3f1ab 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -1,9 +1,4 @@ -# Learn more about services, parameters and containers at -# http://symfony.com/doc/current/book/service_container.html -parameters: -# parameter_name: value - services: -# service_name: -# class: AppBundle\Directory\ClassName -# arguments: ["@another_service_name", "plain_value", "%parameter_name%"] + client.brickset: + class: AppBundle\Client\Brickset\Brickset + arguments: ['%brickset_apikey%'] \ No newline at end of file diff --git a/src/AppBundle/Client/Brickset/Brickset.php b/src/AppBundle/Client/Brickset/Brickset.php new file mode 100644 index 0000000..f731209 --- /dev/null +++ b/src/AppBundle/Client/Brickset/Brickset.php @@ -0,0 +1,242 @@ + Set::class, + 'additionalImages' => AdditionalImage::class, + 'instructions' => Instructions::class, + 'reviews' => Review::class, + ); + + /** + * @param string $apikey Brickset API key + * @param array $options A array of config values + * @param string $wsdl The wsdl file to use + */ + public function __construct($apikey, $wsdl = null, array $options = array()) + { + $this->apiKey = $apikey; + + foreach (self::$classmap as $key => $value) { + if (!isset($options['classmap'][$key])) { + $options['classmap'][$key] = $value; + } + } + if (!$wsdl) { + $wsdl = self::WSDL; + } + parent::__construct($wsdl, $options); + } + + /** + * @param mixed $apiKey + */ + public function setApiKey($apiKey) + { + $this->apiKey = $apiKey; + } + + /** + * @param $query + * @param $theme + * @param $subtheme + * @param $setNumber + * @param $year + * @param $owned + * @param $wanted + * @param $orderBy + * @param $pageSize + * @param $pageNumber + * @param $userName + * + * @return Set[] + */ + public function getSets($query, $theme, $subtheme, $setNumber, $year, $owned, $wanted, $orderBy, $pageSize, $pageNumber, $userName) + { + $parameters = [ + 'apiKey' => $this->apiKey, + 'userHash' => $this->userHash, + 'query' => $query, + 'theme' => $theme, + 'subtheme' => $subtheme, + 'setNumber' => $setNumber, + 'year' => $year, + 'owned' => $owned, + 'wanted' => $wanted, + 'orderBy' => $orderBy, + 'pageSize' => $pageSize, + 'pageNumber' => $pageNumber, + 'userName' => $userName, + ]; + + try { + return $this->__soapCall('getSets', [$parameters])->getSetsResult->sets; + } catch (ContextErrorException $e) { + return []; + } catch (\SoapFault $e) { + //TODO + throw new LogicException($e->getCode().' - '.$e->getMessage()); + } + } + + /** + * @param $SetID + * + * @return Set + */ + public function getSet($SetID) + { + $parameters = [ + 'apiKey' => $this->apiKey, + 'userHash' => $this->userHash, + 'SetID' => $SetID, + ]; + + try { + return $this->__soapCall('getSet', [$parameters])->getSetResult->sets[0]; + } catch (ContextErrorException $e) { + return null; + } catch (\SoapFault $e) { + //TODO + throw new LogicException($e->getCode().' - '.$e->getMessage()); + } + } + + /** + * @param int $minutesAgo + * + * @return Set[] + */ + public function getRecentlyUpdatedSets($minutesAgo) + { + $parameters = [ + 'apiKey' => $this->apiKey, + 'minutesAgo' => $minutesAgo, + ]; + + try { + return $this->__soapCall('getRecentlyUpdatedSets', [$parameters])->getRecentlyUpdatedSetsResult->sets; + } catch (ContextErrorException $e) { + return []; + } catch (\SoapFault $e) { + //TODO + throw new LogicException($e->getCode().' - '.$e->getMessage()); + } + } + + /** + * @param $setID + * + * @return AdditionalImage[] + */ + public function getAdditionalImages($setID) + { + $parameters = [ + 'apiKey' => $this->apiKey, + 'setID' => $setID, + ]; + + try { + return $this->__soapCall('getAdditionalImages', [$parameters])->getAdditionalImagesResult->additionalImages; + } catch (ContextErrorException $e) { + return []; + } catch (\SoapFault $e) { + //TODO + throw new LogicException($e->getCode().' - '.$e->getMessage()); + } + } + + public function getReviews($setID) + { + $parameters = [ + 'apiKey' => $this->apiKey, + 'setID' => $setID, + ]; + + try { + return $this->__soapCall('getReviews', [$parameters])->getReviewsResult->reviews; + } catch (ContextErrorException $e) { + return []; + } catch (\SoapFault $e) { + //TODO + throw new LogicException($e->getCode().' - '.$e->getMessage()); + } + } + + public function getInstructions($setID) + { + $parameters = [ + 'apiKey' => $this->apiKey, + 'setID' => $setID, + ]; + + try { + return $this->__soapCall('getInstructions', [$parameters])->getInstructionsResult->instructions; + } catch (ContextErrorException $e) { + return []; + } catch (\SoapFault $e) { + //TODO + throw new LogicException($e->getCode().' - '.$e->getMessage()); + } + } + + public function login($username, $password) + { + $parameters = [ + 'apiKey' => $this->apiKey, + 'username' => $username, + 'password' => $password, + ]; + + try { + $response = $this->__soapCall('login', [$parameters])->loginResult; + if ($response == 'INVALIDKEY') { + return false; + } elseif (strpos($response, 'ERROR:') === 0) { + return false; + } else { + $this->userHash = $response; + + return true; + } + } catch (\SoapFault $e) { + //TODO + throw new LogicException($e->getCode().' - '.$e->getMessage()); + } + } + + /** + * @return mixed + */ + public function checkKey() + { + $parameters = [ + 'apiKey' => $this->apiKey, + ]; + + try { + return ($this->__soapCall('checkKey', [$parameters])->checkKeyResult) == 'OK' ? true : false; + } catch (\SoapFault $e) { + //TODO + throw new LogicException($e->getCode().' - '.$e->getMessage()); + } + } +} diff --git a/src/AppBundle/Client/Brickset/Entity/AdditionalImage.php b/src/AppBundle/Client/Brickset/Entity/AdditionalImage.php new file mode 100644 index 0000000..7b8ba1e --- /dev/null +++ b/src/AppBundle/Client/Brickset/Entity/AdditionalImage.php @@ -0,0 +1,83 @@ +thumbnailURL; + } + + /** + * @param string $thumbnailURL + * @return AdditionalImage + */ + public function setThumbnailURL($thumbnailURL) + { + $this->thumbnailURL = $thumbnailURL; + return $this; + } + + /** + * @return string + */ + public function getLargeThumbnailURL() + { + return $this->largeThumbnailURL; + } + + /** + * @param string $largeThumbnailURL + * @return AdditionalImage + */ + public function setLargeThumbnailURL($largeThumbnailURL) + { + $this->largeThumbnailURL = $largeThumbnailURL; + return $this; + } + + /** + * @return string + */ + public function getImageURL() + { + return $this->imageURL; + } + + /** + * @param string $imageURL + * @return AdditionalImage + */ + public function setImageURL($imageURL) + { + $this->imageURL = $imageURL; + return $this; + } + +} diff --git a/src/AppBundle/Client/Brickset/Entity/Instructions.php b/src/AppBundle/Client/Brickset/Entity/Instructions.php new file mode 100644 index 0000000..61c3ca3 --- /dev/null +++ b/src/AppBundle/Client/Brickset/Entity/Instructions.php @@ -0,0 +1,59 @@ +URL; + } + + /** + * @param string $URL + * @return Instructions + */ + public function setURL($URL) + { + $this->URL = $URL; + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + * @return Instructions + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + +} diff --git a/src/AppBundle/Client/Brickset/Entity/Review.php b/src/AppBundle/Client/Brickset/Entity/Review.php new file mode 100644 index 0000000..2daae88 --- /dev/null +++ b/src/AppBundle/Client/Brickset/Entity/Review.php @@ -0,0 +1,266 @@ +datePosted = $datePosted->format(\DateTime::ATOM); + $this->overallRating = $overallRating; + $this->parts = $parts; + $this->buildingExperience = $buildingExperience; + $this->playability = $playability; + $this->valueForMoney = $valueForMoney; + $this->HTML = $HTML; + } + + /** + * @return string + */ + public function getAuthor() + { + return $this->author; + } + + /** + * @param string $author + * @return Review + */ + public function setAuthor($author) + { + $this->author = $author; + return $this; + } + + /** + * @return \DateTime + */ + public function getDatePosted() + { + if ($this->datePosted == null) { + return null; + } else { + try { + return new \DateTime($this->datePosted); + } catch (\Exception $e) { + return null; + } + } + } + + /** + * @param \DateTime $datePosted + * @return Review + */ + public function setDatePosted(\DateTime $datePosted) + { + $this->datePosted = $datePosted->format(\DateTime::ATOM); + return $this; + } + + /** + * @return int + */ + public function getOverallRating() + { + return $this->overallRating; + } + + /** + * @param int $overallRating + * @return Review + */ + public function setOverallRating($overallRating) + { + $this->overallRating = $overallRating; + return $this; + } + + /** + * @return int + */ + public function getParts() + { + return $this->parts; + } + + /** + * @param int $parts + * @return Review + */ + public function setParts($parts) + { + $this->parts = $parts; + return $this; + } + + /** + * @return int + */ + public function getBuildingExperience() + { + return $this->buildingExperience; + } + + /** + * @param int $buildingExperience + * @return Review + */ + public function setBuildingExperience($buildingExperience) + { + $this->buildingExperience = $buildingExperience; + return $this; + } + + /** + * @return int + */ + public function getPlayability() + { + return $this->playability; + } + + /** + * @param int $playability + * @return Review + */ + public function setPlayability($playability) + { + $this->playability = $playability; + return $this; + } + + /** + * @return int + */ + public function getValueForMoney() + { + return $this->valueForMoney; + } + + /** + * @param int $valueForMoney + * @return Review + */ + public function setValueForMoney($valueForMoney) + { + $this->valueForMoney = $valueForMoney; + return $this; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $title + * @return Review + */ + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + /** + * @return string + */ + public function getReview() + { + return $this->review; + } + + /** + * @param string $review + * @return Review + */ + public function setReview($review) + { + $this->review = $review; + return $this; + } + + /** + * @return boolean + */ + public function getHTML() + { + return $this->HTML; + } + + /** + * @param boolean $HTML + * @return Review + */ + public function setHTML($HTML) + { + $this->HTML = $HTML; + return $this; + } + +} diff --git a/src/AppBundle/Client/Brickset/Entity/Set.php b/src/AppBundle/Client/Brickset/Entity/Set.php new file mode 100644 index 0000000..8e37519 --- /dev/null +++ b/src/AppBundle/Client/Brickset/Entity/Set.php @@ -0,0 +1,971 @@ +setID = $setID; + $this->numberVariant = $numberVariant; + $this->image = $image; + $this->released = $released; + $this->owned = $owned; + $this->wanted = $wanted; + $this->qtyOwned = $qtyOwned; + $this->ACMDataCount = $ACMDataCount; + $this->ownedByTotal = $ownedByTotal; + $this->wantedByTotal = $wantedByTotal; + $this->rating = $rating; + $this->reviewCount = $reviewCount; + $this->instructionsCount = $instructionsCount; + $this->additionalImageCount = $additionalImageCount; + $this->lastUpdated = $lastUpdated->format(\DateTime::ATOM); + } + + /** + * @return int + */ + public function getSetID() + { + return $this->setID; + } + + /** + * @param int $setID + * @return Set + */ + public function setSetID($setID) + { + $this->setID = $setID; + return $this; + } + + /** + * @return string + */ + public function getNumber() + { + return $this->number; + } + + /** + * @param string $number + * @return Set + */ + public function setNumber($number) + { + $this->number = $number; + return $this; + } + + /** + * @return int + */ + public function getNumberVariant() + { + return $this->numberVariant; + } + + /** + * @param int $numberVariant + * @return Set + */ + public function setNumberVariant($numberVariant) + { + $this->numberVariant = $numberVariant; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * @return Set + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getYear() + { + return $this->year; + } + + /** + * @param string $year + * @return Set + */ + public function setYear($year) + { + $this->year = $year; + return $this; + } + + /** + * @return string + */ + public function getTheme() + { + return $this->theme; + } + + /** + * @param string $theme + * @return Set + */ + public function setTheme($theme) + { + $this->theme = $theme; + return $this; + } + + /** + * @return string + */ + public function getThemeGroup() + { + return $this->themeGroup; + } + + /** + * @param string $themeGroup + * @return Set + */ + public function setThemeGroup($themeGroup) + { + $this->themeGroup = $themeGroup; + return $this; + } + + /** + * @return string + */ + public function getSubtheme() + { + return $this->subtheme; + } + + /** + * @param string $subtheme + * @return Set + */ + public function setSubtheme($subtheme) + { + $this->subtheme = $subtheme; + return $this; + } + + /** + * @return string + */ + public function getPieces() + { + return $this->pieces; + } + + /** + * @param string $pieces + * @return Set + */ + public function setPieces($pieces) + { + $this->pieces = $pieces; + return $this; + } + + /** + * @return string + */ + public function getMinifigs() + { + return $this->minifigs; + } + + /** + * @param string $minifigs + * @return Set + */ + public function setMinifigs($minifigs) + { + $this->minifigs = $minifigs; + return $this; + } + + /** + * @return boolean + */ + public function getImage() + { + return $this->image; + } + + /** + * @param boolean $image + * @return Set + */ + public function setImage($image) + { + $this->image = $image; + return $this; + } + + /** + * @return string + */ + public function getImageFilename() + { + return $this->imageFilename; + } + + /** + * @param string $imageFilename + * @return Set + */ + public function setImageFilename($imageFilename) + { + $this->imageFilename = $imageFilename; + return $this; + } + + /** + * @return string + */ + public function getThumbnailURL() + { + return $this->thumbnailURL; + } + + /** + * @param string $thumbnailURL + * @return Set + */ + public function setThumbnailURL($thumbnailURL) + { + $this->thumbnailURL = $thumbnailURL; + return $this; + } + + /** + * @return string + */ + public function getLargeThumbnailURL() + { + return $this->largeThumbnailURL; + } + + /** + * @param string $largeThumbnailURL + * @return Set + */ + public function setLargeThumbnailURL($largeThumbnailURL) + { + $this->largeThumbnailURL = $largeThumbnailURL; + return $this; + } + + /** + * @return string + */ + public function getImageURL() + { + return $this->imageURL; + } + + /** + * @param string $imageURL + * @return Set + */ + public function setImageURL($imageURL) + { + $this->imageURL = $imageURL; + return $this; + } + + /** + * @return string + */ + public function getBricksetURL() + { + return $this->bricksetURL; + } + + /** + * @param string $bricksetURL + * @return Set + */ + public function setBricksetURL($bricksetURL) + { + $this->bricksetURL = $bricksetURL; + return $this; + } + + /** + * @return boolean + */ + public function getReleased() + { + return $this->released; + } + + /** + * @param boolean $released + * @return Set + */ + public function setReleased($released) + { + $this->released = $released; + return $this; + } + + /** + * @return boolean + */ + public function getOwned() + { + return $this->owned; + } + + /** + * @param boolean $owned + * @return Set + */ + public function setOwned($owned) + { + $this->owned = $owned; + return $this; + } + + /** + * @return boolean + */ + public function getWanted() + { + return $this->wanted; + } + + /** + * @param boolean $wanted + * @return Set + */ + public function setWanted($wanted) + { + $this->wanted = $wanted; + return $this; + } + + /** + * @return int + */ + public function getQtyOwned() + { + return $this->qtyOwned; + } + + /** + * @param int $qtyOwned + * @return Set + */ + public function setQtyOwned($qtyOwned) + { + $this->qtyOwned = $qtyOwned; + return $this; + } + + /** + * @return string + */ + public function getUserNotes() + { + return $this->userNotes; + } + + /** + * @param string $userNotes + * @return Set + */ + public function setUserNotes($userNotes) + { + $this->userNotes = $userNotes; + return $this; + } + + /** + * @return int + */ + public function getACMDataCount() + { + return $this->ACMDataCount; + } + + /** + * @param int $ACMDataCount + * @return Set + */ + public function setACMDataCount($ACMDataCount) + { + $this->ACMDataCount = $ACMDataCount; + return $this; + } + + /** + * @return int + */ + public function getOwnedByTotal() + { + return $this->ownedByTotal; + } + + /** + * @param int $ownedByTotal + * @return Set + */ + public function setOwnedByTotal($ownedByTotal) + { + $this->ownedByTotal = $ownedByTotal; + return $this; + } + + /** + * @return int + */ + public function getWantedByTotal() + { + return $this->wantedByTotal; + } + + /** + * @param int $wantedByTotal + * @return Set + */ + public function setWantedByTotal($wantedByTotal) + { + $this->wantedByTotal = $wantedByTotal; + return $this; + } + + /** + * @return string + */ + public function getUKRetailPrice() + { + return $this->UKRetailPrice; + } + + /** + * @param string $UKRetailPrice + * @return Set + */ + public function setUKRetailPrice($UKRetailPrice) + { + $this->UKRetailPrice = $UKRetailPrice; + return $this; + } + + /** + * @return string + */ + public function getUSRetailPrice() + { + return $this->USRetailPrice; + } + + /** + * @param string $USRetailPrice + * @return Set + */ + public function setUSRetailPrice($USRetailPrice) + { + $this->USRetailPrice = $USRetailPrice; + return $this; + } + + /** + * @return string + */ + public function getCARetailPrice() + { + return $this->CARetailPrice; + } + + /** + * @param string $CARetailPrice + * @return Set + */ + public function setCARetailPrice($CARetailPrice) + { + $this->CARetailPrice = $CARetailPrice; + return $this; + } + + /** + * @return string + */ + public function getEURetailPrice() + { + return $this->EURetailPrice; + } + + /** + * @param string $EURetailPrice + * @return Set + */ + public function setEURetailPrice($EURetailPrice) + { + $this->EURetailPrice = $EURetailPrice; + return $this; + } + + /** + * @return string + */ + public function getUSDateAddedToSAH() + { + return $this->USDateAddedToSAH; + } + + /** + * @param string $USDateAddedToSAH + * @return Set + */ + public function setUSDateAddedToSAH($USDateAddedToSAH) + { + $this->USDateAddedToSAH = $USDateAddedToSAH; + return $this; + } + + /** + * @return string + */ + public function getUSDateRemovedFromSAH() + { + return $this->USDateRemovedFromSAH; + } + + /** + * @param string $USDateRemovedFromSAH + * @return Set + */ + public function setUSDateRemovedFromSAH($USDateRemovedFromSAH) + { + $this->USDateRemovedFromSAH = $USDateRemovedFromSAH; + return $this; + } + + /** + * @return float + */ + public function getRating() + { + return $this->rating; + } + + /** + * @param float $rating + * @return Set + */ + public function setRating($rating) + { + $this->rating = $rating; + return $this; + } + + /** + * @return int + */ + public function getReviewCount() + { + return $this->reviewCount; + } + + /** + * @param int $reviewCount + * @return Set + */ + public function setReviewCount($reviewCount) + { + $this->reviewCount = $reviewCount; + return $this; + } + + /** + * @return string + */ + public function getPackagingType() + { + return $this->packagingType; + } + + /** + * @param string $packagingType + * @return Set + */ + public function setPackagingType($packagingType) + { + $this->packagingType = $packagingType; + return $this; + } + + /** + * @return string + */ + public function getAvailability() + { + return $this->availability; + } + + /** + * @param string $availability + * @return Set + */ + public function setAvailability($availability) + { + $this->availability = $availability; + return $this; + } + + /** + * @return int + */ + public function getInstructionsCount() + { + return $this->instructionsCount; + } + + /** + * @param int $instructionsCount + * @return Set + */ + public function setInstructionsCount($instructionsCount) + { + $this->instructionsCount = $instructionsCount; + return $this; + } + + /** + * @return int + */ + public function getAdditionalImageCount() + { + return $this->additionalImageCount; + } + + /** + * @param int $additionalImageCount + * @return Set + */ + public function setAdditionalImageCount($additionalImageCount) + { + $this->additionalImageCount = $additionalImageCount; + return $this; + } + + /** + * @return string + */ + public function getEAN() + { + return $this->EAN; + } + + /** + * @param string $EAN + * @return Set + */ + public function setEAN($EAN) + { + $this->EAN = $EAN; + return $this; + } + + /** + * @return string + */ + public function getUPC() + { + return $this->UPC; + } + + /** + * @param string $UPC + * @return Set + */ + public function setUPC($UPC) + { + $this->UPC = $UPC; + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + * @return Set + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * @return \DateTime + */ + public function getLastUpdated() + { + if ($this->lastUpdated == null) { + return null; + } else { + try { + return new \DateTime($this->lastUpdated); + } catch (\Exception $e) { + return null; + } + } + } + + /** + * @param \DateTime $lastUpdated + * @return Set + */ + public function setLastUpdated(\DateTime $lastUpdated) + { + $this->lastUpdated = $lastUpdated->format(\DateTime::ATOM); + return $this; + } + +}