first commit
This commit is contained in:
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
class AllegroApiShippingRate extends BaseObject implements Persistent
|
||||
{
|
||||
/**
|
||||
* GUID cennika dostaw
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* Nazwa cennika dostaw
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Data ostatniej modyfikacji cennika dostaw
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
protected $lastModified;
|
||||
|
||||
/**
|
||||
* Lista stawek cennika dostaw
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
protected $rates;
|
||||
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(constant($this->getPeer().'::ID'), $this->getId());
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function getPeer()
|
||||
{
|
||||
return get_class($this).'Peer';
|
||||
}
|
||||
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
$fields = call_user_func(array($this->getPeer(), 'translateFieldName'), 'id', BasePeer::TYPE_FIELDNAME, $keyType);
|
||||
return array($fields);
|
||||
}
|
||||
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setPrimaryKey($primaryKey)
|
||||
{
|
||||
$this->id = $primaryKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca GUID cennika dostaw
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia GUID cennika dostaw
|
||||
*
|
||||
* @param string $id GUID cennika dostaw
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setId(string $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca nazwę cennika dostaw
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia nazwę cennika dostaw
|
||||
*
|
||||
* @param string $name Nazwa cennika dostaw
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca datę ostatniej modyfikacji cennika dostaw
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getLastModified()
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia datę ostatniej modyfikacji cennika dostaw
|
||||
*
|
||||
* @param int $lastModified Data ostatniej modyfikacji cennika dostaw
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setLastModified(int $lastModified)
|
||||
{
|
||||
$this->lastModified = $lastModified;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca listę stawek cennika dostaw
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getRates()
|
||||
{
|
||||
return $this->rates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia listę stawek cennika dostaw
|
||||
*
|
||||
* @param array $rates Lista stawek cennika dostaw
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setRates(array $rates)
|
||||
{
|
||||
$this->rates = $rates;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca stawkę cennika dostawy po GUID
|
||||
*
|
||||
* @param string $id GUID stawki
|
||||
* @param string|null $default Wartość domyślna w przypadku braku stawki
|
||||
* @return array
|
||||
*/
|
||||
public function getRate($id, $default = null)
|
||||
{
|
||||
return isset($this->rates[$id]) ? $this->rates[$id] : $default;
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isNew())
|
||||
{
|
||||
$response = stAllegroApi::getInstance()->createShippingRate(array(
|
||||
'name' => $this->name,
|
||||
'rates' => $this->rates
|
||||
));
|
||||
|
||||
$this->id = $response->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
stAllegroApi::getInstance()->updateShippingRate($this->id, array(
|
||||
'name' => $this->name,
|
||||
'rates' => $this->rates,
|
||||
));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user