diff --git a/src/rokde/Gsales/Api/Client.php b/src/rokde/Gsales/Api/Client.php index f9d996d..7a88bee 100644 --- a/src/rokde/Gsales/Api/Client.php +++ b/src/rokde/Gsales/Api/Client.php @@ -165,6 +165,16 @@ public function user() return $this->getContextInstance('User'); } + /** + * returns delivery context + * + * @return \Rokde\Gsales\Api\Contexts\Delivery + */ + public function delivery() + { + return $this->getContextInstance('Delivery'); + } + /** * returns a configuration context * @@ -192,4 +202,4 @@ protected function getContextInstance($context) return static::$contexts[$context]; } -} \ No newline at end of file +} diff --git a/src/rokde/Gsales/Api/Contexts/Api.php b/src/rokde/Gsales/Api/Contexts/Api.php index 656fe86..d32322a 100644 --- a/src/rokde/Gsales/Api/Contexts/Api.php +++ b/src/rokde/Gsales/Api/Contexts/Api.php @@ -85,6 +85,12 @@ public static function classmap() 'InvoiceSumm' => $namespace . '\Types\Invoice\Sum', 'DunningAction' => $namespace . '\Types\Invoice\DunningAction', + 'Delivery' => $namespace . '\Types\DeliveryType', + 'DeliveryBase' => $namespace . '\Types\Delivery\Base', + 'DeliveryBaseFilterable' => $namespace . '\Types\Delivery\BaseFilterable', + 'DeliveryPosition' => $namespace . '\Types\Delivery\Position', + 'DeliverySumm' => $namespace . '\Types\Delivery\Sum', + 'Refund' => $namespace . '\Types\RefundType', 'RefundBase' => $namespace . '\Types\Refund\Base', 'RefundBaseFilterable' => $namespace . '\Types\Refund\BaseFilterable', @@ -260,4 +266,4 @@ private function prepareFilterOnlyParameter($filter, array $params = array()) return $params; } -} \ No newline at end of file +} diff --git a/src/rokde/Gsales/Api/Contexts/Delivery.php b/src/rokde/Gsales/Api/Contexts/Delivery.php new file mode 100644 index 0000000..a4cb6b3 --- /dev/null +++ b/src/rokde/Gsales/Api/Contexts/Delivery.php @@ -0,0 +1,221 @@ +getEntity('getDelivery', 'deliveryid', $deliveryId); + } + + /** + * returns deliverys by filter and ordering, pagination possible + * + * @param Filter[] $filter + * @param Sort $sort + * @param int $limit + * @param int $offset + * + * @return \Rokde\Gsales\Api\Types\DeliveryType[] + */ + public function all($filter = null, $sort = null, $limit = null, $offset = null) + { + return $this->getCollection('getDeliverys', $filter, $sort, $limit, $offset); + } + + /** + * returns number of deliverys by filter + * + * @param Filter[] $filter + * + * @return int + */ + public function count($filter = null) + { + return $this->getCollectionCount('getDeliverysCount', $filter); + } + + /** + * marks an delivery as paid + * + * @param \Rokde\Gsales\Api\Types\DeliveryType|int $delivery + * + * @return \Rokde\Gsales\Api\Types\DeliveryType + */ + public function paid($delivery) + { + return $this->modifyState('setDeliveryStatePaid', 'deliveryid', $delivery); + } + + /** + * marks an delivery as open + * + * @param \Rokde\Gsales\Api\Types\DeliveryType|int $delivery + * + * @return \Rokde\Gsales\Api\Types\DeliveryType + */ + public function open($delivery) + { + return $this->modifyState('setDeliveryStateOpen', 'deliveryid', $delivery); + } + + /** + * marks an delivery as canceled + * + * @param \Rokde\Gsales\Api\Types\DeliveryType|int $delivery + * + * @return \Rokde\Gsales\Api\Types\DeliveryType + */ + public function canceled($delivery) + { + return $this->modifyState('setDeliveryStateCanceled', 'deliveryid', $delivery); + } + + /** + * creates a position within an delivery + * + * @param \Rokde\Gsales\Api\Types\DeliveryType|int $delivery + * @param BasePosition $position + * + * @return \Rokde\Gsales\Api\Types\DeliveryType + */ + public function createPosition($delivery, BasePosition $position) + { + $deliveryId = Type::getIdentifier($delivery); + + return $this->call('createDeliveryPosition', ['deliveryid' => $deliveryId, 'data' => $position]); + } + + /** + * updates a position within an delivery + * + * @param \Rokde\Gsales\Api\Types\DeliveryType|int $delivery + * @param Position $position + * + * @return \Rokde\Gsales\Api\Types\DeliveryType + */ + public function updatePosition($delivery, Position $position) + { + $deliveryId = Type::getIdentifier($delivery); + $positionId = $position->getId(); + + return $this->call('updateDeliveryPosition', ['deliveryid' => $deliveryId, 'positionid' => $positionId, 'data' => $position]); + } + + /** + * deletes a position from an delivery + * + * @param \Rokde\Gsales\Api\Types\DeliveryType|int $delivery + * @param Position|int $position + * + * @return \Rokde\Gsales\Api\Types\DeliveryType + */ + public function deletePosition($delivery, $position) + { + $deliveryId = Type::getIdentifier($delivery); + $positionId = Type::getIdentifier($position); + + return $this->call('deleteDeliveryPosition', ['deliveryid' => $deliveryId, 'positionid' => $positionId]); + } + + /** + * deletes an delivery + * + * @param \Rokde\Gsales\Api\Types\DeliveryType|int $delivery + * + * @return bool + */ + public function delete($delivery) + { + $deliveryId = Type::getIdentifier($delivery); + + return $this->call('deleteDelivery', ['deliveryid' => $deliveryId]); + } + + /** + * creates an delivery for a customer + * + * @param Customer|int $customer + * + * @return \Rokde\Gsales\Api\Types\DeliveryType + */ + public function createForCustomer($customer) + { + $customerId = Type::getIdentifier($customer); + + return $this->call('createDeliveryForCustomer', ['customerid' => $customerId]); + } + + /** + * creates an delivery + * + * @param Base $delivery + * + * @return \Rokde\Gsales\Api\Types\DeliveryType + */ + public function create(Base $delivery) + { + return $this->call('createDelivery', ['data' => $delivery]); + } + + /** + * creates an delivery + * + * @param Base $delivery + * + * @return \Rokde\Gsales\Api\Types\DeliveryType + */ + public function update(Base $delivery) + { + $deliveryId = $delivery->getId(); + + return $this->call('updateDelivery', ['deliveryid' => $deliveryId, 'data' => $delivery]); + } + + /** + * adds delivery to mailspool + * + * @param \Rokde\Gsales\Api\Types\DeliveryType $delivery + * + * @return bool + */ + public function addToMailspool($delivery) + { + $deliveryId = Type::getIdentifier($delivery); + + return $this->call('addDeliveryToMailspool', ['deliveryid' => $deliveryId]); + } + + /** + * returns pdf file of delivery + * + * @param $delivery + * + * @return File + */ + public function pdf($delivery) + { + $deliveryId = Type::getIdentifier($delivery); + + return $this->call('getDeliveryPDF', ['deliveryid' => $deliveryId]); + } +} diff --git a/src/rokde/Gsales/Api/Types/Delivery/Base.php b/src/rokde/Gsales/Api/Types/Delivery/Base.php new file mode 100644 index 0000000..0ccca28 --- /dev/null +++ b/src/rokde/Gsales/Api/Types/Delivery/Base.php @@ -0,0 +1,10 @@ +deliverydate = $deliverydate; + return $this; + } + + /** + * returns DeliveryDate + * + * @param bool $formatted + * + * @return string + */ + public function getDeliveryDate($formatted = true) + { + if ($formatted) + return DateTime::createFromFormat('Y-m-d', $this->deliverydate)->setTime(0, 0, 0); + + return $this->deliverydate; + } + + /** + * sets mediafinanz file + * + * @param string $mediafinanz_file + * + * @return $this + */ + public function setMediafinanzFile($mediafinanz_file) + { + $this->mediafinanz_file = $mediafinanz_file; + return $this; + } + + /** + * returns Mediafinanz File + * + * @return string + */ + public function getMediafinanzFile() + { + return $this->mediafinanz_file; + } + + /** + * sets partial payment + * + * @param float $partialpayment + * + * @return $this + */ + public function setPartialpayment($partialpayment) + { + $this->partialpayment = $partialpayment; + return $this; + } + + /** + * returns Partial payment + * + * @return float + */ + public function getPartialpayment() + { + return $this->partialpayment; + } + + /** + * sets payable + * + * @param string $payable date(Y-m-d) + * + * @return $this + */ + public function setPayable($payable) + { + $this->payable = $payable; + return $this; + } + + /** + * returns Payable + * + * @param bool $formatted + * + * @return string + */ + public function getPayable($formatted = true) + { + if ($formatted) + return DateTime::createFromFormat('Y-m-d', $this->payable)->setTime(0, 0, 0); + + return $this->payable; + } + + /** + * sets storno text + * + * @param string $storno_txt + * + * @return $this + */ + public function setStornoText($storno_txt) + { + $this->storno_txt = $storno_txt; + return $this; + } + + /** + * returns Storno Text + * + * @return string + */ + public function getStornoText() + { + return $this->storno_txt; + } +} diff --git a/src/rokde/Gsales/Api/Types/Delivery/BasePosition.php b/src/rokde/Gsales/Api/Types/Delivery/BasePosition.php new file mode 100644 index 0000000..aa1dc23 --- /dev/null +++ b/src/rokde/Gsales/Api/Types/Delivery/BasePosition.php @@ -0,0 +1,12 @@ +action; + } + + /** + * returns Created + * + * @param bool $formatted + * + * @return string|\DateTime + */ + public function getCreated($formatted = true) + { + if ($formatted) + return \DateTime::createFromFormat('Y-m-d H:i:s', $this->created); + + return $this->created; + } + + /** + * returns Fee + * + * @return float + */ + public function getFee() + { + return $this->fee; + } + + /** + * returns Id + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * returns Invoice Id + * + * @return int + */ + public function getInvoiceId() + { + return $this->invoices_id; + } +} diff --git a/src/rokde/Gsales/Api/Types/Delivery/Position.php b/src/rokde/Gsales/Api/Types/Delivery/Position.php new file mode 100644 index 0000000..fd60102 --- /dev/null +++ b/src/rokde/Gsales/Api/Types/Delivery/Position.php @@ -0,0 +1,191 @@ +article_id; + } + + /** + * returns CurrencyPrice (net) + * + * @return float + */ + public function getCurrencyPrice() + { + return $this->curr_price; + } + + /** + * returns DiscountValue + * + * @return float + */ + public function getDiscountValue() + { + return $this->discount_value; + } + + /** + * returns Headline + * + * @return int + */ + public function getHeadline() + { + return $this->headline; + } + + /** + * returns Id + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * returns InvoicesId + * + * @return int + */ + public function getInvoicesId() + { + return $this->invoices_id; + } + + /** + * returns rounded total price in currency (net) + * + * @return float + */ + public function getRoundedCurrencyTotalPrice() + { + return $this->rounded_curr_tprice; + } + + /** + * returns rounded total price (net) + * + * @return float + */ + public function getRoundedTotalPrice() + { + return $this->rounded_tprice; + } + + /** + * returns sort number + * + * @return int + */ + public function getSortNumber() + { + return $this->sortno; + } + + /** + * returns TaxValue + * + * @return float + */ + public function getTaxValue() + { + return $this->tax_value; + } + + /** + * returns total price + * + * @return float + */ + public function getTotalPrice() + { + return $this->tprice; + } + + /** + * returns assembled position text + * + * @return string + */ + public function getPositionTextAssembled() + { + return $this->vars_pos_txt; + } +} diff --git a/src/rokde/Gsales/Api/Types/Delivery/Sum.php b/src/rokde/Gsales/Api/Types/Delivery/Sum.php new file mode 100644 index 0000000..54bd59f --- /dev/null +++ b/src/rokde/Gsales/Api/Types/Delivery/Sum.php @@ -0,0 +1,12 @@ +base; + } + + /** + * returns Dunning + * + * @return \Rokde\Gsales\Api\Types\Invoice\DunningAction[] + */ + public function getDunning() + { + return $this->dunning; + } + + /** + * returns Pos + * + * @return \Rokde\Gsales\Api\Types\Invoice\Position[] + */ + public function getPos() + { + return $this->pos; + } + + /** + * returns Summ + * + * @return \Rokde\Gsales\Api\Types\Invoice\Sum + */ + public function getSumm() + { + return $this->summ; + } + + /** + * returns invoice id + * + * @return int + */ + public function getId() + { + return $this->getBase()->getId(); + } + + /** + * is the invoice open + * + * @return bool + */ + public function isOpen() + { + return $this->getBase()->getStatus() === InvoiceStatus::OPEN; + } + + /** + * is the invoice paid + * + * @return bool + */ + public function isPaid() + { + return $this->getBase()->getStatus() >= InvoiceStatus::BILLED; + } +}