Skip to content

Commit

Permalink
Merge pull request #19 from discovery-tecnologia/develop
Browse files Browse the repository at this point in the history
Fix: Correcao da publicacao do Anuncio com Descricao
  • Loading branch information
dilowagner authored Nov 12, 2018
2 parents 1532030 + e3979a7 commit 84208a5
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function create(AnnouncementInterface $announcement)
* @return ItemResponse
* @link http://developers.mercadolibre.com/products-sync-listings/#Update-your-item
*/
public function update($code, $data)
public function update($code, array $data)
{
return $this->getResponse(
$this->put("/items/$code", $data),
Expand Down Expand Up @@ -79,7 +79,7 @@ public function changeStatus($code, $status)
*/
public function changeDescription($code, $description)
{
$data = ['text' => $description];
$data = ['plain_text' => $description];
return $this->getResponse(
$this->put("/items/$code/description", $data),
ItemResponse::class
Expand Down
12 changes: 9 additions & 3 deletions src/Announcement/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use JMS\Serializer\Annotation as JMS;
use Dsc\MercadoLivre\Requests\Product\Variation;
use Dsc\MercadoLivre\Requests\Category\Attribute;
use Dsc\MercadoLivre\Requests\Product\Description;

class Item implements Announcement
{
Expand Down Expand Up @@ -71,8 +72,8 @@ class Item implements Announcement
private $condition;

/**
* @var string
* @JMS\Type("string")
* @var Description
* @JMS\Type("Dsc\MercadoLivre\Requests\Product\Description")
*/
private $description;

Expand Down Expand Up @@ -291,6 +292,10 @@ public function setCondition($condition)
}

/**
* @deprecated
* Use o servico ProductService metodo findDescription
* para recuperar os dados da descricao dos Anuncios
*
* @return string
*/
public function getDescription()
Expand All @@ -304,7 +309,8 @@ public function getDescription()
*/
public function setDescription($description)
{
$this->description = $description;
$desc = new Description($description);
$this->description = $desc;
return $this;
}

Expand Down
80 changes: 80 additions & 0 deletions src/Requests/Product/Description.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@ class Description
*/
private $id;

/**
* @var string
* @JMS\Type("string")
*/
private $plainText;

/**
* @var \DateTime
* @JMS\Type("DateTime<'Y-m-d\TH:i:s.u\Z'>")
*/
private $dateCreated;

/**
* @var \DateTime
* @JMS\Type("DateTime<'Y-m-d\TH:i:s.u\Z'>")
*/
private $lastUpdated;

/**
* constructor
*/
public function __construct($text = null)
{
$this->plainText = $text;
}

/**
* @return string
*/
Expand All @@ -34,4 +60,58 @@ public function setId($id)
$this->id = $id;
return $this;
}

/**
* @return string
*/
public function getPlainText()
{
return $this->plainText;
}

/**
* @param string $text
* @return Description
*/
public function setPlainText($text)
{
$this->plainText = $text;
return $this;
}

/**
* @return \DateTime
*/
public function getDateCreated()
{
return $this->dateCreated;
}

/**
* @param \DateTime $dateCreated
* @return Description
*/
public function setDateCreated($dateCreated)
{
$this->dateCreated = $dateCreated;
return $this;
}

/**
* @return \DateTime
*/
public function getLastUpdated()
{
return $this->lastUpdated;
}

/**
* @param \DateTime $lastUpdated
* @return Description
*/
public function setLastUpdated($lastUpdated)
{
$this->lastUpdated = $lastUpdated;
return $this;
}
}
12 changes: 12 additions & 0 deletions src/Requests/Product/ProductService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public function findProduct($code)
);
}

/**
* @param $code
* @return Description
*/
public function findDescription($code)
{
return $this->getResponse(
$this->get("/items/$code/description"),
Description::class
);
}

/**
* @param string $code
* @return Collection
Expand Down
2 changes: 1 addition & 1 deletion tests/Publisher/announcement.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"title":"Item de test - no offer","category_id":"MLB46585","price":100,"currency_id":"BRL","available_quantity":10,"buying_mode":"buy_it_now","listing_type_id":"gold_special","condition":"new","description":"Test item - no offer","video_id":"YOUTUBE_ID_HERE","warranty":"12 months","pictures":[{"source":"http:\/\/example.com\/image.jpg"}],"attributes":[],"variations":[]}
{"title":"Item de test - no offer","category_id":"MLB46585","price":100,"currency_id":"BRL","available_quantity":10,"buying_mode":"buy_it_now","listing_type_id":"gold_special","condition":"new","description":{"plain_text":"Test item - no offer"},"video_id":"YOUTUBE_ID_HERE","warranty":"12 months","pictures":[{"source":"http:\/\/example.com\/image.jpg"}],"attributes":[],"variations":[]}

0 comments on commit 84208a5

Please sign in to comment.