Skip to content
Permalink
Browse files

Invoice rebase (#22)

* create the invoice model

* update the api

* general update

* The StyleCI update

* fix code style

* Fix cache response

* Fix issues

* Adding files in tests maps and fixing the assertions test

* staging cache file and fixing the code style

* deleting of the useless constructor and files

* fix issues #18 & #17 in invoice branch

* cs

* cs

* last update

* fix cs

* fix composer.json

* using guzzel

* fix cs
  • Loading branch information...
Ibrahimhizeoui authored and Nyholm committed Aug 1, 2017
1 parent c13142c commit c0435cc1ab98c28aa226f45b008d94df348b1a60
@@ -31,8 +31,7 @@
"php-http/message": "^1.0",
"guzzlehttp/psr7": "^1.3",
"nyholm/nsa": "^1.0",
"php-http/mock-client": "^1.0",
"nyholm/psr7": "^0.2.2"
"php-http/mock-client": "^1.0"
},
"autoload": {
"psr-4": {"Billogram\\": "src"}
@@ -7,7 +7,7 @@
use Billogram\Exception\Domain\NotFoundException;
use Billogram\Exception\Domain\ValidationException;
use Billogram\Model\Customer\Customer as Model;
use Billogram\Model\Customer\Customers;
use Billogram\Model\Customer\CustomerCollection;
use Psr\Http\Message\ResponseInterface;
/**
@@ -33,7 +33,7 @@ public function search(array $param = [])
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Customers::class);
return $this->hydrator->hydrate($response, CustomerCollection::class);
}
/**
@@ -6,7 +6,7 @@
use Billogram\Exception\Domain\ValidationException;
use Billogram\Model\Invoice\Invoice as Model;
use Billogram\Model\Invoice\Invoices;
use Billogram\Model\Invoice\InvoiceCollection;
/**
* @author Ibrahim Hizeoui <ibrahimhizeoui@gmail.com>
@@ -33,7 +33,7 @@ public function search(array $param = [])
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Invoices::class);
return $this->hydrator->hydrate($response, InvoiceCollection::class);
}
/**
@@ -6,7 +6,7 @@
use Billogram\Exception\Domain\ValidationException;
use Billogram\Model\Item\Item as Model;
use Billogram\Model\Item\Items;
use Billogram\Model\Item\CollectionItem;
/**
* @author Ibrahim Hizeoui <ibrahimhizeoui@gmail.com>
@@ -32,7 +32,7 @@ public function search(array $param = [])
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Items::class);
return $this->hydrator->hydrate($response, CollectionItem::class);
}
/**
@@ -105,18 +105,17 @@ public function update(int $itemNo, Model $item)
}
/**
* @param int $itemNo
* @param Model $item
* @param int $itemNo
*
* @return mixed|\Psr\Http\Message\ResponseInterface
*
* @throws ValidationException
*
* @see https://billogram.com/api/documentation#items_delete
*/
public function delete(int $itemNo, Model $item)
public function delete(int $itemNo)
{
$response = $this->httpDelete('/item/'.$itemNo, $item->toArray());
$response = $this->httpDelete('/item/'.$itemNo);
if (!$this->hydrator) {
return $response;
}
@@ -72,18 +72,18 @@ public function isUseCareOfAsAttention()
return $this->useCareOfAsAttention;
}
/**
* @param bool $useCareOfAsAttention
*
* @return CustomerBillingAddress
*/
public function withUseCareOfAsAttention(bool $useCareOfAsAttention)
{
$new = clone $this;
$new->useCareOfAsAttention = $useCareOfAsAttention;
return $new;
}
/**
* @param bool $useCareOfAsAttention
*
* @return CustomerBillingAddress
*/
public function withUseCareOfAsAttention(bool $useCareOfAsAttention)
{
$new = clone $this;
$new->useCareOfAsAttention = $useCareOfAsAttention;
return $new;
}
/**
* @return string
@@ -9,7 +9,7 @@
/**
* @author Ibrahim Hizeoui <ibrahimhizeoui@gmail.com>
*/
class Customers implements CreatableFromArray
class CustomerCollection implements CreatableFromArray
{
/**
* @var Customer[]
@@ -9,7 +9,7 @@
/**
* @author Ibrahim Hizeoui <ibrahimhizeoui@gmail.com>
*/
class Invoices implements CreatableFromArray
class InvoiceCollection implements CreatableFromArray
{
/**
* @var Invoice[]
@@ -5,13 +5,13 @@
namespace Billogram\Model\Invoice;
use Billogram\Model\CreatableFromArray;
use Billogram\Model\Item\BaseItem;
use Billogram\Model\Item\Bookkeeping;
use Billogram\Model\Item\Item as Model;
/**
* @author Ibrahim Hizeoui <ibrahimhizeoui@gmail.com>
*/
class Item extends Model implements CreatableFromArray
class Item extends BaseItem implements CreatableFromArray
{
/**
* @var int count
@@ -88,14 +88,14 @@ public static function createFromArray(array $data)
$item->count = $data['count'];
$item->discount = $data['discount'];
//$item = $item->withItemNo($data['item_no']) ?? null;
$item = $item->withTitle($data['title']) ?? null;
$item = $item->withDescription($data['description']) ?? null;
$item = $item->withPrice($data['price']) ?? null;
$item = $item->withVat($data['vat']) ?? null;
$item = $item->withUnit($data['unit']) ?? null;
$item->itemNo = $data['item_no'] ?? null;
$item->title = $data['title'] ?? null;
$item->description = $data['description'] ?? null;
$item->price = $data['price'] ?? null;
$item->vat = $data['vat'] ?? null;
$item->unit = $data['unit'] ?? null;
$item = $item->withBookkeeping(Bookkeeping::createFromArray($data['bookkeeping'])) ?? null;
//$item = parent::createFromArray($data);
return $item;
}
}

0 comments on commit c0435cc

Please sign in to comment.
You can’t perform that action at this time.