Skip to content

Commit

Permalink
Merge pull request #6 from AlissonCorrea/master
Browse files Browse the repository at this point in the history
Criando os parâmetros genéricos para informar nos objetos dados de marketplace
  • Loading branch information
idealizetecnologia authored May 7, 2024
2 parents ab86b6d + 040a42e commit 9aa4fb9
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 9aa4fb9

Please sign in to comment.