1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-18 21:20:09 -07:00

Update Rebrickable API getPart

This commit is contained in:
David Hübner 2017-03-16 02:48:08 +01:00
parent 77f0e169c1
commit 874d72c7bc
5 changed files with 102 additions and 104 deletions

View File

@ -5,8 +5,16 @@
{{ dump(part) }}
{{ dump(rbPart) }}
{{ dump(apiPart) }}
<div style="display: flex; flex-wrap: wrap">
{% if apiPart is not null %}
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
<img src="{{ apiPart.imgUrl }}" style="max-height: 90%; max-width: 100%">
</div>
{% endif %}
{% if part is not null %}
<div id="model" style="height: 300px; width: 300px; padding: 5px; display: inline-block"></div>
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">

View File

@ -14,7 +14,7 @@ class PropertyNameConverter implements NameConverterInterface
public function denormalize($propertyName)
{
switch ($propertyName) {
case 'part_num': return 'number';
case 'part_num': return 'id';
case 'part_cat_id': return 'categoryId';
case 'part_img_url': return 'imgUrl';
case 'part_url': return 'url';

View File

@ -2,27 +2,8 @@
namespace AppBundle\Api\Client\Rebrickable\Entity;
class Part
class Part extends \AppBundle\Entity\Rebrickable\Part
{
/**
* Part ID number.
*
* @var int
*/
private $number;
/**
* Part Name.
*
* @var string
*/
private $name;
/**
* Part category id.
*
* @var int
*/
private $categoryId;
/**
* Year the part first appeared in sets.
*
@ -41,6 +22,24 @@ class Part
* @var array
*/
private $externalIds;
/**
* Array of molds of part.
*
* @var array
*/
private $molds;
/**
* Array of prints the part appears in.
*
* @var array
*/
private $prints;
/**
* Array of alternative prts.
*
* @var array
*/
private $alternates;
/**
* Rebrickable URL to the Part Details page.
*
@ -54,70 +53,6 @@ class Part
*/
private $imgUrl;
/**
* @return int
*/
public function getNumber()
{
return $this->number;
}
/**
* @param int $number
*/
public function setNumber($number)
{
$this->number = $number;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return int
*/
public function getCategoryId()
{
return $this->categoryId;
}
/**
* @param int $categoryId
*/
public function setCategoryId($categoryId)
{
$this->categoryId = $categoryId;
}
/**
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* @param int $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return int
*/
@ -166,6 +101,54 @@ class Part
$this->externalIds = $externalIds;
}
/**
* @return array
*/
public function getAlternates()
{
return $this->alternates;
}
/**
* @param array $alternates
*/
public function setAlternates($alternates)
{
$this->alternates = $alternates;
}
/**
* @return array
*/
public function getMolds()
{
return $this->molds;
}
/**
* @param array $molds
*/
public function setMolds($molds)
{
$this->molds = $molds;
}
/**
* @return array
*/
public function getPrints()
{
return $this->prints;
}
/**
* @param array $prints
*/
public function setPrints($prints)
{
$this->prints = $prints;
}
/**
* @return string
*/

View File

@ -142,26 +142,25 @@ class RebrickableManager
return $this->serializer->denormalize($data, Set::class.'[]', self::FORMAT);
}
/**
* Get a list of all parts (normal + spare) used in a set.
*
* @param $setId
* @param $page
*
* @return
*/
public function getSetParts($setId, $page = null)
{
$options = [
'query' => [
'page' => $page,
],
];
//
// $response = $this->rebrickableClient->call('GET','lego/sets/'.$setId.'/parts', $options);
// /**
// * Get a list of all parts (normal + spare) used in a set.
// *
// * @param $setId
// * @param $page
// *
// * @return
// */
// public function getSetParts($setId, $page = null)
// {
// $options = [
// 'query' => [
// 'page' => $page,
// ],
// ];
//
// $response = $this->rebrickableClient->call('GET', 'lego/sets/'.$setId.'/parts', $options);
// $data = json_decode($response, true)['results'];
//
// return $this->serializer->denormalize($data, Part::class . '[]', self::FORMAT);
}
// return $this->serializer->denormalize($data, Part::class.'[]', self::FORMAT);
// }
}

View File

@ -26,6 +26,13 @@ class PartController extends Controller
$part = $em->getRepository(Part::class)->find($id);
$rbPart = $em->getRepository(\AppBundle\Entity\Rebrickable\Part::class)->find($id);
$apiPart = null;
try {
$apiPart = $this->get('manager.rebrickable')->getPart($id);
} catch (\Exception $e) {
dump($e);
}
$qb = $em->getRepository('AppBundle:Rebrickable\Inventory')->createQueryBuilder('i');
$qb->innerJoin(Inventory_Part::class, 'ip', Join::WITH, 'i.id = ip.inventory')
@ -37,6 +44,7 @@ class PartController extends Controller
return $this->render('part/detail.html.twig', [
'part' => $part,
'rbPart' => $rbPart,
'apiPart' => $apiPart,
'inventories' => $inventries,
]);
}