Skip to content

Commit

Permalink
Criando os parametros genericos para informar no objeto item
Browse files Browse the repository at this point in the history
Criando os parametros genericos para informar no objeto item os dados para informar se o item é de marketplace
  • Loading branch information
alisson committed May 6, 2024
1 parent ab86b6d commit 040a42e
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/ClearSale/XmlEntity/SendOrder/GenericParameter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace ClearSale\XmlEntity\SendOrder;

use ClearSale\XmlEntity\XmlEntityInterface;
use XMLWriter;

class GenericParameter implements XmlEntityInterface
{
private $name;
private $value;

public function __construct($name, $value)
{
$this->name = $name;
$this->value = $value;
}

public function getName()
{
return $this->name;
}

public function getValue()
{
return $this->value;
}

public function toXML(XMLWriter $xml)
{
$xml->startElement("Generic");

$xml->writeElement("Name", $this->getName());

$xml->writeElement("Value", $this->getValue());

$xml->endElement();
}
}
27 changes: 27 additions & 0 deletions src/ClearSale/XmlEntity/SendOrder/GenericParameters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace ClearSale\XmlEntity\SendOrder;

use ClearSale\XmlEntity\XmlEntityInterface;
use XMLWriter;

class GenericParameters implements XmlEntityInterface
{
private $genericParameters = array();

public function addParamGeneric(GenericParameter $genericParameter)
{
$this->genericParameters[] = $genericParameter;
}

public function toXML(XMLWriter $xml)
{
$xml->startElement("Generics");

foreach ($this->genericParameters as $genericParameter) {
$genericParameter->toXML($xml);
}

$xml->endElement();
}
}
17 changes: 17 additions & 0 deletions src/ClearSale/XmlEntity/SendOrder/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Item implements XmlEntityInterface
private $isGift;
private $categoryId;
private $categoryName;
private $genericParameters;

/**
* Criar Item com campos obrigatórios preenchidos
Expand Down Expand Up @@ -151,6 +152,18 @@ public function setCategoryName($categoryName)
return $this;
}

public function getGenericParameters(): GenericParameters
{
return $this->genericParameters;
}

public function setGenericParameters(GenericParameters $genericParameters)
{
$this->genericParameters = $genericParameters;

return $this;
}

public function toXML(XMLWriter $xml)
{
$xml->startElement("Item");
Expand Down Expand Up @@ -191,6 +204,10 @@ public function toXML(XMLWriter $xml)
$xml->writeElement("CategoryName", $this->categoryName);
}

if ($this->genericParameters){
$this->getGenericParameters()->toXML($xml);
}

$xml->endElement();
}
}

0 comments on commit 040a42e

Please sign in to comment.