Skip to content

Commit

Permalink
Finish 0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgoodchild committed Aug 24, 2021
2 parents a48c66d + e0e1a44 commit d563200
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.3.0] - 2021-08-22
## [0.3.1] - 2021-08-22
### Added
- Add support for new Bill Items update to the API.

Expand Down
32 changes: 23 additions & 9 deletions src/Entities/Bills/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace FernleafSystems\ApiWrappers\Freeagent\Entities\Bills;

use FernleafSystems\ApiWrappers\Freeagent\Entities\Bills\Items\BillItemVO;
use FernleafSystems\ApiWrappers\Freeagent\Entities\Categories\CategoryVO;
use FernleafSystems\ApiWrappers\Freeagent\Entities\Contacts\ContactVO;

Expand All @@ -14,29 +15,42 @@ class Create extends Base {
const REQUEST_METHOD = 'post';

/**
* @param array $aData
* @param array $data
* @return BillVO|null
*/
public function create( $aData = [] ) {
return $this->setRequestData( $aData, true )
public function create( array $data = [] ) {
return $this->setRequestData( $data, true )
->sendRequestWithVoResponse();
}

/**
* @param CategoryVO $oCategory
* @param BillItemVO $item
* @return $this
*/
public function setCategory( $oCategory ) {
return $this->setRequestDataItem( 'category', $oCategory->getUri() );
public function addBillItem( BillItemVO $item, $merge = true ) {
$items = $this->getRequestDataItem( 'bill_items' );
if ( !$merge || !is_array( $items ) ) {
$items = [];
}
$items[] = $item->getRawDataAsArray();
return $this->setRequestDataItem( 'bill_items', $items );
}

/**
* @param CategoryVO $category
* @return $this
*/
public function setCategory( CategoryVO $category ) {
return $this->setRequestDataItem( 'category', $category->getUri() );
}

/**
* Will attempt to construct the URI for this category from the Base ID
* @param int $nId
* @param int $id
* @return $this
*/
public function setCategoryId( $nId ) {
return $this->setRequestDataItem( 'category', $this->getCategoryUrl( $nId ) );
public function setCategoryId( $id ) {
return $this->setRequestDataItem( 'category', $this->getCategoryUrl( $id ) );
}

/**
Expand Down

0 comments on commit d563200

Please sign in to comment.